This commit is contained in:
seb
2026-10-21 03:22:35 +02:00
parent b09100b13e
commit fbf107843f
9 changed files with 448 additions and 172 deletions

View File

@@ -136,6 +136,7 @@ export function emptyLine() {
pu: '1',
unit: '',
netprice: '',
shippable: true,
};
}
@@ -167,6 +168,7 @@ export function lineFromApi(row) {
unit: row.unit ?? '',
netprice: netVal,
taxrate: taxVal,
shippable: row.shippable !== undefined ? Boolean(row.shippable) : true,
};
}
@@ -197,7 +199,7 @@ export function hasArticleLines(lines) {
}
/** Build create/update line array. Throws Error on client validation. */
export function buildLines(lines, { requireAtLeastOne }) {
export function buildLines(lines, { requireAtLeastOne, kind } = {}) {
const outLines = [];
const errors = [];
@@ -255,6 +257,9 @@ export function buildLines(lines, { requireAtLeastOne }) {
if (name) row.name = name;
if (rebate != null) row.rebate = rebate;
if (pu != null) row.pu = pu;
if (kind !== 'delivery') {
row.shippable = line.shippable !== undefined ? Boolean(line.shippable) : true;
}
outLines.push(row);
}
@@ -503,7 +508,7 @@ export async function buildManifestBody(
date,
};
if (shouldIncludeLines) {
body.lines = buildLines(form.lines, { requireAtLeastOne: shouldRequireLine });
body.lines = buildLines(form.lines, { requireAtLeastOne: shouldRequireLine, kind: 'delivery' });
}
} else {
let number = String(form.number ?? '').trim();
@@ -516,7 +521,7 @@ export async function buildManifestBody(
date,
};
if (shouldIncludeLines) {
body.lines = buildLines(form.lines, { requireAtLeastOne: shouldRequireLine });
body.lines = buildLines(form.lines, { requireAtLeastOne: shouldRequireLine, kind });
}
if (useExternalNumber || form.externalNumber != null) {
body.externalNumber = externalNumber || null;
@@ -564,13 +569,24 @@ export const LINE_COLUMNS = [
{ id: 'gross', label: 'Brutto', width: 95, align: 'right', type: 'number' },
];
export const QUOTE_LINE_COLUMNS = LINE_COLUMNS;
export const QUOTE_LINE_COLUMNS = [
{ id: 'pos', label: 'Pos', width: 44, align: 'center' },
{ id: 'amount', label: 'Anzahl', width: 80, align: 'right', type: 'number' },
{ id: 'sku', label: 'ArtNr', width: 130, align: 'left', type: 'text' },
{ id: 'name', label: 'Name', width: 200, align: 'left', type: 'text' },
{ id: 'shippable', label: 'Lieferbar', width: 68, align: 'center', type: 'boolean' },
{ id: 'tax', label: 'MwSt', width: 70, align: 'right', type: 'number' },
{ id: 'rebate', label: 'Rabatt', width: 75, align: 'right', type: 'number' },
{ id: 'net', label: 'Netto', width: 95, align: 'right', type: 'number' },
{ id: 'gross', label: 'Brutto', width: 95, align: 'right', type: 'number' },
];
export const ORDER_LINE_COLUMNS = [
{ id: 'pos', label: 'Pos', width: 44, align: 'center' },
{ id: 'sku', label: 'ArtNr', width: 130, align: 'left', type: 'text' },
{ id: 'name', label: 'Name', width: 200, align: 'left', type: 'text' },
{ id: 'amount', label: 'Anzahl', width: 80, align: 'right', type: 'number' },
{ id: 'shippable', label: 'Lieferbar', width: 68, align: 'center', type: 'boolean' },
{ id: 'tax', label: 'MwSt', width: 70, align: 'right', type: 'number' },
{ id: 'rebate', label: 'Rabatt', width: 75, align: 'right', type: 'number' },
{ id: 'net', label: 'Netto', width: 95, align: 'right', type: 'number' },
@@ -710,7 +726,7 @@ export function manifestConfig(cfgOrKind) {
listAutomat: quoteAutomat,
partiesByIdFromList: (parties) =>
Object.fromEntries(parties.map((row) => [row.id, row])),
columns: LINE_COLUMNS,
columns: QUOTE_LINE_COLUMNS,
};
}
if (kind === 'order') {