Add support for invoice level discounts on ESCI invoices
Description
At present, OpenVPMS can't receive discounts from suppliers via ESCI as there is no support for discount information on act.supplierDelivery nor act.supplierDeliveryItem.
Discounts are represented in UBL via the AllowanceCharge element; for discounts its ChargeIndicator is set "false". AllowanceCharge elements may be present on both Invoice and InvoiceLine. For simplicity, we will only support AllowanceCharge elements on the Invoice.
New archetypes
This will require the following archetypes:
1. act.supplierDeliveryAllowance - used to represent discounts This includes the following nodes:
supplierAllowanceId - the identifier for the allowance allocated by the supplier
allowanceType - lookup of type "lookup.allowanceCharge"
description - optional description of the allowance
amount - the allowance, ex tax
tax - tax on the allowance
total - the allowance, including tax
2. act.supplierDeliveryCharge - used to represent freight
supplierChargeId - the identifier for the charge allocated by the supplier
chargeType - lookup of type "lookup.allowanceCharge"
description - optional description of the charge
amount - the charge, ex tax
tax - tax on the charge
total - the charge, including tax
3. lookup.allowanceCharge - indicates the type of an allowance/charge. This is used by both allowances and charges in order to support reversals.
4. act.supplierAccountInvoiceCharge - corresponds to an act.supplierDeliveryCharge, used by act.supplierAccountChargesInvoice
5. act.supplierAccountInvoiceAllowance - corresponds to an act.supplierDeliveryAllowance, used by act.supplierAccountChargesInvoice
6. act.supplierAccountCreditCharge - reversal of an act.supplierAccountInvoiceCharge, used by act.supplierAccountChargesCredit
7. act.supplierAccountCreditAllowance - reversal of an act.supplierAccountInvoiceAllowance, used by act.supplierAccountChargesCredit
8. act.supplierReturnCharge - reversal of an act.supplierDeliveryCharge, used by act.supplierReturn
9. act.supplierReturnAllowance - reversal of an act.supplierDeliveryAllowance, used by act.supplierReturn
Archetype changes
The addition of these archetypes requires changes to the following archetypes: 1. act.supplierDelivery
Add "charges" node, linking to zero or more "act.supplierDeliveryCharge" acts
Add "allowances" node, linking to zero or more "act.supplierDeliveryAllowance" acts
2. act.supplierCredit
Add "charges" node, linking to zero or more "act.supplierCreditCharge" acts
Add "allowances" node, linking to zero or more "act.supplierCreditAllowance" acts
3. act.supplierReturn
Add "charges" node, linking to zero or more "act.supplierReturnCharge" acts
Add "allowances" node, linking to zero or more "act.supplierReturnAllowance" acts
4. act.supplierInvoice
Add "charges" node, linking to zero or more "act.supplierInvoiceCharge" acts
Add "allowances" node, linking to zero or more "act.supplierInvoiceAllowance" acts
Code changes
The following classes/methods need to be changed:
OrderRules.invoiceSupplier(). Need to handle allowance and charges
OrderRules.reverseDelivery(). Need to reverse allowances and charges
OrderRules.reverseReturns(). Need to reverse allowances and charges
OrderRules.creditSupplier(). Need to handle allowance and charges
DeliveryEditor
Need to display tabs for charges and allowances
Need to change calculation to handle allowances and charges
SupplierChargeActEditor
Need to display tabs for charges and allowances
Need to change calculation to handle allowances and charges
InvoiceMapperImpl
Change existing mapping of AllowanceCharge with ChargeIndicator=true to act.supplierDeliveryItem to map to act.supplierDeliveryCharge
Add mapping of AllowanceCharge with ChargeIndicator=false to act.supplierDeliveryAllowance
ESCI changes
ESCI integration documentation needs to be updated
ESCI sample Invoice documents need to be provided that demonstrate use of AllowanceCharge
At present, OpenVPMS can't receive discounts from suppliers via ESCI as there is no support for discount information on act.supplierDelivery nor act.supplierDeliveryItem.
Discounts are represented in UBL via the AllowanceCharge element; for discounts its ChargeIndicator is set "false".
AllowanceCharge elements may be present on both Invoice and InvoiceLine.
For simplicity, we will only support AllowanceCharge elements on the Invoice.
New archetypes
This will require the following archetypes:
1. act.supplierDeliveryAllowance - used to represent discounts
This includes the following nodes:
supplierAllowanceId - the identifier for the allowance allocated by the supplier
allowanceType - lookup of type "lookup.allowanceCharge"
description - optional description of the allowance
amount - the allowance, ex tax
tax - tax on the allowance
total - the allowance, including tax
2. act.supplierDeliveryCharge - used to represent freight
supplierChargeId - the identifier for the charge allocated by the supplier
chargeType - lookup of type "lookup.allowanceCharge"
description - optional description of the charge
amount - the charge, ex tax
tax - tax on the charge
total - the charge, including tax
3. lookup.allowanceCharge - indicates the type of an allowance/charge.
This is used by both allowances and charges in order to support reversals.
4. act.supplierAccountInvoiceCharge - corresponds to an act.supplierDeliveryCharge, used by act.supplierAccountChargesInvoice
5. act.supplierAccountInvoiceAllowance - corresponds to an act.supplierDeliveryAllowance, used by act.supplierAccountChargesInvoice
6. act.supplierAccountCreditCharge - reversal of an act.supplierAccountInvoiceCharge, used by act.supplierAccountChargesCredit
7. act.supplierAccountCreditAllowance - reversal of an act.supplierAccountInvoiceAllowance, used by act.supplierAccountChargesCredit
8. act.supplierReturnCharge - reversal of an act.supplierDeliveryCharge, used by act.supplierReturn
9. act.supplierReturnAllowance - reversal of an act.supplierDeliveryAllowance, used by act.supplierReturn
Archetype changes
The addition of these archetypes requires changes to the following archetypes:
1. act.supplierDelivery
Add "charges" node, linking to zero or more "act.supplierDeliveryCharge" acts
Add "allowances" node, linking to zero or more "act.supplierDeliveryAllowance" acts
2. act.supplierCredit
Add "charges" node, linking to zero or more "act.supplierCreditCharge" acts
Add "allowances" node, linking to zero or more "act.supplierCreditAllowance" acts
3. act.supplierReturn
Add "charges" node, linking to zero or more "act.supplierReturnCharge" acts
Add "allowances" node, linking to zero or more "act.supplierReturnAllowance" acts
4. act.supplierInvoice
Add "charges" node, linking to zero or more "act.supplierInvoiceCharge" acts
Add "allowances" node, linking to zero or more "act.supplierInvoiceAllowance" acts
Code changes
The following classes/methods need to be changed:
OrderRules.invoiceSupplier(). Need to handle allowance and charges
OrderRules.reverseDelivery(). Need to reverse allowances and charges
OrderRules.reverseReturns(). Need to reverse allowances and charges
OrderRules.creditSupplier(). Need to handle allowance and charges
DeliveryEditor
Need to display tabs for charges and allowances
Need to change calculation to handle allowances and charges
SupplierChargeActEditor
Need to display tabs for charges and allowances
Need to change calculation to handle allowances and charges
InvoiceMapperImpl
Change existing mapping of AllowanceCharge with ChargeIndicator=true to act.supplierDeliveryItem to map to act.supplierDeliveryCharge
Add mapping of AllowanceCharge with ChargeIndicator=false to act.supplierDeliveryAllowance
ESCI changes
ESCI integration documentation needs to be updated
ESCI sample Invoice documents need to be provided that demonstrate use of AllowanceCharge
Report changes
There are currently no reports for supplier acts.