@Test public void shouldShowAllocatedBudgetAsNotAllocatedIfBudgetAppliesForRegularRnrAndNotProvided() throws DocumentException { when(messageService.message("label.summary")).thenReturn("Summary"); when(messageService.message("label.total.cost.full.supply.items")).thenReturn("Total Cost For Full Supply Items"); when(messageService.message("label.total.cost.non.full.supply.items")).thenReturn("Total Cost For Non Full Supply Items"); when(messageService.message("label.total.cost")).thenReturn("Total Cost"); when(messageService.message("label.submitted.by")).thenReturn("Submitted By"); when(messageService.message("label.authorized.by")).thenReturn("Authorized By"); when(messageService.message("label.date")).thenReturn("Date"); when(messageService.message("label.currency.symbol")).thenReturn("$"); when(messageService.message("label.allocated.budget")).thenReturn("Allocated Budget"); when(messageService.message("msg.cost.exceeds.budget")).thenReturn("The total cost exceeds the allocated budget"); when(messageService.message("msg.budget.not.allocated")).thenReturn("Not Allocated"); Program requisitionProgram = mock(Program.class); when(requisition.getProgram()).thenReturn(requisitionProgram); when(requisition.isEmergency()).thenReturn(false); when(requisitionProgram.getBudgetingApplies()).thenReturn(true); when(requisition.getAllocatedBudget()).thenReturn(null); PdfPTable summary = requisitionPdfModel.getSummary(); assertRowValues(summary.getRow(0), "Summary"); assertRowValues(summary.getRow(1), "Allocated Budget", "Not Allocated"); assertRowValues(summary.getRow(2), "Total Cost For Full Supply Items", "$8.00"); assertRowValues(summary.getRow(3), "Total Cost For Non Full Supply Items", "$0.00"); assertRowValues(summary.getRow(4), "Total Cost", "$8.00"); assertRowValues(summary.getRow(5), " ", " "); assertRowValues(summary.getRow(6), " ", " "); assertRowValues(summary.getRow(7), "Submitted By: submit-firstName submit-lastName", "Date: " + DATE_FORMAT.format(currentDate.getTime())); assertRowValues(summary.getRow(8), " ", " "); assertRowValues(summary.getRow(9), "Authorized By: auth-firstName auth-lastName", "Date: " + DATE_FORMAT.format(authorizedDate.getTime())); }
public PdfPTable getSummary() throws DocumentException { this.requisition.fillFullSupplyCost(); this.requisition.fillNonFullSupplyCost(); DecimalFormat formatter = new DecimalFormat("#,##0.00"); PdfPTable summaryTable = new PdfPTable(2); summaryTable.setWidths(new int[]{30, 20}); summaryTable.setSpacingBefore(TABLE_SPACING); summaryTable.setWidthPercentage(40); summaryTable.setHorizontalAlignment(0); PdfPCell summaryHeaderCell = headingCell(messageService.message("label.summary")); summaryHeaderCell.setColspan(2); summaryHeaderCell.setPadding(10); summaryHeaderCell.setBorder(0); summaryTable.addCell(summaryHeaderCell); boolean showBudget = !requisition.isEmergency() && requisition.getProgram().getBudgetingApplies(); if (showBudget) { summaryTable.addCell(summaryCell(textCell(messageService.message("label.allocated.budget")))); PdfPCell allocatedBudgetCell = requisition.getAllocatedBudget() != null ? numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format( new Money(requisition.getAllocatedBudget()).toDecimal())) : numberCell(messageService.message("msg.budget.not.allocated")); summaryTable.addCell(summaryCell(allocatedBudgetCell)); } summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost.full.supply.items")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(requisition.getFullSupplyItemsSubmittedCost().toDecimal()))) ); summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost.non.full.supply.items")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(requisition.getNonFullSupplyItemsSubmittedCost().toDecimal())))); summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(this.getTotalCost( requisition).toDecimal()).toString()))); if (showBudget && requisition.getAllocatedBudget() != null && (requisition.getAllocatedBudget().compareTo(this.getTotalCost(requisition).getValue()) == -1)) { summaryTable.addCell(summaryCell(textCell(messageService.message("msg.cost.exceeds.budget")))); summaryTable.addCell(summaryCell(textCell(" "))); } summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); fillAuditFields(summaryTable); return summaryTable; }
RequisitionPdfModel { public PdfPTable getSummary() throws DocumentException { this.requisition.fillFullSupplyCost(); this.requisition.fillNonFullSupplyCost(); DecimalFormat formatter = new DecimalFormat("#,##0.00"); PdfPTable summaryTable = new PdfPTable(2); summaryTable.setWidths(new int[]{30, 20}); summaryTable.setSpacingBefore(TABLE_SPACING); summaryTable.setWidthPercentage(40); summaryTable.setHorizontalAlignment(0); PdfPCell summaryHeaderCell = headingCell(messageService.message("label.summary")); summaryHeaderCell.setColspan(2); summaryHeaderCell.setPadding(10); summaryHeaderCell.setBorder(0); summaryTable.addCell(summaryHeaderCell); boolean showBudget = !requisition.isEmergency() && requisition.getProgram().getBudgetingApplies(); if (showBudget) { summaryTable.addCell(summaryCell(textCell(messageService.message("label.allocated.budget")))); PdfPCell allocatedBudgetCell = requisition.getAllocatedBudget() != null ? numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format( new Money(requisition.getAllocatedBudget()).toDecimal())) : numberCell(messageService.message("msg.budget.not.allocated")); summaryTable.addCell(summaryCell(allocatedBudgetCell)); } summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost.full.supply.items")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(requisition.getFullSupplyItemsSubmittedCost().toDecimal()))) ); summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost.non.full.supply.items")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(requisition.getNonFullSupplyItemsSubmittedCost().toDecimal())))); summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(this.getTotalCost( requisition).toDecimal()).toString()))); if (showBudget && requisition.getAllocatedBudget() != null && (requisition.getAllocatedBudget().compareTo(this.getTotalCost(requisition).getValue()) == -1)) { summaryTable.addCell(summaryCell(textCell(messageService.message("msg.cost.exceeds.budget")))); summaryTable.addCell(summaryCell(textCell(" "))); } summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); fillAuditFields(summaryTable); return summaryTable; } }
RequisitionPdfModel { public PdfPTable getSummary() throws DocumentException { this.requisition.fillFullSupplyCost(); this.requisition.fillNonFullSupplyCost(); DecimalFormat formatter = new DecimalFormat("#,##0.00"); PdfPTable summaryTable = new PdfPTable(2); summaryTable.setWidths(new int[]{30, 20}); summaryTable.setSpacingBefore(TABLE_SPACING); summaryTable.setWidthPercentage(40); summaryTable.setHorizontalAlignment(0); PdfPCell summaryHeaderCell = headingCell(messageService.message("label.summary")); summaryHeaderCell.setColspan(2); summaryHeaderCell.setPadding(10); summaryHeaderCell.setBorder(0); summaryTable.addCell(summaryHeaderCell); boolean showBudget = !requisition.isEmergency() && requisition.getProgram().getBudgetingApplies(); if (showBudget) { summaryTable.addCell(summaryCell(textCell(messageService.message("label.allocated.budget")))); PdfPCell allocatedBudgetCell = requisition.getAllocatedBudget() != null ? numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format( new Money(requisition.getAllocatedBudget()).toDecimal())) : numberCell(messageService.message("msg.budget.not.allocated")); summaryTable.addCell(summaryCell(allocatedBudgetCell)); } summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost.full.supply.items")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(requisition.getFullSupplyItemsSubmittedCost().toDecimal()))) ); summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost.non.full.supply.items")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(requisition.getNonFullSupplyItemsSubmittedCost().toDecimal())))); summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(this.getTotalCost( requisition).toDecimal()).toString()))); if (showBudget && requisition.getAllocatedBudget() != null && (requisition.getAllocatedBudget().compareTo(this.getTotalCost(requisition).getValue()) == -1)) { summaryTable.addCell(summaryCell(textCell(messageService.message("msg.cost.exceeds.budget")))); summaryTable.addCell(summaryCell(textCell(" "))); } summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); fillAuditFields(summaryTable); return summaryTable; } RequisitionPdfModel(Map<String, Object> model, MessageService messageService, ConfigurationSettingService configService); }
RequisitionPdfModel { public PdfPTable getSummary() throws DocumentException { this.requisition.fillFullSupplyCost(); this.requisition.fillNonFullSupplyCost(); DecimalFormat formatter = new DecimalFormat("#,##0.00"); PdfPTable summaryTable = new PdfPTable(2); summaryTable.setWidths(new int[]{30, 20}); summaryTable.setSpacingBefore(TABLE_SPACING); summaryTable.setWidthPercentage(40); summaryTable.setHorizontalAlignment(0); PdfPCell summaryHeaderCell = headingCell(messageService.message("label.summary")); summaryHeaderCell.setColspan(2); summaryHeaderCell.setPadding(10); summaryHeaderCell.setBorder(0); summaryTable.addCell(summaryHeaderCell); boolean showBudget = !requisition.isEmergency() && requisition.getProgram().getBudgetingApplies(); if (showBudget) { summaryTable.addCell(summaryCell(textCell(messageService.message("label.allocated.budget")))); PdfPCell allocatedBudgetCell = requisition.getAllocatedBudget() != null ? numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format( new Money(requisition.getAllocatedBudget()).toDecimal())) : numberCell(messageService.message("msg.budget.not.allocated")); summaryTable.addCell(summaryCell(allocatedBudgetCell)); } summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost.full.supply.items")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(requisition.getFullSupplyItemsSubmittedCost().toDecimal()))) ); summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost.non.full.supply.items")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(requisition.getNonFullSupplyItemsSubmittedCost().toDecimal())))); summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(this.getTotalCost( requisition).toDecimal()).toString()))); if (showBudget && requisition.getAllocatedBudget() != null && (requisition.getAllocatedBudget().compareTo(this.getTotalCost(requisition).getValue()) == -1)) { summaryTable.addCell(summaryCell(textCell(messageService.message("msg.cost.exceeds.budget")))); summaryTable.addCell(summaryCell(textCell(" "))); } summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); fillAuditFields(summaryTable); return summaryTable; } RequisitionPdfModel(Map<String, Object> model, MessageService messageService, ConfigurationSettingService configService); Paragraph getFullSupplyHeader(); Paragraph getNonFullSupplyHeader(); PdfPTable getFullSupplyTable(); PdfPTable getRegimenTable(); PdfPTable getNonFullSupplyTable(); PdfPTable getRequisitionHeader(); PdfPTable getSummary(); Money getTotalCost(Rnr requisition); Paragraph getRegimenHeader(); }
RequisitionPdfModel { public PdfPTable getSummary() throws DocumentException { this.requisition.fillFullSupplyCost(); this.requisition.fillNonFullSupplyCost(); DecimalFormat formatter = new DecimalFormat("#,##0.00"); PdfPTable summaryTable = new PdfPTable(2); summaryTable.setWidths(new int[]{30, 20}); summaryTable.setSpacingBefore(TABLE_SPACING); summaryTable.setWidthPercentage(40); summaryTable.setHorizontalAlignment(0); PdfPCell summaryHeaderCell = headingCell(messageService.message("label.summary")); summaryHeaderCell.setColspan(2); summaryHeaderCell.setPadding(10); summaryHeaderCell.setBorder(0); summaryTable.addCell(summaryHeaderCell); boolean showBudget = !requisition.isEmergency() && requisition.getProgram().getBudgetingApplies(); if (showBudget) { summaryTable.addCell(summaryCell(textCell(messageService.message("label.allocated.budget")))); PdfPCell allocatedBudgetCell = requisition.getAllocatedBudget() != null ? numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format( new Money(requisition.getAllocatedBudget()).toDecimal())) : numberCell(messageService.message("msg.budget.not.allocated")); summaryTable.addCell(summaryCell(allocatedBudgetCell)); } summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost.full.supply.items")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(requisition.getFullSupplyItemsSubmittedCost().toDecimal()))) ); summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost.non.full.supply.items")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(requisition.getNonFullSupplyItemsSubmittedCost().toDecimal())))); summaryTable.addCell(summaryCell(textCell(messageService.message("label.total.cost")))); summaryTable.addCell(summaryCell(numberCell(messageService.message(LABEL_CURRENCY_SYMBOL) + formatter.format(this.getTotalCost( requisition).toDecimal()).toString()))); if (showBudget && requisition.getAllocatedBudget() != null && (requisition.getAllocatedBudget().compareTo(this.getTotalCost(requisition).getValue()) == -1)) { summaryTable.addCell(summaryCell(textCell(messageService.message("msg.cost.exceeds.budget")))); summaryTable.addCell(summaryCell(textCell(" "))); } summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); summaryTable.addCell(summaryCell(textCell(" "))); fillAuditFields(summaryTable); return summaryTable; } RequisitionPdfModel(Map<String, Object> model, MessageService messageService, ConfigurationSettingService configService); Paragraph getFullSupplyHeader(); Paragraph getNonFullSupplyHeader(); PdfPTable getFullSupplyTable(); PdfPTable getRegimenTable(); PdfPTable getNonFullSupplyTable(); PdfPTable getRequisitionHeader(); PdfPTable getSummary(); Money getTotalCost(Rnr requisition); Paragraph getRegimenHeader(); static final String LABEL_CURRENCY_SYMBOL; static final float PARAGRAPH_SPACING; static final BaseColor ROW_GREY_BACKGROUND; static final Font H1_FONT; static final SimpleDateFormat DATE_FORMAT; static final int TABLE_SPACING; }