feat(accounting): edit finalized document cost centres
This commit is contained in:
@@ -1896,6 +1896,31 @@ const saveDocument = async (state, resetup = false) => {
|
||||
if (resetup) await setupPage()
|
||||
}
|
||||
|
||||
const saveFinalizedCostCentres = async () => {
|
||||
const rowCostCentres = itemInfo.value.rows
|
||||
.filter(row => row?.id)
|
||||
.map(row => ({
|
||||
rowId: String(row.id),
|
||||
costcentre: row.costCentre || null,
|
||||
}))
|
||||
|
||||
const result = await $api(`/api/functions/outgoing-documents/${itemInfo.value.id}/cost-centres`, {
|
||||
method: "PUT",
|
||||
body: {
|
||||
costcentre: itemInfo.value.costcentre || null,
|
||||
rowCostCentres,
|
||||
},
|
||||
})
|
||||
|
||||
itemInfo.value.costcentre = result.document.costcentre
|
||||
itemInfo.value.rows = normalizeCreatedDocumentRows(result.document.rows)
|
||||
toast.add({
|
||||
title: "Kostenstellen gespeichert",
|
||||
description: "Die Kostenstellen des fertiggestellten Belegs wurden aktualisiert.",
|
||||
color: "success",
|
||||
})
|
||||
}
|
||||
|
||||
const selectedTab = ref("0")
|
||||
|
||||
const closeDocument = async () => {
|
||||
@@ -2077,7 +2102,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
||||
<UButton
|
||||
icon="i-mdi-content-save"
|
||||
@click="saveDocument('Entwurf',true)"
|
||||
v-if="itemInfo.type !== 'serialInvoices' && !isTemplateMode"
|
||||
v-if="itemInfo.type !== 'serialInvoices' && !isTemplateMode && itemInfo.state === 'Entwurf'"
|
||||
:disabled="!itemInfo.customer"
|
||||
>
|
||||
Speichern
|
||||
@@ -2092,10 +2117,17 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
|
||||
</UButton>
|
||||
<UButton
|
||||
@click="closeDocument"
|
||||
v-if="itemInfo.id && itemInfo.type !== 'serialInvoices' && !isTemplateMode"
|
||||
v-if="itemInfo.id && itemInfo.type !== 'serialInvoices' && !isTemplateMode && itemInfo.state === 'Entwurf'"
|
||||
>
|
||||
{{selectedTab === '0' ? "Vorschau zeigen" : "Fertigstellen"}}
|
||||
</UButton>
|
||||
<UButton
|
||||
icon="i-heroicons-tag"
|
||||
@click="saveFinalizedCostCentres"
|
||||
v-if="itemInfo.id && itemInfo.type !== 'serialInvoices' && !isTemplateMode && itemInfo.state === 'Gebucht'"
|
||||
>
|
||||
Kostenstellen speichern
|
||||
</UButton>
|
||||
<UButton
|
||||
icon="i-mdi-content-save"
|
||||
@click="saveSerialInvoice"
|
||||
|
||||
Reference in New Issue
Block a user