mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 09:30:59 +00:00
eims integration master test complete
This commit is contained in:
@@ -183,6 +183,12 @@ export interface EimsLineTax {
|
||||
code: string;
|
||||
ratePercent: number;
|
||||
exciseTaxValue: number;
|
||||
/**
|
||||
* Line-level `Discount`. Its effect on `TotalLineAmount` has never been observed live (every
|
||||
* prior test ran it at 0), so the total below still sums PreTax + Tax + Excise only — do not
|
||||
* start subtracting this without a confirmed MoR example.
|
||||
*/
|
||||
discount: number;
|
||||
}
|
||||
|
||||
export interface EimsMapperContext {
|
||||
@@ -336,7 +342,13 @@ export function toEimsInvoice(
|
||||
const ItemList: EimsInvoiceItem[] = invoice.lines.map((line, index) => {
|
||||
const lineNumber = index + 1;
|
||||
const tax = context.taxForLine(line, lineNumber);
|
||||
if (!tax || !tax.code || !Number.isFinite(tax.ratePercent) || !Number.isFinite(tax.exciseTaxValue)) {
|
||||
if (
|
||||
!tax ||
|
||||
!tax.code ||
|
||||
!Number.isFinite(tax.ratePercent) ||
|
||||
!Number.isFinite(tax.exciseTaxValue) ||
|
||||
!Number.isFinite(tax.discount)
|
||||
) {
|
||||
throw new Error(
|
||||
`EIMS mapping: unresolved tax treatment for line ${lineNumber} (${line.chargeType}) ` +
|
||||
`on invoice ${invoice.invoiceNumber}`,
|
||||
@@ -349,7 +361,7 @@ export function toEimsInvoice(
|
||||
const unit = typeof line.metadata?.unit === "string" ? line.metadata.unit : context.unitDefault;
|
||||
|
||||
return {
|
||||
Discount: 0,
|
||||
Discount: round2(tax.discount),
|
||||
ExciseTaxValue,
|
||||
HarmonizationCode: null,
|
||||
NatureOfSupplies: natureOfSupplies,
|
||||
|
||||
Reference in New Issue
Block a user