diff --git a/backend/src/routes/resources/main.ts b/backend/src/routes/resources/main.ts index e72036b..419ab42 100644 --- a/backend/src/routes/resources/main.ts +++ b/backend/src/routes/resources/main.ts @@ -239,6 +239,13 @@ function isDateValue(value: any) { } function normalizeCreatedDocumentPayload(payload: Record) { + if (Object.prototype.hasOwnProperty.call(payload, "customSurchargePercentage")) { + const customSurchargePercentage = Number(payload.customSurchargePercentage) + payload.customSurchargePercentage = Number.isFinite(customSurchargePercentage) + ? customSurchargePercentage + : 0 + } + const numberRelationFields = [ "customer", "contact", diff --git a/frontend/pages/createDocument/edit/[[id]].vue b/frontend/pages/createDocument/edit/[[id]].vue index 54aface..85ff571 100644 --- a/frontend/pages/createDocument/edit/[[id]].vue +++ b/frontend/pages/createDocument/edit/[[id]].vue @@ -1701,6 +1701,7 @@ const saveSerialInvoice = async () => { const saveDocument = async (state, resetup = false) => { itemInfo.value.state = state + normalizeCustomSurchargePercentage() if (state !== "Entwurf") { console.log("???") @@ -1870,7 +1871,14 @@ const checkCompatibilityWithInputPrice = () => { }) } +const normalizeCustomSurchargePercentage = () => { + const percentage = Number(itemInfo.value.customSurchargePercentage) + itemInfo.value.customSurchargePercentage = Number.isFinite(percentage) ? percentage : 0 +} + const updateCustomSurcharge = () => { + normalizeCustomSurchargePercentage() + itemInfo.value.rows.forEach(row => { if (!["pagebreak", "title", "text"].includes(row.mode) && isImportedAdvanceInvoiceRow(row)) { row.price = Number(row.inputPrice || 0)