From dd89a707898fda48fff202e1de703fd8aae266f5 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Tue, 3 Jun 2025 16:35:10 +0200 Subject: [PATCH] Corrected Markup Calc in Products --- stores/data.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/stores/data.js b/stores/data.js index f4589f8..295f516 100644 --- a/stores/data.js +++ b/stores/data.js @@ -471,10 +471,16 @@ export const useDataStore = defineStore('data', () => { key: "salutation", label: "Anrede", inputType: "text", + inputChangeFunction: function (row) { + row.fullName = `${row.firstName} ${row.lastName}` + } },{ key: "title", label: "Titel", inputType: "text", + inputChangeFunction: function (row) { + row.fullName = `${row.firstName} ${row.lastName}` + } },{ key: "firstName", label: "Vorname", @@ -505,6 +511,8 @@ export const useDataStore = defineStore('data', () => { selectDataType: "customers", selectOptionAttribute: "name", selectSearchAttributes: ['name'], + secondInfo: true, + secondInfoKey: "name" }, { key: "vendor", @@ -514,6 +522,8 @@ export const useDataStore = defineStore('data', () => { selectDataType: "vendors", selectOptionAttribute: "name", selectSearchAttributes: ['name'], + secondInfo: true, + secondInfoKey: "name" }, { key: "role", @@ -906,9 +916,9 @@ export const useDataStore = defineStore('data', () => { inputTrailing: "EUR", inputChangeFunction: function (row) { if(row.markupPercentage) { - row.sellingPrice = row.purchasePrice * (1+row.markupPercentage/100); + row.sellingPrice = (row.purchasePrice * (1+row.markupPercentage/100)).toFixed(4) } else { - row.sellingPrice = row.purchasePrice; + row.sellingPrice = row.purchasePrice.toFixed(4) } } },{ @@ -917,8 +927,12 @@ export const useDataStore = defineStore('data', () => { inputType: "number", inputTrailing: "%", inputChangeFunction: function (row) { - if(row.sellingPrice) { - row.sellingPrice = row.purchasePrice * (1+row.markupPercentage/100); + if(row.purchasePrice && ! row.sellingPrice) { + row.sellingPrice = (row.purchasePrice * (1+row.markupPercentage/100)).toFixed(4) + } else if(row.sellingPrice && !row.purchasePrice) { + row.purchasePrice = (row.sellingPrice / (1+row.markupPercentage/100)).toFixed(4) + } else { + row.sellingPrice = (row.purchasePrice * (1+row.markupPercentage/100)).toFixed(4) } } },{ @@ -929,8 +943,10 @@ export const useDataStore = defineStore('data', () => { inputType: "number", inputTrailing: "EUR", inputChangeFunction: function (row) { - if(row.markupPercentage) { - row.purchasePrice = (row.sellingPrice / (1+row.markupPercentage/100)).toFixed(4); + if(row.purchasePrice ) { + row.markupPercentage = ((row.sellingPrice / row.purchasePrice - 1) * 100 ).toFixed(2) + } else{ + row.purchasePrice = (row.sellingPrice / (1+row.markupPercentage/100)).toFixed(4) } } },{