This commit is contained in:
seb
2026-09-25 07:27:37 +02:00
parent b331f8f535
commit a3db1742e7
17 changed files with 2273 additions and 371 deletions

View File

@@ -55,6 +55,8 @@ import { article as articleApi, supplier as supplierApi } from '../api';
* @returns {DeliveryLine} Normalized line.
*/
export function createEmptyLineitem(line = {}) {
const netVal = line.netprice ?? line.net ?? null;
const taxVal = line.taxrate ?? line.tax ?? null;
return {
key: line.key ?? `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
name: line.name ?? null,
@@ -62,8 +64,10 @@ export function createEmptyLineitem(line = {}) {
amount: line.amount ?? null,
pu: line.pu ?? null,
unit: line.unit ?? null,
netprice: line.netprice ?? null,
taxrate: line.taxrate ?? null,
netprice: netVal,
net: netVal,
taxrate: taxVal,
tax: taxVal,
};
}
@@ -357,6 +361,20 @@ export function createDeliveryEditorAutomat(options = {}) {
automat.actions.removeLineitem(payload);
},
/** Clears all lines from the editor. @returns {void} */
clearLineitems() {
automat.setState({
lines: [],
lineitems: [],
supplierArticlesByLineKey: {},
});
},
/** Clears all lines from the editor. @returns {void} */
clearLines() {
automat.actions.clearLineitems();
},
/**
* Loads supplier articles for all current SKUs and rebuilds line matches.
* @param {string|number|null} [targetEntityId] Supplier to query.
@@ -658,6 +676,8 @@ export const {
updateLine,
removeLineitem,
removeLine,
clearLineitems,
clearLines,
fetchSupplierArticles,
fetchSupplierArticleForSku,
unlinkSupplierArticle,