mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-17 10:14:08 +00:00
Fix default template not pre-selected on document create
Read default_invoice_template and default_estimate_template from useUserStore().currentUserSettings instead of relying on a parameter that was never passed from the create views.
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<string, unknown> } }> {
|
||||
const response = await invoiceService.convertToEstimate(data.id)
|
||||
return { data: response }
|
||||
},
|
||||
|
||||
async markAsSent(data: InvoiceStatusPayload): Promise<unknown> {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user