diff --git a/models/doctype/Payment/PaymentServer.js b/models/doctype/Payment/PaymentServer.js index aadb3e71..7ffe4aaf 100644 --- a/models/doctype/Payment/PaymentServer.js +++ b/models/doctype/Payment/PaymentServer.js @@ -36,9 +36,14 @@ export default class PaymentServer extends BaseDocument { outstandingAmount = baseGrandTotal; } if (this.amount <= 0 || this.amount > outstandingAmount) { - throw new Error( - `Payment amount (${this.amount}) should be greater than 0 and less than Outstanding amount (${outstandingAmount})` + let message = frappe._( + `Payment amount (${this.amount}) should be less than Outstanding amount (${outstandingAmount}).` ); + if (this.amount <= 0) { + const amt = this.amount < 0 ? ` (${this.amount})` : ''; + message = frappe._(`Payment amount${amt} should be greater than 0.`); + } + throw new frappe.errors.ValidationError(message); } else { // update outstanding amounts in invoice and party let newOutstanding = outstandingAmount - this.amount; @@ -61,4 +66,4 @@ export default class PaymentServer extends BaseDocument { // Maybe revert outstanding amount of invoice too? } -}; +} diff --git a/src/pages/QuickEditForm.vue b/src/pages/QuickEditForm.vue index 8351c825..36f74d2c 100644 --- a/src/pages/QuickEditForm.vue +++ b/src/pages/QuickEditForm.vue @@ -26,10 +26,10 @@ type="primary" v-if=" meta && - meta.isSubmittable && - doc && - !doc.submitted && - !doc._notInserted + meta.isSubmittable && + doc && + !doc.submitted && + !doc._notInserted " class="ml-2 text-white text-xs" > @@ -43,7 +43,7 @@ v-if="imageField" :df="imageField" :value="doc[imageField.fieldname]" - @change="value => valueChange(imageField, value)" + @change="(value) => valueChange(imageField, value)" size="small" class="mb-1" :letter-placeholder=" @@ -57,7 +57,7 @@ v-if="titleField" :df="titleField" :value="doc[titleField.fieldname]" - @change="value => valueChange(titleField, value)" + @change="(value) => valueChange(titleField, value)" @input="setTitleSize" /> @@ -81,7 +81,11 @@ import Button from '@/components/Button'; import FormControl from '@/components/Controls/FormControl'; import TwoColumnForm from '@/components/TwoColumnForm'; import DropdownWithActions from '@/components/DropdownWithActions'; -import { openQuickEdit, getActionsForDocument } from '@/utils'; +import { + openQuickEdit, + getActionsForDocument, + handleErrorWithDialog, +} from '@/utils'; export default { name: 'QuickEditForm', @@ -90,7 +94,7 @@ export default { Button, FormControl, TwoColumnForm, - DropdownWithActions + DropdownWithActions, }, provide() { let vm = this; @@ -99,7 +103,7 @@ export default { name: this.name, get doc() { return vm.doc; - } + }, }; }, data() { @@ -107,7 +111,7 @@ export default { doc: null, titleField: null, imageField: null, - statusText: null + statusText: null, }; }, async created() { @@ -120,7 +124,7 @@ export default { fields() { return this.meta .getQuickEditFields() - .filter(df => !(this.hideFields || []).includes(df.fieldname)); + .filter((df) => !(this.hideFields || []).includes(df.fieldname)); }, actions() { return getActionsForDocument(this.doc); @@ -130,7 +134,7 @@ export default { return null; } return this.meta.quickEditWidget(this.doc); - } + }, }, methods: { async fetchMetaAndDoc() { @@ -165,7 +169,7 @@ export default { this.doc.once('afterRename', () => { openQuickEdit({ doctype: this.doctype, - name: this.doc.name + name: this.doc.name, }); }); this.doc.on('beforeUpdate', () => { @@ -186,8 +190,14 @@ export default { insertDoc() { this.$refs.form.insert(); }, - submitDoc() { - this.$refs.form.submit(); + async submitDoc() { + console.log(this.meta) + console.log(this.doc) + try { + await this.$refs.form.submit(); + } catch (e) { + this.statusText = null; + } }, routeToPrevious() { this.$router.back(); @@ -202,7 +212,7 @@ export default { } input.size = valueLength; } - } - } + }, + }, };