@Test public void shouldCopyUserEditableFieldsOnlyIfVisible() throws Exception { RnrLineItem editedLineItem = make(a(defaultRnrLineItem)); editedLineItem.setRemarks("Submitted"); editedLineItem.setBeginningBalance(12); editedLineItem.setQuantityReceived(23); editedLineItem.setQuantityDispensed(32); editedLineItem.setStockInHand(1946); editedLineItem.setNewPatientCount(1); editedLineItem.setStockOutDays(7); editedLineItem.setQuantityRequested(43); editedLineItem.setReasonForRequestedQuantity("Reason"); List<LossesAndAdjustments> lossesAndAdjustments = new ArrayList<>(); editedLineItem.setLossesAndAdjustments(lossesAndAdjustments); lineItem.copyCreatorEditableFieldsForFullSupply(editedLineItem, new ProgramRnrTemplate(getRnrColumns())); assertThat(lineItem.getBeginningBalance(), is(RnrLineItemBuilder.DEFAULT_BEGINNING_BALANCE)); assertThat(lineItem.getStockOutDays(), is(RnrLineItemBuilder.STOCK_OUT_DAYS)); }
public void copyCreatorEditableFieldsForFullSupply(RnrLineItem lineItem, ProgramRnrTemplate template) { this.previousStockInHand = lineItem.previousStockInHand; copyTotalLossesAndAdjustments(lineItem, template); for (Column column : template.getColumns()) { String fieldName = column.getName(); if (fieldName.equals(QUANTITY_APPROVED)) continue; copyField(fieldName, lineItem, template); } }
RnrLineItem extends LineItem { public void copyCreatorEditableFieldsForFullSupply(RnrLineItem lineItem, ProgramRnrTemplate template) { this.previousStockInHand = lineItem.previousStockInHand; copyTotalLossesAndAdjustments(lineItem, template); for (Column column : template.getColumns()) { String fieldName = column.getName(); if (fieldName.equals(QUANTITY_APPROVED)) continue; copyField(fieldName, lineItem, template); } } }
RnrLineItem extends LineItem { public void copyCreatorEditableFieldsForFullSupply(RnrLineItem lineItem, ProgramRnrTemplate template) { this.previousStockInHand = lineItem.previousStockInHand; copyTotalLossesAndAdjustments(lineItem, template); for (Column column : template.getColumns()) { String fieldName = column.getName(); if (fieldName.equals(QUANTITY_APPROVED)) continue; copyField(fieldName, lineItem, template); } } RnrLineItem(Long rnrId,
                     FacilityTypeApprovedProduct facilityTypeApprovedProduct,
                     Long modifiedBy,
                     Long createdBy); }
RnrLineItem extends LineItem { public void copyCreatorEditableFieldsForFullSupply(RnrLineItem lineItem, ProgramRnrTemplate template) { this.previousStockInHand = lineItem.previousStockInHand; copyTotalLossesAndAdjustments(lineItem, template); for (Column column : template.getColumns()) { String fieldName = column.getName(); if (fieldName.equals(QUANTITY_APPROVED)) continue; copyField(fieldName, lineItem, template); } } RnrLineItem(Long rnrId,
                     FacilityTypeApprovedProduct facilityTypeApprovedProduct,
                     Long modifiedBy,
                     Long createdBy); void setFieldsForApproval(); void setBeginningBalanceWhenPreviousStockInHandAvailable(RnrLineItem previousLineItem,
                                                                  Boolean beginningBalanceVisible); void setSkippedValueWhenPreviousLineItemIsAvailable(RnrLineItem previousLineItem); void setLineItemFieldsAccordingToTemplate(ProgramRnrTemplate template); void validateForApproval(); void validateMandatoryFields(ProgramRnrTemplate template); void validateNonFullSupply(); void validateCalculatedFields(ProgramRnrTemplate template); void calculateForFullSupply(ProgramRnrTemplate template,
                                     RnrStatus rnrStatus,
                                     List<LossesAndAdjustmentsType> lossesAndAdjustmentsTypes, Integer numberOfMonths); void calculatePeriodNormalizedConsumption(Integer numberOfMonths); void calculateAmc(Integer numberOfMonths); void calculatePacksToShip(); void calculateMaxStockQuantity( ProgramRnrTemplate template); void calculateOrderQuantity(); void calculateNormalizedConsumption(ProgramRnrTemplate template); void calculateTotalLossesAndAdjustments(List<LossesAndAdjustmentsType> lossesAndAdjustmentsTypes); void calculateQuantityDispensed(); void calculateStockInHand(); Money calculateCost(); void copyCreatorEditableFieldsForFullSupply(RnrLineItem lineItem, ProgramRnrTemplate template); void copyCreatorEditableFieldsForNonFullSupply(RnrLineItem lineItem, ProgramRnrTemplate template); void copyApproverEditableFields(RnrLineItem lineItem, ProgramRnrTemplate template); void addLossesAndAdjustments(LossesAndAdjustments lossesAndAdjustments); @Override boolean compareCategory(LineItem lineItem); @Override String getCategoryName(); @Override String getValue(String columnName); @Override boolean isRnrLineItem(); }
RnrLineItem extends LineItem { public void copyCreatorEditableFieldsForFullSupply(RnrLineItem lineItem, ProgramRnrTemplate template) { this.previousStockInHand = lineItem.previousStockInHand; copyTotalLossesAndAdjustments(lineItem, template); for (Column column : template.getColumns()) { String fieldName = column.getName(); if (fieldName.equals(QUANTITY_APPROVED)) continue; copyField(fieldName, lineItem, template); } } RnrLineItem(Long rnrId,
                     FacilityTypeApprovedProduct facilityTypeApprovedProduct,
                     Long modifiedBy,
                     Long createdBy); void setFieldsForApproval(); void setBeginningBalanceWhenPreviousStockInHandAvailable(RnrLineItem previousLineItem,
                                                                  Boolean beginningBalanceVisible); void setSkippedValueWhenPreviousLineItemIsAvailable(RnrLineItem previousLineItem); void setLineItemFieldsAccordingToTemplate(ProgramRnrTemplate template); void validateForApproval(); void validateMandatoryFields(ProgramRnrTemplate template); void validateNonFullSupply(); void validateCalculatedFields(ProgramRnrTemplate template); void calculateForFullSupply(ProgramRnrTemplate template,
                                     RnrStatus rnrStatus,
                                     List<LossesAndAdjustmentsType> lossesAndAdjustmentsTypes, Integer numberOfMonths); void calculatePeriodNormalizedConsumption(Integer numberOfMonths); void calculateAmc(Integer numberOfMonths); void calculatePacksToShip(); void calculateMaxStockQuantity( ProgramRnrTemplate template); void calculateOrderQuantity(); void calculateNormalizedConsumption(ProgramRnrTemplate template); void calculateTotalLossesAndAdjustments(List<LossesAndAdjustmentsType> lossesAndAdjustmentsTypes); void calculateQuantityDispensed(); void calculateStockInHand(); Money calculateCost(); void copyCreatorEditableFieldsForFullSupply(RnrLineItem lineItem, ProgramRnrTemplate template); void copyCreatorEditableFieldsForNonFullSupply(RnrLineItem lineItem, ProgramRnrTemplate template); void copyApproverEditableFields(RnrLineItem lineItem, ProgramRnrTemplate template); void addLossesAndAdjustments(LossesAndAdjustments lossesAndAdjustments); @Override boolean compareCategory(LineItem lineItem); @Override String getCategoryName(); @Override String getValue(String columnName); @Override boolean isRnrLineItem(); static final BigDecimal NUMBER_OF_DAYS; static final MathContext MATH_CONTEXT; static final String DISPENSED_PLUS_NEW_PATIENTS; static final String DISPENSED_X_90; static final String DEFAULT; static final String DISPENSED_X_2; static final String CONSUMPTION_X_2; }