Add invoice/estimate/payment number length setting (#425)

* Add invoice/estimate/payment number length setting
This commit is contained in:
Florian Gareis
2021-03-26 08:31:43 +01:00
committed by GitHub
parent 3f7db2793f
commit bfd9850bf6
15 changed files with 209 additions and 24 deletions

View File

@@ -14,6 +14,19 @@
/>
</sw-input-group>
<sw-input-group
:label="$t('settings.customization.estimates.estimate_number_length')"
:error="estimateNumberLengthError"
class="mt-6 mb-4"
>
<sw-input
v-model="estimates.estimate_number_length"
:invalid="$v.estimates.estimate_number_length.$error"
type="number"
style="max-width: 60px"
/>
</sw-input-group>
<sw-input-group
:label="
$t('settings.customization.estimates.default_estimate_email_body')
@@ -127,7 +140,7 @@
<script>
import { mapActions, mapGetters } from 'vuex'
const { required, maxLength, alpha } = require('vuelidate/lib/validators')
const { required, maxLength, minValue, alpha, numeric } = require('vuelidate/lib/validators')
export default {
props: {
@@ -145,6 +158,7 @@ export default {
estimates: {
estimate_prefix: null,
estimate_number_length: null,
estimate_mail_body: null,
estimate_terms_and_conditions: null,
company_address_format: null,
@@ -193,6 +207,23 @@ export default {
return this.$t('validation.characters_only')
}
},
estimateNumberLengthError() {
if (!this.$v.estimates.estimate_number_length.$error) {
return ''
}
if (!this.$v.estimates.estimate_number_length.required) {
return this.$t('validation.required')
}
if (!this.$v.estimates.estimate_number_length.minValue) {
return this.$t('validation.number_length_minvalue')
}
if (!this.$v.estimates.estimate_number_length.numeric) {
return this.$t('validation.numbers_only')
}
},
},
validations: {
@@ -202,12 +233,18 @@ export default {
maxLength: maxLength(5),
alpha,
},
estimate_number_length: {
required,
minValue: minValue(1),
numeric
},
},
},
watch: {
settings(val) {
this.estimates.estimate_prefix = val ? val.estimate_prefix : ''
this.estimates.estimate_number_length = val ? val.estimate_number_length : ''
this.estimates.estimate_mail_body = val ? val.estimate_mail_body : ''
this.estimates.company_address_format = val
@@ -275,6 +312,7 @@ export default {
let data = {
settings: {
estimate_prefix: this.estimates.estimate_prefix,
estimate_number_length: this.estimates.estimate_number_length,
estimate_mail_body: this.estimates.estimate_mail_body,
estimate_company_address_format: this.estimates
.company_address_format,