u
This commit is contained in:
@@ -107,12 +107,13 @@ export function lineFromApi(row) {
|
||||
const taxVal = row.taxrate != null ? String(row.taxrate) : row.tax != null ? String(row.tax) : '';
|
||||
const netNum = parseNum(netVal);
|
||||
const taxNum = parseNum(taxVal);
|
||||
const rebateNum = parseNum(row.rebate) ?? 0;
|
||||
let grossVal = '';
|
||||
if (row.gross != null && row.gross !== '') {
|
||||
grossVal = String(row.gross);
|
||||
} else if (netNum != null) {
|
||||
const rate = taxNum ?? 0;
|
||||
const g = Math.round((netNum * (1 + rate / 100) + Number.EPSILON) * 100) / 100;
|
||||
const g = Math.round((netNum * (1 + rate / 100) * (1 - rebateNum / 100) + Number.EPSILON) * 100) / 100;
|
||||
grossVal = String(g);
|
||||
}
|
||||
return {
|
||||
@@ -175,10 +176,10 @@ export function buildLines(lines, { requireAtLeastOne }) {
|
||||
const tax = parseNum(rawTax);
|
||||
const rawGross = getFirstVal(line.gross);
|
||||
const gross = parseNum(rawGross);
|
||||
if (net == null && gross != null && tax != null) {
|
||||
net = netFromGross(gross, tax);
|
||||
}
|
||||
const rebate = parseNum(getFirstVal(line.rebate));
|
||||
if (net == null && gross != null && tax != null) {
|
||||
net = netFromGross(gross, tax, rebate ?? 0);
|
||||
}
|
||||
const rawPu = getFirstVal(line.pu, line.vpe);
|
||||
const pu = parseNum(rawPu);
|
||||
const blank = !sku && !name && net == null && gross == null;
|
||||
|
||||
Reference in New Issue
Block a user