mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-07 13:41:23 +00:00
feat: Tax included (#370)
* feat: Tax included * Added a toggle switch in tax settings to enable the feature. * Database migration adding tax_included field into estimates, invoices and recurring invoices table. * Toggle switch to enable and store the tax_included by estimates, invoices and recurring invoices. * In case of tax included enabled, total taxes will be recalculated and the invoices, estimates and recurring invoices total won't be sum with taxes. * Apply tax included when discount_per_item/tax_per_item item is enabled. * Custom component to show the net total when tax included is enabled. * Update invoice and estimates pdfs with net total. * chore: Tax included by default A switch button inside the tax settings to enable the tax included by default in invoices, estimates and recurring invoices.
This commit is contained in:
71
resources/scripts/admin/stores/estimate.js
vendored
71
resources/scripts/admin/stores/estimate.js
vendored
@@ -44,6 +44,9 @@ export const useEstimateStore = (useWindow = false) => {
|
||||
return a + b['total']
|
||||
}, 0)
|
||||
},
|
||||
getNetTotal() {
|
||||
return this.getSubtotalWithDiscount - this.getTotalTax
|
||||
},
|
||||
getTotalSimpleTax() {
|
||||
return _.sumBy(this.newEstimate.taxes, function (tax) {
|
||||
if (!tax.compound_tax) {
|
||||
@@ -79,6 +82,9 @@ export const useEstimateStore = (useWindow = false) => {
|
||||
},
|
||||
|
||||
getTotal() {
|
||||
if (this.newEstimate.tax_included) {
|
||||
return this.getSubtotalWithDiscount
|
||||
}
|
||||
return this.getSubtotalWithDiscount + this.getTotalTax
|
||||
},
|
||||
|
||||
@@ -149,7 +155,7 @@ export const useEstimateStore = (useWindow = false) => {
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
console.log(err)
|
||||
handleError(err)
|
||||
reject(err)
|
||||
})
|
||||
@@ -160,20 +166,19 @@ export const useEstimateStore = (useWindow = false) => {
|
||||
Object.assign(this.newEstimate, estimate)
|
||||
if (this.newEstimate.tax_per_item === 'YES') {
|
||||
this.newEstimate.items.forEach((_i) => {
|
||||
if (_i.taxes && !_i.taxes.length){
|
||||
if (_i.taxes && !_i.taxes.length) {
|
||||
_i.taxes.push({ ...taxStub, id: Guid.raw() })
|
||||
}
|
||||
})
|
||||
}
|
||||
if (this.newEstimate.discount_per_item === 'YES') {
|
||||
this.newEstimate.items.forEach((_i, index) => {
|
||||
if (_i.discount_type === 'fixed'){
|
||||
if (_i.discount_type === 'fixed') {
|
||||
this.newEstimate.items[index].discount = _i.discount / 100
|
||||
}
|
||||
})
|
||||
}
|
||||
else {
|
||||
if (this.newEstimate.discount_type === 'fixed'){
|
||||
} else {
|
||||
if (this.newEstimate.discount_type === 'fixed') {
|
||||
this.newEstimate.discount = this.newEstimate.discount / 100
|
||||
}
|
||||
}
|
||||
@@ -182,19 +187,23 @@ export const useEstimateStore = (useWindow = false) => {
|
||||
setCustomerAddresses(customer) {
|
||||
const customer_business = customer.customer_business
|
||||
|
||||
if (customer_business?.billing_address){
|
||||
this.newEstimate.customer.billing_address = customer_business.billing_address
|
||||
if (customer_business?.billing_address) {
|
||||
this.newEstimate.customer.billing_address =
|
||||
customer_business.billing_address
|
||||
}
|
||||
|
||||
if (customer_business?.shipping_address){
|
||||
this.newEstimate.customer.shipping_address = customer_business.shipping_address
|
||||
if (customer_business?.shipping_address) {
|
||||
this.newEstimate.customer.shipping_address =
|
||||
customer_business.shipping_address
|
||||
}
|
||||
},
|
||||
|
||||
addSalesTaxUs() {
|
||||
const taxTypeStore = useTaxTypeStore()
|
||||
let salesTax = { ...taxStub }
|
||||
let found = this.newEstimate.taxes.find((_t) => _t.name === 'Sales Tax' && _t.type === 'MODULE')
|
||||
let found = this.newEstimate.taxes.find(
|
||||
(_t) => _t.name === 'Sales Tax' && _t.type === 'MODULE',
|
||||
)
|
||||
if (found) {
|
||||
for (const key in found) {
|
||||
if (Object.prototype.hasOwnProperty.call(salesTax, key)) {
|
||||
@@ -202,10 +211,10 @@ export const useEstimateStore = (useWindow = false) => {
|
||||
}
|
||||
}
|
||||
salesTax.id = found.tax_type_id
|
||||
console.log(salesTax, 'salesTax');
|
||||
console.log(salesTax, 'salesTax')
|
||||
|
||||
taxTypeStore.taxTypes.push(salesTax)
|
||||
console.log(taxTypeStore.taxTypes);
|
||||
console.log(taxTypeStore.taxTypes)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -261,7 +270,7 @@ export const useEstimateStore = (useWindow = false) => {
|
||||
.post(`/api/v1/estimates/delete`, id)
|
||||
.then((response) => {
|
||||
let index = this.estimates.findIndex(
|
||||
(estimate) => estimate.id === id
|
||||
(estimate) => estimate.id === id,
|
||||
)
|
||||
|
||||
this.estimates.splice(index, 1)
|
||||
@@ -288,7 +297,7 @@ export const useEstimateStore = (useWindow = false) => {
|
||||
.then((response) => {
|
||||
this.selectedEstimates.forEach((estimate) => {
|
||||
let index = this.estimates.findIndex(
|
||||
(_est) => _est.id === estimate.id
|
||||
(_est) => _est.id === estimate.id,
|
||||
)
|
||||
this.estimates.splice(index, 1)
|
||||
})
|
||||
@@ -313,7 +322,7 @@ export const useEstimateStore = (useWindow = false) => {
|
||||
.put(`/api/v1/estimates/${data.id}`, data)
|
||||
.then((response) => {
|
||||
let pos = this.estimates.findIndex(
|
||||
(estimate) => estimate.id === response.data.data.id
|
||||
(estimate) => estimate.id === response.data.data.id,
|
||||
)
|
||||
this.estimates[pos] = response.data.data
|
||||
const notificationStore = useNotificationStore()
|
||||
@@ -355,7 +364,7 @@ export const useEstimateStore = (useWindow = false) => {
|
||||
.post(`/api/v1/estimates/${data.id}/status`, data)
|
||||
.then((response) => {
|
||||
let pos = this.estimates.findIndex(
|
||||
(estimate) => estimate.id === data.id
|
||||
(estimate) => estimate.id === data.id,
|
||||
)
|
||||
if (this.estimates[pos]) {
|
||||
this.estimates[pos].status = 'ACCEPTED'
|
||||
@@ -402,7 +411,7 @@ export const useEstimateStore = (useWindow = false) => {
|
||||
.post(`/api/v1/estimates/${data.id}/status`, data)
|
||||
.then((response) => {
|
||||
let pos = this.estimates.findIndex(
|
||||
(estimate) => estimate.id === data.id
|
||||
(estimate) => estimate.id === data.id,
|
||||
)
|
||||
if (this.estimates[pos]) {
|
||||
this.estimates[pos].status = 'SENT'
|
||||
@@ -570,17 +579,26 @@ export const useEstimateStore = (useWindow = false) => {
|
||||
|
||||
if (!isEdit) {
|
||||
await notesStore.fetchNotes()
|
||||
this.newEstimate.notes = notesStore.getDefaultNoteForType('Estimate')?.notes
|
||||
this.newEstimate.notes =
|
||||
notesStore.getDefaultNoteForType('Estimate')?.notes
|
||||
this.newEstimate.tax_per_item =
|
||||
companyStore.selectedCompanySettings.tax_per_item
|
||||
this.newEstimate.sales_tax_type = companyStore.selectedCompanySettings.sales_tax_type
|
||||
this.newEstimate.sales_tax_address_type = companyStore.selectedCompanySettings.sales_tax_address_type
|
||||
this.newEstimate.sales_tax_type =
|
||||
companyStore.selectedCompanySettings.sales_tax_type
|
||||
this.newEstimate.sales_tax_address_type =
|
||||
companyStore.selectedCompanySettings.sales_tax_address_type
|
||||
this.newEstimate.discount_per_item =
|
||||
companyStore.selectedCompanySettings.discount_per_item
|
||||
this.newEstimate.estimate_date = moment().format('YYYY-MM-DD')
|
||||
if (companyStore.selectedCompanySettings.estimate_set_expiry_date_automatically === 'YES') {
|
||||
if (
|
||||
companyStore.selectedCompanySettings
|
||||
.estimate_set_expiry_date_automatically === 'YES'
|
||||
) {
|
||||
this.newEstimate.expiry_date = moment()
|
||||
.add(companyStore.selectedCompanySettings.estimate_expiry_date_days, 'days')
|
||||
.add(
|
||||
companyStore.selectedCompanySettings.estimate_expiry_date_days,
|
||||
'days',
|
||||
)
|
||||
.format('YYYY-MM-DD')
|
||||
}
|
||||
} else {
|
||||
@@ -607,9 +625,10 @@ export const useEstimateStore = (useWindow = false) => {
|
||||
}
|
||||
|
||||
this.setTemplate(this.templates[0].name)
|
||||
this.newEstimate.template_name =
|
||||
userStore.currentUserSettings.default_estimate_template ?
|
||||
userStore.currentUserSettings.default_estimate_template : this.newEstimate.template_name
|
||||
this.newEstimate.template_name = userStore.currentUserSettings
|
||||
.default_estimate_template
|
||||
? userStore.currentUserSettings.default_estimate_template
|
||||
: this.newEstimate.template_name
|
||||
}
|
||||
|
||||
if (isEdit) {
|
||||
|
||||
58
resources/scripts/admin/stores/invoice.js
vendored
58
resources/scripts/admin/stores/invoice.js
vendored
@@ -51,6 +51,10 @@ export const useInvoiceStore = (useWindow = false) => {
|
||||
}, 0)
|
||||
},
|
||||
|
||||
getNetTotal() {
|
||||
return this.getSubtotalWithDiscount - this.getTotalTax
|
||||
},
|
||||
|
||||
getTotalSimpleTax() {
|
||||
return _.sumBy(this.newInvoice.taxes, function (tax) {
|
||||
if (!tax.compound_tax) {
|
||||
@@ -86,6 +90,9 @@ export const useInvoiceStore = (useWindow = false) => {
|
||||
},
|
||||
|
||||
getTotal() {
|
||||
if (this.newInvoice.tax_included) {
|
||||
return this.getSubtotalWithDiscount
|
||||
}
|
||||
return this.getSubtotalWithDiscount + this.getTotalTax
|
||||
},
|
||||
|
||||
@@ -160,8 +167,7 @@ export const useInvoiceStore = (useWindow = false) => {
|
||||
if (_i.discount_type === 'fixed')
|
||||
this.newInvoice.items[index].discount = _i.discount / 100
|
||||
})
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (this.newInvoice.discount_type === 'fixed')
|
||||
this.newInvoice.discount = this.newInvoice.discount / 100
|
||||
}
|
||||
@@ -171,16 +177,20 @@ export const useInvoiceStore = (useWindow = false) => {
|
||||
const customer_business = customer.customer_business
|
||||
|
||||
if (customer_business?.billing_address)
|
||||
this.newInvoice.customer.billing_address = customer_business.billing_address
|
||||
this.newInvoice.customer.billing_address =
|
||||
customer_business.billing_address
|
||||
|
||||
if (customer_business?.shipping_address)
|
||||
this.newInvoice.customer.shipping_address = customer_business.shipping_address
|
||||
this.newInvoice.customer.shipping_address =
|
||||
customer_business.shipping_address
|
||||
},
|
||||
|
||||
addSalesTaxUs() {
|
||||
const taxTypeStore = useTaxTypeStore()
|
||||
let salesTax = { ...taxStub }
|
||||
let found = this.newInvoice.taxes.find((_t) => _t.name === 'Sales Tax' && _t.type === 'MODULE')
|
||||
let found = this.newInvoice.taxes.find(
|
||||
(_t) => _t.name === 'Sales Tax' && _t.type === 'MODULE',
|
||||
)
|
||||
if (found) {
|
||||
for (const key in found) {
|
||||
if (Object.prototype.hasOwnProperty.call(salesTax, key)) {
|
||||
@@ -237,7 +247,7 @@ export const useInvoiceStore = (useWindow = false) => {
|
||||
.post(`/api/v1/invoices/delete`, id)
|
||||
.then((response) => {
|
||||
let index = this.invoices.findIndex(
|
||||
(invoice) => invoice.id === id
|
||||
(invoice) => invoice.id === id,
|
||||
)
|
||||
this.invoices.splice(index, 1)
|
||||
|
||||
@@ -261,7 +271,7 @@ export const useInvoiceStore = (useWindow = false) => {
|
||||
.then((response) => {
|
||||
this.selectedInvoices.forEach((invoice) => {
|
||||
let index = this.invoices.findIndex(
|
||||
(_inv) => _inv.id === invoice.id
|
||||
(_inv) => _inv.id === invoice.id,
|
||||
)
|
||||
this.invoices.splice(index, 1)
|
||||
})
|
||||
@@ -286,7 +296,7 @@ export const useInvoiceStore = (useWindow = false) => {
|
||||
.put(`/api/v1/invoices/${data.id}`, data)
|
||||
.then((response) => {
|
||||
let pos = this.invoices.findIndex(
|
||||
(invoice) => invoice.id === response.data.data.id
|
||||
(invoice) => invoice.id === response.data.data.id,
|
||||
)
|
||||
this.invoices[pos] = response.data.data
|
||||
|
||||
@@ -328,7 +338,7 @@ export const useInvoiceStore = (useWindow = false) => {
|
||||
.post(`/api/v1/invoices/${data.id}/status`, data)
|
||||
.then((response) => {
|
||||
let pos = this.invoices.findIndex(
|
||||
(invoices) => invoices.id === data.id
|
||||
(invoices) => invoices.id === data.id,
|
||||
)
|
||||
|
||||
if (this.invoices[pos]) {
|
||||
@@ -493,26 +503,35 @@ export const useInvoiceStore = (useWindow = false) => {
|
||||
}
|
||||
|
||||
let editActions = []
|
||||
|
||||
|
||||
if (!isEdit) {
|
||||
await notesStore.fetchNotes()
|
||||
this.newInvoice.notes = notesStore.getDefaultNoteForType('Invoice')?.notes
|
||||
this.newInvoice.notes =
|
||||
notesStore.getDefaultNoteForType('Invoice')?.notes
|
||||
this.newInvoice.tax_per_item =
|
||||
companyStore.selectedCompanySettings.tax_per_item
|
||||
this.newInvoice.sales_tax_type = companyStore.selectedCompanySettings.sales_tax_type
|
||||
this.newInvoice.sales_tax_address_type = companyStore.selectedCompanySettings.sales_tax_address_type
|
||||
this.newInvoice.sales_tax_type =
|
||||
companyStore.selectedCompanySettings.sales_tax_type
|
||||
this.newInvoice.sales_tax_address_type =
|
||||
companyStore.selectedCompanySettings.sales_tax_address_type
|
||||
this.newInvoice.discount_per_item =
|
||||
companyStore.selectedCompanySettings.discount_per_item
|
||||
|
||||
let dateFormat = 'YYYY-MM-DD';
|
||||
let dateFormat = 'YYYY-MM-DD'
|
||||
if (companyStore.selectedCompanySettings.invoice_use_time === 'YES') {
|
||||
dateFormat += ' HH:mm'
|
||||
}
|
||||
|
||||
this.newInvoice.invoice_date = moment().format(dateFormat)
|
||||
if (companyStore.selectedCompanySettings.invoice_set_due_date_automatically === 'YES') {
|
||||
if (
|
||||
companyStore.selectedCompanySettings
|
||||
.invoice_set_due_date_automatically === 'YES'
|
||||
) {
|
||||
this.newInvoice.due_date = moment()
|
||||
.add(companyStore.selectedCompanySettings.invoice_due_date_days, 'days')
|
||||
.add(
|
||||
companyStore.selectedCompanySettings.invoice_due_date_days,
|
||||
'days',
|
||||
)
|
||||
.format('YYYY-MM-DD')
|
||||
}
|
||||
} else {
|
||||
@@ -539,9 +558,10 @@ export const useInvoiceStore = (useWindow = false) => {
|
||||
|
||||
if (res3.data) {
|
||||
this.setTemplate(this.templates[0].name)
|
||||
this.newInvoice.template_name =
|
||||
userStore.currentUserSettings.default_invoice_template ?
|
||||
userStore.currentUserSettings.default_invoice_template : this.newInvoice.template_name
|
||||
this.newInvoice.template_name = userStore.currentUserSettings
|
||||
.default_invoice_template
|
||||
? userStore.currentUserSettings.default_invoice_template
|
||||
: this.newInvoice.template_name
|
||||
}
|
||||
}
|
||||
if (isEdit) {
|
||||
|
||||
108
resources/scripts/admin/stores/recurring-invoice.js
vendored
108
resources/scripts/admin/stores/recurring-invoice.js
vendored
@@ -37,17 +37,56 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
|
||||
},
|
||||
|
||||
frequencies: [
|
||||
{ label: global.t('recurring_invoices.frequency.every_minute'), value: '* * * * *' },
|
||||
{ label: global.t('recurring_invoices.frequency.every_30_minute'), value: '*/30 * * * *' },
|
||||
{ label: global.t('recurring_invoices.frequency.every_hour'), value: '0 * * * *' },
|
||||
{ label: global.t('recurring_invoices.frequency.every_2_hour'), value: '0 */2 * * *' },
|
||||
{ label: global.t('recurring_invoices.frequency.every_day_at_midnight'), value: '0 0 * * *' },
|
||||
{ label: global.t('recurring_invoices.frequency.every_week'), value: '0 0 * * 0' },
|
||||
{ label: global.t('recurring_invoices.frequency.every_15_days_at_midnight'), value: '0 5 */15 * *' },
|
||||
{ label: global.t('recurring_invoices.frequency.on_the_first_day_of_every_month_at_midnight'), value: '0 0 1 * *' },
|
||||
{ label: global.t('recurring_invoices.frequency.every_6_month'), value: '0 0 1 */6 *' },
|
||||
{ label: global.t('recurring_invoices.frequency.every_year_on_the_first_day_of_january_at_midnight'), value: '0 0 1 1 *' },
|
||||
{ label: global.t('recurring_invoices.frequency.custom'), value: 'CUSTOM' },
|
||||
{
|
||||
label: global.t('recurring_invoices.frequency.every_minute'),
|
||||
value: '* * * * *',
|
||||
},
|
||||
{
|
||||
label: global.t('recurring_invoices.frequency.every_30_minute'),
|
||||
value: '*/30 * * * *',
|
||||
},
|
||||
{
|
||||
label: global.t('recurring_invoices.frequency.every_hour'),
|
||||
value: '0 * * * *',
|
||||
},
|
||||
{
|
||||
label: global.t('recurring_invoices.frequency.every_2_hour'),
|
||||
value: '0 */2 * * *',
|
||||
},
|
||||
{
|
||||
label: global.t('recurring_invoices.frequency.every_day_at_midnight'),
|
||||
value: '0 0 * * *',
|
||||
},
|
||||
{
|
||||
label: global.t('recurring_invoices.frequency.every_week'),
|
||||
value: '0 0 * * 0',
|
||||
},
|
||||
{
|
||||
label: global.t(
|
||||
'recurring_invoices.frequency.every_15_days_at_midnight',
|
||||
),
|
||||
value: '0 5 */15 * *',
|
||||
},
|
||||
{
|
||||
label: global.t(
|
||||
'recurring_invoices.frequency.on_the_first_day_of_every_month_at_midnight',
|
||||
),
|
||||
value: '0 0 1 * *',
|
||||
},
|
||||
{
|
||||
label: global.t('recurring_invoices.frequency.every_6_month'),
|
||||
value: '0 0 1 */6 *',
|
||||
},
|
||||
{
|
||||
label: global.t(
|
||||
'recurring_invoices.frequency.every_year_on_the_first_day_of_january_at_midnight',
|
||||
),
|
||||
value: '0 0 1 1 *',
|
||||
},
|
||||
{
|
||||
label: global.t('recurring_invoices.frequency.custom'),
|
||||
value: 'CUSTOM',
|
||||
},
|
||||
],
|
||||
}),
|
||||
|
||||
@@ -60,6 +99,10 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
|
||||
)
|
||||
},
|
||||
|
||||
getNetTotal() {
|
||||
return this.getSubtotalWithDiscount - this.getTotalTax
|
||||
},
|
||||
|
||||
getTotalSimpleTax() {
|
||||
return _.sumBy(this.newRecurringInvoice.taxes, function (tax) {
|
||||
if (!tax.compound_tax) {
|
||||
@@ -95,6 +138,9 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
|
||||
},
|
||||
|
||||
getTotal() {
|
||||
if (this.newRecurringInvoice.tax_included) {
|
||||
return this.getSubtotalWithDiscount
|
||||
}
|
||||
return this.getSubtotalWithDiscount + this.getTotalTax
|
||||
},
|
||||
},
|
||||
@@ -174,7 +220,7 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
|
||||
})
|
||||
|
||||
let pos = this.recurringInvoices.findIndex(
|
||||
(invoice) => invoice.id === response.data.data.id
|
||||
(invoice) => invoice.id === response.data.data.id,
|
||||
)
|
||||
|
||||
this.recurringInvoices[pos] = response.data.data
|
||||
@@ -240,7 +286,7 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
|
||||
.post(`/api/v1/recurring-invoices/delete`, id)
|
||||
.then((response) => {
|
||||
let index = this.recurringInvoices.findIndex(
|
||||
(invoice) => invoice.id === id
|
||||
(invoice) => invoice.id === id,
|
||||
)
|
||||
this.recurringInvoices.splice(index, 1)
|
||||
resolve(response)
|
||||
@@ -265,7 +311,7 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
|
||||
.then((response) => {
|
||||
this.selectedRecurringInvoices.forEach((invoice) => {
|
||||
let index = this.recurringInvoices.findIndex(
|
||||
(_inv) => _inv.id === invoice.id
|
||||
(_inv) => _inv.id === invoice.id,
|
||||
)
|
||||
this.recurringInvoices.splice(index, 1)
|
||||
})
|
||||
@@ -305,7 +351,7 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
|
||||
this.selectAllField = false
|
||||
} else {
|
||||
let allInvoiceIds = this.recurringInvoices.map(
|
||||
(invoice) => invoice.id
|
||||
(invoice) => invoice.id,
|
||||
)
|
||||
this.selectedRecurringInvoices = allInvoiceIds
|
||||
this.selectAllField = true
|
||||
@@ -351,13 +397,16 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
|
||||
// on create
|
||||
if (!isEdit) {
|
||||
await notesStore.fetchNotes()
|
||||
this.newRecurringInvoice.notes = notesStore.getDefaultNoteForType('Invoice')?.notes
|
||||
this.newRecurringInvoice.notes =
|
||||
notesStore.getDefaultNoteForType('Invoice')?.notes
|
||||
this.newRecurringInvoice.tax_per_item =
|
||||
companyStore.selectedCompanySettings.tax_per_item
|
||||
this.newRecurringInvoice.discount_per_item =
|
||||
companyStore.selectedCompanySettings.discount_per_item
|
||||
this.newRecurringInvoice.sales_tax_type = companyStore.selectedCompanySettings.sales_tax_type
|
||||
this.newRecurringInvoice.sales_tax_address_type = companyStore.selectedCompanySettings.sales_tax_address_type
|
||||
this.newRecurringInvoice.sales_tax_type =
|
||||
companyStore.selectedCompanySettings.sales_tax_type
|
||||
this.newRecurringInvoice.sales_tax_address_type =
|
||||
companyStore.selectedCompanySettings.sales_tax_address_type
|
||||
this.newRecurringInvoice.starts_at = moment().format('YYYY-MM-DD')
|
||||
this.newRecurringInvoice.next_invoice_date = moment()
|
||||
.add(7, 'days')
|
||||
@@ -399,7 +448,7 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
|
||||
this.isFetchingInitialSettings = false
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
console.log(err)
|
||||
handleError(err)
|
||||
})
|
||||
},
|
||||
@@ -407,7 +456,9 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
|
||||
addSalesTaxUs() {
|
||||
const taxTypeStore = useTaxTypeStore()
|
||||
let salesTax = { ...TaxStub }
|
||||
let found = this.newRecurringInvoice.taxes.find((_t) => _t.name === 'Sales Tax' && _t.type === 'MODULE')
|
||||
let found = this.newRecurringInvoice.taxes.find(
|
||||
(_t) => _t.name === 'Sales Tax' && _t.type === 'MODULE',
|
||||
)
|
||||
if (found) {
|
||||
for (const key in found) {
|
||||
if (Object.prototype.hasOwnProperty.call(salesTax, key)) {
|
||||
@@ -424,14 +475,15 @@ export const useRecurringInvoiceStore = (useWindow = false) => {
|
||||
},
|
||||
|
||||
setSelectedFrequency() {
|
||||
let data = this.frequencies.find(
|
||||
(frequency) => {
|
||||
return frequency.value === this.newRecurringInvoice.frequency
|
||||
}
|
||||
)
|
||||
data ? this.newRecurringInvoice.selectedFrequency = data
|
||||
: this.newRecurringInvoice.selectedFrequency = { label: 'Custom', value: 'CUSTOM' }
|
||||
|
||||
let data = this.frequencies.find((frequency) => {
|
||||
return frequency.value === this.newRecurringInvoice.frequency
|
||||
})
|
||||
data
|
||||
? (this.newRecurringInvoice.selectedFrequency = data)
|
||||
: (this.newRecurringInvoice.selectedFrequency = {
|
||||
label: 'Custom',
|
||||
value: 'CUSTOM',
|
||||
})
|
||||
},
|
||||
|
||||
resetSelectedNote() {
|
||||
|
||||
Reference in New Issue
Block a user