mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-29 20:51:09 -04:00
Add invoice/estimate/payment number length setting (#425)
* Add invoice/estimate/payment number length setting
This commit is contained in:
@ -14,6 +14,19 @@
|
||||
/>
|
||||
</sw-input-group>
|
||||
|
||||
<sw-input-group
|
||||
:label="$t('settings.customization.invoices.invoice_number_length')"
|
||||
:error="invoicenumberLengthError"
|
||||
class="mt-6 mb-4"
|
||||
>
|
||||
<sw-input
|
||||
v-model="invoices.invoice_number_length"
|
||||
:invalid="$v.invoices.invoice_number_length.$error"
|
||||
type="number"
|
||||
style="max-width: 60px"
|
||||
/>
|
||||
</sw-input-group>
|
||||
|
||||
<sw-input-group
|
||||
:label="
|
||||
$t('settings.customization.invoices.default_invoice_email_body')
|
||||
@ -132,7 +145,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const { required, maxLength, alpha } = require('vuelidate/lib/validators')
|
||||
const { required, maxLength, minValue, alpha, numeric } = require('vuelidate/lib/validators')
|
||||
import { mapActions, mapGetters } from 'vuex'
|
||||
|
||||
export default {
|
||||
@ -151,6 +164,7 @@ export default {
|
||||
|
||||
invoices: {
|
||||
invoice_prefix: null,
|
||||
invoice_number_length: null,
|
||||
invoice_mail_body: null,
|
||||
company_address_format: null,
|
||||
shipping_address_format: null,
|
||||
@ -193,11 +207,29 @@ export default {
|
||||
return this.$t('validation.characters_only')
|
||||
}
|
||||
},
|
||||
invoicenumberLengthError() {
|
||||
if (!this.$v.invoices.invoice_number_length.$error) {
|
||||
return ''
|
||||
}
|
||||
|
||||
if (!this.$v.invoices.invoice_number_length.required) {
|
||||
return this.$t('validation.required')
|
||||
}
|
||||
|
||||
if (!this.$v.invoices.invoice_number_length.minValue) {
|
||||
return this.$t('validation.number_length_minvalue')
|
||||
}
|
||||
|
||||
if (!this.$v.invoices.invoice_number_length.numeric) {
|
||||
return this.$t('validation.numbers_only')
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
settings(val) {
|
||||
this.invoices.invoice_prefix = val ? val.invoice_prefix : ''
|
||||
this.invoices.invoice_number_length = val ? val.invoice_number_length : ''
|
||||
|
||||
this.invoices.invoice_mail_body = val ? val.invoice_mail_body : null
|
||||
this.invoices.company_address_format = val
|
||||
@ -235,6 +267,11 @@ export default {
|
||||
maxLength: maxLength(5),
|
||||
alpha,
|
||||
},
|
||||
invoice_number_length: {
|
||||
required,
|
||||
minValue: minValue(1),
|
||||
numeric
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@ -274,6 +311,7 @@ export default {
|
||||
let data = {
|
||||
settings: {
|
||||
invoice_prefix: this.invoices.invoice_prefix,
|
||||
invoice_number_length: this.invoices.invoice_number_length,
|
||||
invoice_mail_body: this.invoices.invoice_mail_body,
|
||||
invoice_company_address_format: this.invoices.company_address_format,
|
||||
invoice_billing_address_format: this.invoices.billing_address_format,
|
||||
|
||||
Reference in New Issue
Block a user