use of de.metas.pricing.conditions.PricingConditionsId in project metasfresh-webui-api by metasfresh.
the class PricingConditionsView_SaveEditableRow method createPricingConditionsBreakChangeRequest.
private static PricingConditionsBreakChangeRequest createPricingConditionsBreakChangeRequest(final PricingConditionsRow row) {
if (!row.isEditable()) {
throw new AdempiereException("Saving not editable rows is not allowed").setParameter("row", row);
}
final PricingConditionsId pricingConditionsId = row.getPricingConditionsId();
final PricingConditionsBreak pricingConditionsBreak = row.getPricingConditionsBreak();
final PricingConditionsBreakId updateFromPricingConditionsBreakId = row.getCopiedFromPricingConditionsBreakId();
return preparePricingConditionsBreakChangeRequest(pricingConditionsBreak).pricingConditionsId(pricingConditionsId).updateFromPricingConditionsBreakId(updateFromPricingConditionsBreakId).build();
}
use of de.metas.pricing.conditions.PricingConditionsId in project metasfresh-webui-api by metasfresh.
the class PricingConditionsRowsLoader method createEditablePricingConditionsRowOrNull.
/**
* On-the-fly create a PricingConditionsRow using this instance's {@link #sourceDocumentLine}.
*/
private PricingConditionsRow createEditablePricingConditionsRowOrNull() {
if (sourceDocumentLine == null) {
return null;
}
final int discountSchemaId = bpartnerBL.getDiscountSchemaId(sourceDocumentLine.getBpartnerId(), sourceDocumentLine.getSoTrx());
final PricingConditionsId pricingConditionsId = PricingConditionsId.ofRepoIdOrNull(discountSchemaId);
final Money priceEntered = sourceDocumentLine.getPriceEntered();
final PricingConditionsBreak pricingConditionsBreak = PricingConditionsBreak.builder().id(// N/A
null).matchCriteria(PricingConditionsBreakMatchCriteria.builder().breakValue(BigDecimal.ZERO).productId(sourceDocumentLine.getProductId()).productCategoryId(sourceDocumentLine.getProductCategoryId()).build()).priceSpecification(PriceSpecification.fixedPrice(priceEntered)).paymentTermIdOrNull(sourceDocumentLine.getPaymentTermId()).discount(sourceDocumentLine.getDiscount()).dateCreated(// N/A; the PricingConditionsBreak hasn't been created (i.e. persisted on DB) yet
null).createdById(null).build();
return PricingConditionsRow.builder().lookups(lookups).editable(true).bpartner(lookups.lookupBPartner(sourceDocumentLine.getBpartnerId())).customer(sourceDocumentLine.getSoTrx().isSales()).pricingConditionsId(pricingConditionsId).pricingConditionsBreak(pricingConditionsBreak).basePricingSystemPriceCalculator(basePricingSystemPriceCalculator).dateLastInOut(getLastInOutDate(sourceDocumentLine.getBpartnerId(), sourceDocumentLine.getSoTrx(), pricingConditionsBreak)).build();
}
Aggregations