diff --git a/src/components/PriceInputRow.vue b/src/components/PriceInputRow.vue index 6dc3c7dccd8..1f2ee432f14 100644 --- a/src/components/PriceInputRow.vue +++ b/src/components/PriceInputRow.vue @@ -47,6 +47,7 @@ :label="$t('Common.QuantityBought')" type="text" inputmode="numeric" + :rules="receiptQuantityRules" :prepend-inner-icon="PROOF_TYPE_RECEIPT_ICON" hide-details="auto" /> @@ -112,6 +113,13 @@ export default { value => !value.match(/\.\d{3}/) || this.$t('PriceRules.TwoDecimals'), ] }, + receiptQuantityRules() { + if (!this.priceForm.receipt_quantity) return [() => true] // optional field + return [ + value => !isNaN(value) || this.$t('PriceRules.Number'), + value => Number(value) >= 1 || this.$t('PriceRules.Positive'), + ] + }, priceFormFilled() { let keys = ['price', 'currency'] return Object.keys(this.priceForm).filter(k => keys.includes(k)).every(k => !!this.priceForm[k]) diff --git a/src/components/ProofMetadataInputRow.vue b/src/components/ProofMetadataInputRow.vue index 94515e46cb4..d7cc70f57db 100644 --- a/src/components/ProofMetadataInputRow.vue +++ b/src/components/ProofMetadataInputRow.vue @@ -31,30 +31,27 @@ - -

- - {{ $t('Common.AdditionalInfo') }} -

-
-
- true] // optional field + return [ + value => !isNaN(value) || this.$t('PriceRules.Number'), + value => Number(value) >= 1 || this.$t('PriceRules.Positive'), + ] + }, + priceTotalRules() { + if (!this.proofMetadataForm.receipt_price_total) return [() => true] // optional field return [ - // value => !!value && !!value.trim() || this.$t('PriceRules.AmountRequired'), value => !!value && !value.trim().match(/ /) || this.$t('PriceRules.NoSpaces'), value => !isNaN(value) || this.$t('PriceRules.Number'), value => Number(value) >= 0 || this.$t('PriceRules.Positive'),