Search in sources :

Example 1 with PricingConditionsId

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();
}
Also used : PricingConditionsId(de.metas.pricing.conditions.PricingConditionsId) PricingConditionsBreakId(de.metas.pricing.conditions.PricingConditionsBreakId) PricingConditionsBreak(de.metas.pricing.conditions.PricingConditionsBreak) AdempiereException(org.adempiere.exceptions.AdempiereException)

Example 2 with PricingConditionsId

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();
}
Also used : PricingConditionsId(de.metas.pricing.conditions.PricingConditionsId) Money(de.metas.money.Money) PricingConditionsBreak(de.metas.pricing.conditions.PricingConditionsBreak)

Aggregations

PricingConditionsBreak (de.metas.pricing.conditions.PricingConditionsBreak)2 PricingConditionsId (de.metas.pricing.conditions.PricingConditionsId)2 Money (de.metas.money.Money)1 PricingConditionsBreakId (de.metas.pricing.conditions.PricingConditionsBreakId)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1