This commit is contained in:
seb
2026-10-17 21:40:53 +02:00
parent d1ccbf335c
commit 0d11dd5014
4 changed files with 95 additions and 11 deletions

View File

@@ -77,12 +77,19 @@ function parseNum(value) {
* @returns {DeliveryLine} Normalized line.
*/
export function createEmptyLineitem(line = {}) {
const netRaw = line.netprice ?? line.net ?? line.eknetto ?? line.netPrice ?? null;
let netVal = null;
if (line.netprice != null || line.net != null || line.netPrice != null) {
const netRaw = line.netprice ?? line.net ?? line.netPrice;
netVal = netRaw != null ? (parseNum(netRaw) ?? netRaw) : null;
} else if (line.eknetto != null && line.eknetto !== '') {
const parsedCent = parseNum(line.eknetto);
netVal = parsedCent != null ? Math.round((parsedCent / 100) * 10000) / 10000 : null;
}
const taxRaw = line.taxrate ?? line.tax ?? line.mwst ?? line.taxRate ?? null;
const amountRaw = line.amount ?? line.count ?? line.qty ?? line.quantity ?? null;
const puRaw = line.pu ?? line.vpe ?? null;
const netVal = netRaw != null ? (parseNum(netRaw) ?? netRaw) : null;
const taxVal = taxRaw != null ? (parseNum(taxRaw) ?? taxRaw) : null;
const amountVal = amountRaw != null ? (parseNum(amountRaw) ?? amountRaw) : null;
const puVal = puRaw != null ? (parseNum(puRaw) ?? puRaw) : null;