diff --git a/resources/scripts-v2/features/company/estimates/store.ts b/resources/scripts-v2/features/company/estimates/store.ts index d090d425..9f91be9b 100644 --- a/resources/scripts-v2/features/company/estimates/store.ts +++ b/resources/scripts-v2/features/company/estimates/store.ts @@ -1,6 +1,7 @@ import { defineStore } from 'pinia' import { useNotificationStore } from '../../../stores/notification.store' import { useCompanyStore } from '../../../stores/company.store' +import { useUserStore } from '../../../stores/user.store' import { estimateService } from '../../../api/services/estimate.service' import type { EstimateListParams, @@ -545,9 +546,10 @@ export const useEstimateStore = defineStore('estimate', { if (this.templates.length) { this.setTemplate(this.templates[0].name) - if (userSettings?.default_estimate_template) { + const { currentUserSettings } = useUserStore() + if (currentUserSettings.default_estimate_template) { this.newEstimate.template_name = - userSettings.default_estimate_template + currentUserSettings.default_estimate_template } } } diff --git a/resources/scripts-v2/features/company/invoices/store.ts b/resources/scripts-v2/features/company/invoices/store.ts index 2c64daa0..2d1508e6 100644 --- a/resources/scripts-v2/features/company/invoices/store.ts +++ b/resources/scripts-v2/features/company/invoices/store.ts @@ -1,6 +1,7 @@ import { defineStore } from 'pinia' import { useNotificationStore } from '../../../stores/notification.store' import { useCompanyStore } from '../../../stores/company.store' +import { useUserStore } from '../../../stores/user.store' import { invoiceService } from '../../../api/services/invoice.service' import type { InvoiceListParams, @@ -361,6 +362,11 @@ export const useInvoiceStore = defineStore('invoice', { return { data: response } }, + async convertToEstimate(data: { id: number }): Promise<{ data: { data: Record } }> { + const response = await invoiceService.convertToEstimate(data.id) + return { data: response } + }, + async markAsSent(data: InvoiceStatusPayload): Promise { const response = await invoiceService.changeStatus(data) const pos = this.invoices.findIndex((inv) => inv.id === data.id) @@ -528,9 +534,10 @@ export const useInvoiceStore = defineStore('invoice', { if (templatesRes?.data?.invoiceTemplates?.length) { this.setTemplate(this.templates[0].name) - if (userSettings?.default_invoice_template) { + const { currentUserSettings } = useUserStore() + if (currentUserSettings.default_invoice_template) { this.newInvoice.template_name = - userSettings.default_invoice_template + currentUserSettings.default_invoice_template } } }