Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af9d672574 | ||
|
|
7606f8ece8 | ||
|
|
9b0498a2e5 | ||
|
|
04c7682e73 | ||
|
|
0f933b6217 | ||
|
|
241ec09220 | ||
|
|
ed7af3fc3c |
@@ -35,7 +35,7 @@
|
||||
"yes": "हां",
|
||||
"no": "नहीं",
|
||||
"sort_by": "इसके अनुसार क्रमबद्ध करें",
|
||||
"ascending": "आरोही",
|
||||
"ascending": "बढ़ते क्रम में",
|
||||
"descending": "उतरते",
|
||||
"subject": "विषय",
|
||||
"body": "बॉडी",
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, reactive } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { deburr } from 'lodash'
|
||||
import { required, maxLength, helpers } from '@vuelidate/validators'
|
||||
import { useVuelidate } from '@vuelidate/core'
|
||||
import { useGlobalStore } from '@/scripts/admin/stores/global'
|
||||
@@ -180,6 +181,7 @@ let logoFileName = ref(null)
|
||||
|
||||
const companyForm = reactive({
|
||||
name: null,
|
||||
slug: null,
|
||||
tax_id: null,
|
||||
vat_id: null,
|
||||
address: {
|
||||
@@ -251,6 +253,18 @@ async function next() {
|
||||
}
|
||||
|
||||
isSaving.value = true
|
||||
|
||||
// Generate slug from company name (imitate Laravel's Str::slug)
|
||||
if (companyForm.name) {
|
||||
companyForm.slug = deburr(companyForm.name) // Remove accents etc.
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/_/g, '-')
|
||||
.replace(/[^a-z0-9\s-]/g, '') // Remove all non-alphanumeric chars
|
||||
.replace(/[\s-]+/g, '-')
|
||||
.replace(/^-+|-+$/g, '') // Trim dashes
|
||||
}
|
||||
|
||||
let res = companyStore.updateCompany(companyForm)
|
||||
if (res) {
|
||||
if (logoFileBlob.value) {
|
||||
|
||||
@@ -139,6 +139,7 @@
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import moment from 'moment'
|
||||
import {
|
||||
required,
|
||||
maxLength,
|
||||
@@ -179,6 +180,9 @@ let router = useRouter()
|
||||
const invoiceValidationScope = 'newInvoice'
|
||||
let isSaving = ref(false)
|
||||
const isMarkAsDefault = ref(false)
|
||||
const dueDateManuallyChanged = ref(false)
|
||||
let isAutoUpdatingDueDate = false
|
||||
let expectedAutoDueDate = ref(null)
|
||||
|
||||
const invoiceNoteFieldList = ref([
|
||||
'customer',
|
||||
@@ -261,6 +265,52 @@ watch(
|
||||
{immediate: true}
|
||||
)
|
||||
|
||||
// Watch for manual changes to due_date
|
||||
watch(() => invoiceStore.newInvoice.due_date, (newDueDate, oldDueDate) => {
|
||||
if (!isAutoUpdatingDueDate && newDueDate !== oldDueDate && oldDueDate !== undefined && newDueDate !== expectedAutoDueDate.value) {
|
||||
dueDateManuallyChanged.value = true
|
||||
}
|
||||
});
|
||||
|
||||
// Watch invoice_date and automatically update due_date when it changes
|
||||
watch(() => invoiceStore.newInvoice.invoice_date, (newInvoiceDate, oldInvoiceDate) => {
|
||||
if (
|
||||
companyStore.selectedCompanySettings?.invoice_set_due_date_automatically === 'YES' &&
|
||||
newInvoiceDate &&
|
||||
newInvoiceDate !== oldInvoiceDate &&
|
||||
oldInvoiceDate !== undefined
|
||||
) {
|
||||
|
||||
const dueDateDays = parseInt(companyStore.selectedCompanySettings.invoice_due_date_days || 0);
|
||||
const invoiceDate = moment(newInvoiceDate)
|
||||
|
||||
if (invoiceDate.isValid()) {
|
||||
const calculatedDueDate = invoiceDate.clone().add(dueDateDays, 'days').format('YYYY-MM-DD')
|
||||
expectedAutoDueDate.value = calculatedDueDate
|
||||
|
||||
|
||||
if (dueDateManuallyChanged.value) {
|
||||
const currentDueDate = invoiceStore.newInvoice.due_date
|
||||
if (currentDueDate) {
|
||||
const dueDateMoment = moment(currentDueDate)
|
||||
if (dueDateMoment.isValid() && dueDateMoment.isSameOrAfter(invoiceDate, 'day')) {
|
||||
return // Manual due date still valid/in the future
|
||||
}
|
||||
}
|
||||
|
||||
// Manual due date is in the past/invalid
|
||||
dueDateManuallyChanged.value = false
|
||||
}
|
||||
|
||||
// Set the calculated due date
|
||||
isAutoUpdatingDueDate = true
|
||||
invoiceStore.newInvoice.due_date = calculatedDueDate
|
||||
isAutoUpdatingDueDate = false
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
async function submitForm() {
|
||||
v$.value.$touch()
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
2.3.1
|
||||
2.3.2
|
||||
|
||||
Reference in New Issue
Block a user