Actual.java

package com.tradecloud.domain.document.invoice;

import com.tradecloud.domain.costing.clean.Costed;
import com.tradecloud.domain.export.ExportCosting;
import org.apache.commons.lang3.NotImplementedException;

import java.math.BigDecimal;

/**
 * Interface that all 'actual' cost classes must support.
 * <p>
 * https://connect.devstream.net/display/Dev/Commercial+Invoice+Line+Items
 *
 * @param <P> The parent type
 * @param <C> The child type
 */
public interface Actual<P extends Costed, C extends Costed> extends Costed<P, C> {

    /**
     * The total value for the actual. This should never be calculated by the actuals themselves. It should be done by the service layer
     * whenever the invoice is changed, and saved to the actual.
     *
     * @return
     */
    BigDecimal getTotalInvoiceValue();

    void setTotalInvoiceValue(BigDecimal totalValue);

    BigDecimal getOrderQuantity();

    void setOrderQuantity(BigDecimal orderQuantity);

    BigDecimal getInvoiceQuantity();

    void setInvoiceQuantity(BigDecimal invoiceQuantity);

    Long getId();

    CostsInvoice getCostsInvoice();

    /**
     * This is a key used when traversing the actual structure. The problem is that a given actual can appear more than one time.
     * eg there can be two actualConsignments 'mapping' to a single consignment, each with different costlines filled in.
     * At the moment they don't keep a reference to the underlying class, so are not easy to match up.
     *
     * @return
     */
    Object getTraversalKey();

    boolean match(Actual actual);

    default ExportCosting getExportCosting() {
        throw new NotImplementedException("please implement");
    }

    default void setExportCosting(ExportCosting exportCosting) {
        throw new NotImplementedException("please implement");
    }
}