Fixed FinalInvoice
This commit is contained in:
@@ -99,6 +99,10 @@ const setupData = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const loaded = ref(false)
|
const loaded = ref(false)
|
||||||
|
const normalizeEntityId = (value) => {
|
||||||
|
if (value === null || typeof value === "undefined") return null
|
||||||
|
return typeof value === "object" ? (value.id ?? null) : value
|
||||||
|
}
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
|
|
||||||
await setupData()
|
await setupData()
|
||||||
@@ -138,14 +142,15 @@ const setupPage = async () => {
|
|||||||
|
|
||||||
if (route.query.loadMode === "deliveryNotes") {
|
if (route.query.loadMode === "deliveryNotes") {
|
||||||
let linkedDocuments = (await useEntities("createddocuments").select()).filter(i => JSON.parse(route.query.linkedDocuments).includes(i.id))
|
let linkedDocuments = (await useEntities("createddocuments").select()).filter(i => JSON.parse(route.query.linkedDocuments).includes(i.id))
|
||||||
|
if (linkedDocuments.length === 0) return
|
||||||
|
|
||||||
//TODO: Implement Checking for Same Customer, Contact and Project
|
//TODO: Implement Checking for Same Customer, Contact and Project
|
||||||
|
|
||||||
itemInfo.value.customer = linkedDocuments[0].customer ? linkedDocuments[0].customer.id : null
|
itemInfo.value.customer = normalizeEntityId(linkedDocuments[0].customer)
|
||||||
itemInfo.value.project = linkedDocuments[0].project ? linkedDocuments[0].project.id : null
|
itemInfo.value.project = normalizeEntityId(linkedDocuments[0].project)
|
||||||
itemInfo.value.contact = linkedDocuments[0].contact ? linkedDocuments[0].contact.id : null
|
itemInfo.value.contact = normalizeEntityId(linkedDocuments[0].contact)
|
||||||
|
|
||||||
setCustomerData()
|
await setCustomerData(null, true)
|
||||||
|
|
||||||
let firstDate = null
|
let firstDate = null
|
||||||
let lastDate = null
|
let lastDate = null
|
||||||
@@ -207,21 +212,23 @@ const setupPage = async () => {
|
|||||||
}
|
}
|
||||||
else if (route.query.loadMode === "finalInvoice") {
|
else if (route.query.loadMode === "finalInvoice") {
|
||||||
let linkedDocuments = (await useEntities("createddocuments").select()).filter(i => JSON.parse(route.query.linkedDocuments).includes(i.id))
|
let linkedDocuments = (await useEntities("createddocuments").select()).filter(i => JSON.parse(route.query.linkedDocuments).includes(i.id))
|
||||||
|
if (linkedDocuments.length === 0) return
|
||||||
|
|
||||||
//TODO: Implement Checking for Same Customer, Contact and Project
|
//TODO: Implement Checking for Same Customer, Contact and Project
|
||||||
|
|
||||||
console.log(linkedDocuments)
|
console.log(linkedDocuments)
|
||||||
|
|
||||||
itemInfo.value.customer = linkedDocuments[0].customer
|
itemInfo.value.customer = normalizeEntityId(linkedDocuments[0].customer)
|
||||||
itemInfo.value.project = linkedDocuments[0].project
|
itemInfo.value.project = normalizeEntityId(linkedDocuments[0].project)
|
||||||
itemInfo.value.contact = linkedDocuments[0].contact
|
itemInfo.value.contact = normalizeEntityId(linkedDocuments[0].contact)
|
||||||
|
|
||||||
setCustomerData()
|
await setCustomerData(null, true)
|
||||||
|
|
||||||
for await (const doc of linkedDocuments.filter(i => i.type === "confirmationOrders")) {
|
for await (const doc of linkedDocuments.filter(i => i.type === "confirmationOrders")) {
|
||||||
let linkedDocument = await useEntities("createddocuments").selectSingle(doc.id)
|
let linkedDocument = await useEntities("createddocuments").selectSingle(doc.id)
|
||||||
|
|
||||||
itemInfo.value.rows.push({
|
itemInfo.value.rows.push({
|
||||||
|
id: uuidv4(),
|
||||||
mode: "title",
|
mode: "title",
|
||||||
text: linkedDocument.title,
|
text: linkedDocument.title,
|
||||||
})
|
})
|
||||||
@@ -233,6 +240,7 @@ const setupPage = async () => {
|
|||||||
let linkedDocument = await useEntities("createddocuments").selectSingle(doc.id)
|
let linkedDocument = await useEntities("createddocuments").selectSingle(doc.id)
|
||||||
|
|
||||||
itemInfo.value.rows.push({
|
itemInfo.value.rows.push({
|
||||||
|
id: uuidv4(),
|
||||||
mode: "title",
|
mode: "title",
|
||||||
text: linkedDocument.title,
|
text: linkedDocument.title,
|
||||||
})
|
})
|
||||||
@@ -241,6 +249,7 @@ const setupPage = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
itemInfo.value.rows.push({
|
itemInfo.value.rows.push({
|
||||||
|
id: uuidv4(),
|
||||||
mode: "title",
|
mode: "title",
|
||||||
text: "Abschlagsrechnungen",
|
text: "Abschlagsrechnungen",
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user