private AdjustmentLetter GetTestData_Letter() { var letter = new AdjustmentLetter(); var voucherInfo = GetTestData_VoucherInfo(); letter.PdfFilename = "Hello.pdf"; letter.AdjustedVoucher = voucherInfo; letter.Vouchers.Add(voucherInfo); return(letter); }
public void WhenGenerateReportCalled_ThenCreateReportPage() { var letterGenerator = new LetterGenerator(config.Object, aspose.Object); var voucher = TestData_VoucherInfo(); var letter = new AdjustmentLetter { AdjustedVoucher = voucher }; letter.Vouchers.Add(voucher); var pdf = new Document(); var count = pdf.Pages.Count; letterGenerator.AddTransactionReport(pdf, letter); Assert.AreEqual(count + 1, pdf.Pages.Count); }
public void WhenAddImageCalled_ThenCreatePdfPage() { var letterGenerator = new LetterGenerator(config.Object, aspose.Object); var voucher = TestData_VoucherInfo(); var letter = new AdjustmentLetter { AdjustedVoucher = voucher }; letter.Vouchers.Add(voucher); var jobIdLocation = config.Object.BitLockerLocation; var pdf = new Document(); var count = pdf.Pages.Count; letterGenerator.AddVoucherImage(jobIdLocation, pdf, letter, fileReader.Object); Assert.AreEqual(count + 1, pdf.Pages.Count); }
public ValidatedResponse <AdjLetterBatch> Map(CreateBatchAdjustmentLettersRequest request) { if (string.IsNullOrEmpty(request.jobIdentifier)) { Log.Error("MessageToBatchConverter:Map, Request does not contain a jobIdentifier."); return(this.Failure("Request does not contain a jobIdentifier")); } var batch = new AdjLetterBatch(); batch.JobFolderLocation = this.pathHelper.GetJobPath(request.jobIdentifier.Replace("/", "\\")).Result; batch.JobIdentifier = request.jobIdentifier; batch.ProcessingDate = request.processingDate; batch.PdfZipFilename = string.Format(this.config.PdfZipFilename, this.config.Environment, request.processingDate.ToString(ReportConstants.DateTimeFormat)); if (request.voucherInformation.Any()) { var voucherGroup = request.voucherInformation.GroupBy(x => new { x.voucherProcess.transactionLinkNumber, x.voucherBatch.scannedBatchNumber }); var index = 1; foreach (var group in voucherGroup) { if (!group.Any(g => g.voucherProcess.adjustedFlag)) { return(this.Failure(string.Format("No adjusted Voucher found for {@batchNumber}, {@TransLinkNo}", group.First().voucherBatch.scannedBatchNumber, group.First().voucherProcess.transactionLinkNumber))); } else { foreach (var adjustedVoucher in group.Where(vi => vi.voucherProcess.adjustedFlag)) { var matchedCustomerDetails = request.outputMetadata.FirstOrDefault(t => t.customer.Any (g => g.accountNumber == adjustedVoucher.voucher.accountNumber && g.bsb == adjustedVoucher.voucher.bsbNumber)); var filenamePrefix = "nbsb"; if (matchedCustomerDetails != null) { filenamePrefix = matchedCustomerDetails.outputFilenamePrefix; } else { Log.Warning("WARNING: {@bsb} and {@accountNumber} did not match with the reference data, Letter will be generated using" + filenamePrefix + " prefix.", adjustedVoucher.voucher.bsbNumber, adjustedVoucher.voucher.accountNumber); } var newLetter = new AdjustmentLetter { AdjustedVoucher = adjustedVoucher, JobIdentifier = request.jobIdentifier, ProcessingDate = request.processingDate, PdfFilename = string.Format("{0}_{1}.pdf", filenamePrefix, index.ToString().PadLeft(4, '0')) }; batch.Letters.Add(newLetter); newLetter.Vouchers.AddRange(group.ToList()); index++; } } } } else { Log.Error("[MessageToBatchConverter:Map], No vouchers found."); return(this.Failure("No vouchers found")); } return(ValidatedResponse <AdjLetterBatch> .Success(batch)); }