@Test public void shouldCalculatePacksToShipWhenCanRoundToZero() throws Exception { RnrLineItem lineItem = new RnrLineItem(); lineItem.setCalculatedOrderQuantity(6); lineItem.setPackSize(10); lineItem.setPackRoundingThreshold(7); lineItem.setRoundToZero(true); lineItem.calculatePacksToShip(); assertThat(lineItem.getPacksToShip(), is(0)); }
public void calculatePacksToShip() { Integer orderQuantity = getOrderQuantity(); if (allNotNull(orderQuantity, packSize)) { packsToShip = ((orderQuantity == 0) ? (roundToZero ? 0 : 1) : applyRoundingRules(orderQuantity)); } }
RnrLineItem extends LineItem { public void calculatePacksToShip() { Integer orderQuantity = getOrderQuantity(); if (allNotNull(orderQuantity, packSize)) { packsToShip = ((orderQuantity == 0) ? (roundToZero ? 0 : 1) : applyRoundingRules(orderQuantity)); } } }
RnrLineItem extends LineItem { public void calculatePacksToShip() { Integer orderQuantity = getOrderQuantity(); if (allNotNull(orderQuantity, packSize)) { packsToShip = ((orderQuantity == 0) ? (roundToZero ? 0 : 1) : applyRoundingRules(orderQuantity)); } } RnrLineItem(Long rnrId,
                     FacilityTypeApprovedProduct facilityTypeApprovedProduct,
                     Long modifiedBy,
                     Long createdBy); }
RnrLineItem extends LineItem { public void calculatePacksToShip() { Integer orderQuantity = getOrderQuantity(); if (allNotNull(orderQuantity, packSize)) { packsToShip = ((orderQuantity == 0) ? (roundToZero ? 0 : 1) : applyRoundingRules(orderQuantity)); } } 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 calculatePacksToShip() { Integer orderQuantity = getOrderQuantity(); if (allNotNull(orderQuantity, packSize)) { packsToShip = ((orderQuantity == 0) ? (roundToZero ? 0 : 1) : applyRoundingRules(orderQuantity)); } } 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; }