u
This commit is contained in:
@@ -638,6 +638,37 @@ export function createDeliveryEditorAutomat(options = {}) {
|
||||
...initialState,
|
||||
});
|
||||
},
|
||||
|
||||
/** Serializes the delivery into a VFS draft manifest format. @returns {object} */
|
||||
getManifest() {
|
||||
const state = automat.state;
|
||||
const rawLines = state.lines ?? state.lineitems ?? [];
|
||||
const lines = rawLines
|
||||
.filter((l) => Boolean(l && (l.sku || l.name || l.amount != null || l.netprice != null || l.net != null)))
|
||||
.map((l) => ({
|
||||
sku: l.sku || null,
|
||||
name: l.name || null,
|
||||
amount: l.amount != null ? Number(l.amount) : null,
|
||||
pu: l.pu != null ? Number(l.pu) : 1,
|
||||
unit: l.unit || null,
|
||||
netprice: l.netprice != null ? Number(l.netprice) : (l.net != null ? Number(l.net) : null),
|
||||
taxrate: l.taxrate != null ? Number(l.taxrate) : (l.tax != null ? Number(l.tax) : null),
|
||||
}));
|
||||
|
||||
return {
|
||||
manifest: {
|
||||
kind: 'delivery',
|
||||
id: null,
|
||||
date: state.date || null,
|
||||
partyId: state.partyId ?? state.deliveryEntity ?? null,
|
||||
externalNumber: state.externalNumber ?? state.external_number ?? null,
|
||||
lines,
|
||||
items: lines,
|
||||
notes: state.notes ?? [],
|
||||
attachments: (state.attachments ?? []).map((a) => ({ name: a.name, type: a.type })),
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
automat = new Automat(initialState, actions, {
|
||||
|
||||
Reference in New Issue
Block a user