I have direction on invoice's item level
Overview
The goal of this update is to enhance the invoice model by introducing money flow directions for invoice items. Each invoice consists of two main parts:
- Invoice Header (
invoiceNature == HEADER)- Contains general invoice details (e.g., sender, recipient, etc.).
- Invoice Items (
invoiceNature == ITEM)- Represents individual invoice lines with monetary values.
- Each item has an
amount, and the total sum of all items forms the invoice total. - A new field
directionis introduced with possible values:- CREDIT
- DEBIT
Flow Direction Calculation
- The overall
flowDirectionof an invoice is determined based on its balance:- If the balance is positive →
flowDirection = INVOICE - If the balance is negative →
flowDirection = CREDIT_NOTE
- If the balance is positive →
- The handling of
flowDirectiondiffers based on invoice origin:- Automatic Invoices:
flowDirectionis dynamically determined during invoice creation. If adding an item makes the balance negative,flowDirectionswitches toCREDIT_NOTE, and vice versa. - Manual Invoices (
invoiceOrigin == MANUAL): The user must selectflowDirection, but validation ensures consistency:- If
flowDirection == CREDIT_NOTEbut the balance is positive, the invoice cannot be booked.
- If
- Automatic Invoices:
Validation Enhancements
- A new validation collection will be added at the invoice header level.
- Upon saving an invoice, validations will be executed and stored.
- If there are validation messages:
- The frontend will display them to the user.
- Booking the invoice will be blocked if validation messages exist.
Additional Considerations
- Currently, negative values are not supported in CFR; this needs to be implemented alongside invoices for accurate results.
- Post-Settlements Invoice Creation was disabled due to incomplete analysis. Implementation should be reviewed and re-enabled if needed.
Updated InvoiceItem Model
class InvoiceItem {
private String id;
private String parentId;
private CatalogValue invoiceNature;
private String organisationId;
private LedgerAccountShort expenseAccount;
// Amounts
private Money amount;
private Money amountWithoutTaxes;
private Money taxesAmount;
private Quantity vatRate;
private Money apportionAmount;
private Money apportionTaxAmount;
private Money premiumBasis;
private Quantity premiumRate;
private Descriptor descriptor;
private String description;
private CatalogValue feeType;
private CatalogValue guaranteeOption;
private CatalogValue eventTrigger;
private TargetObject allocation;
private String unique;
// New field
private AccountingEntryDirection direction;
}