This commit is contained in:
Florian Federspiel
2023-11-25 16:53:52 +01:00
commit 677030f712
685 changed files with 148719 additions and 0 deletions

236
spaces/store/data.ts Normal file
View File

@@ -0,0 +1,236 @@
import {defineStore} from 'pinia'
import {CustomerInfo, ProjectInfo, VendorInvoice, ProductInfo} from "@/misc/interfaces";
export const useDataStore = defineStore('dataStore', {
state: () => {
return {
customers: [
{
id: 10069,
name: "NOA Service GmbH",
addresses: [
{
type: "invoice",
street: "Oldenburger Str. ",
number: "52",
zip: 26340,
city: "Zetel"
}
],
contacts: [
{
name: "Noa",
firstname: "Stefanie",
role: "Geschäftsführerin",
email: ""
}, {
name: "Kramer",
firstname: "Lena",
role: "",
email: ""
}
]
},
{
id: 10083,
name: "Specht Reepsholt e.K.",
addresses: [
{
type: "invoice",
street: "Reepsholter Hauptstr. ",
number: "17",
zip: 26446,
city: "Reepsholt"
}
],
contacts: [
{
name: "Specht",
firstname: "Oliver",
role: "",
email: ""
}
]
},
{
id: 10023,
name: "M&K Nordsonne GmbH & Co. KG",
addresses: [
{
type: "invoice",
street: "Berghamm",
number: "1",
zip: 26434,
city: "Wangerland"
}
],
contacts: [
{
name: "Mick",
firstname: "Martin",
role: "Geschäftsführer",
email: ""
}, {
name: "Obst",
firstname: "Yvonne",
role: "",
email: ""
}
]
}
] as CustomerInfo[],
projects: [
{
id: 1001,
name: "FRIOS052PV001",
customerId: 10069,
notes: ""
},
{
id: 1002,
name: "WTMRH017PV001",
customerId: 10083,
notes: ""
},
{
id: 1003,
name: "Kamerainstallation WHVAS19",
customerId: 10069,
notes: ""
}
] as ProjectInfo[],
vendorInvoices: [
{
id: 230001,
vendorId: 10001,
date: "2023-11-01",
reference: "2023-11-01-1000",
lineItems: [
{
pos: 0,
text: "Ja Solar",
projectId: 1001,
quantity: 10,
unit: "Stk",
unitPriceNet: 120.50,
vat: 19,
skrAccountId: 3400
}
]
},
{
id: 230002,
vendorId: 10001,
date: "2023-10-29",
reference: "2023-11-01-1001",
lineItems: [
{
pos: 0,
productId: 10003,
projectId: 1003,
quantity: 3,
unit: "Stk",
unitPriceNet: 96.00,
vat: 19,
skrAccountId: 3400
}
]
}
] as VendorInvoice[],
products: [
{
id:10001,
name: "STP-10SE",
manufacturer: "SMA",
purchasePriceNet: 1500.00,
profitPercentage: 20,
retailPriceNet: 1800.00,
tags: ["pv","wechselrichter"]
},
{
id:10002,
name: "RLC-810A",
manufacturer: "Reolink",
purchasePriceNet: 80.00,
profitPercentage: 20,
retailPriceNet: 96.00,
tags: ["kamera","outdoor","lan","poe"],
optionalProductIds: [10003]
},
{
id:10003,
name: "RLC-510WA",
manufacturer: "Reolink",
purchasePriceNet: 80.00,
profitPercentage: 20,
retailPriceNet: 96.00,
tags: ["kamera","outdoor","wlan"],
optionalProductIds: [10002]
}
] as ProductInfo[],
}
},
actions: {
async getData(){
const {data} = await useFetch("/api/customers")
console.log(data)
// @ts-ignore
this.customers = data
},
addCustomer(value: CustomerInfo) {
this.customers.push(value)
},
addProject(value: ProjectInfo){
this.projects.push(value)
}
},
getters: {
customerList(state){
return state.customers
},
customersForSelect(state){
return state.customers.map((customer:any) => {return {label: customer.name, value: customer.id}})
},
getCustomerById: (state) => (id:number) => state.customers.find((customer:any) => customer.id === id),
projectList(state){
return state.projects
},
getVendorInvoiceList: (state) => state.vendorInvoices,
getVendorInvoicesByProjectId: (state) => (id:number) => {
let invoices:any[] = []
state.vendorInvoices.forEach((invoice:any) => {
//Store Current Invoice Data
let temp:any = {
vendorInvoiceId: 0,
value: 0
}
//Check if Current Invoice Contains Relevant Data
if(invoice.lineItems.filter((lineItem:any) => lineItem.projectId === id).length > 0) {
console.log("in if")
temp.vendorInvoiceId = invoice.id
invoice.lineItems.filter((lineItem:any) => lineItem.projectId === id).forEach((lineItem:any) => {
console.log(temp)
temp.value = Number(temp.value) + lineItem.quantity * lineItem.unitPriceNet
console.log(lineItem)
})
temp.value = String(temp.value.toFixed(2)) + "€"
invoices.push(temp)
}
})
return invoices
},
getProductsList: (state) => state.products
}
})