mirror of
https://github.com/frappe/books.git
synced 2025-01-03 15:17:30 +00:00
fix: prevent "Saving..." due to slipping error (needs frappejs #152)
This commit is contained in:
parent
96d7a9819c
commit
f905fab256
@ -36,9 +36,14 @@ export default class PaymentServer extends BaseDocument {
|
|||||||
outstandingAmount = baseGrandTotal;
|
outstandingAmount = baseGrandTotal;
|
||||||
}
|
}
|
||||||
if (this.amount <= 0 || this.amount > outstandingAmount) {
|
if (this.amount <= 0 || this.amount > outstandingAmount) {
|
||||||
throw new Error(
|
let message = frappe._(
|
||||||
`Payment amount (${this.amount}) should be greater than 0 and less than Outstanding amount (${outstandingAmount})`
|
`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 {
|
} else {
|
||||||
// update outstanding amounts in invoice and party
|
// update outstanding amounts in invoice and party
|
||||||
let newOutstanding = outstandingAmount - this.amount;
|
let newOutstanding = outstandingAmount - this.amount;
|
||||||
@ -61,4 +66,4 @@ export default class PaymentServer extends BaseDocument {
|
|||||||
|
|
||||||
// Maybe revert outstanding amount of invoice too?
|
// Maybe revert outstanding amount of invoice too?
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
type="primary"
|
type="primary"
|
||||||
v-if="
|
v-if="
|
||||||
meta &&
|
meta &&
|
||||||
meta.isSubmittable &&
|
meta.isSubmittable &&
|
||||||
doc &&
|
doc &&
|
||||||
!doc.submitted &&
|
!doc.submitted &&
|
||||||
!doc._notInserted
|
!doc._notInserted
|
||||||
"
|
"
|
||||||
class="ml-2 text-white text-xs"
|
class="ml-2 text-white text-xs"
|
||||||
>
|
>
|
||||||
@ -43,7 +43,7 @@
|
|||||||
v-if="imageField"
|
v-if="imageField"
|
||||||
:df="imageField"
|
:df="imageField"
|
||||||
:value="doc[imageField.fieldname]"
|
:value="doc[imageField.fieldname]"
|
||||||
@change="value => valueChange(imageField, value)"
|
@change="(value) => valueChange(imageField, value)"
|
||||||
size="small"
|
size="small"
|
||||||
class="mb-1"
|
class="mb-1"
|
||||||
:letter-placeholder="
|
:letter-placeholder="
|
||||||
@ -57,7 +57,7 @@
|
|||||||
v-if="titleField"
|
v-if="titleField"
|
||||||
:df="titleField"
|
:df="titleField"
|
||||||
:value="doc[titleField.fieldname]"
|
:value="doc[titleField.fieldname]"
|
||||||
@change="value => valueChange(titleField, value)"
|
@change="(value) => valueChange(titleField, value)"
|
||||||
@input="setTitleSize"
|
@input="setTitleSize"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -81,7 +81,11 @@ import Button from '@/components/Button';
|
|||||||
import FormControl from '@/components/Controls/FormControl';
|
import FormControl from '@/components/Controls/FormControl';
|
||||||
import TwoColumnForm from '@/components/TwoColumnForm';
|
import TwoColumnForm from '@/components/TwoColumnForm';
|
||||||
import DropdownWithActions from '@/components/DropdownWithActions';
|
import DropdownWithActions from '@/components/DropdownWithActions';
|
||||||
import { openQuickEdit, getActionsForDocument } from '@/utils';
|
import {
|
||||||
|
openQuickEdit,
|
||||||
|
getActionsForDocument,
|
||||||
|
handleErrorWithDialog,
|
||||||
|
} from '@/utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'QuickEditForm',
|
name: 'QuickEditForm',
|
||||||
@ -90,7 +94,7 @@ export default {
|
|||||||
Button,
|
Button,
|
||||||
FormControl,
|
FormControl,
|
||||||
TwoColumnForm,
|
TwoColumnForm,
|
||||||
DropdownWithActions
|
DropdownWithActions,
|
||||||
},
|
},
|
||||||
provide() {
|
provide() {
|
||||||
let vm = this;
|
let vm = this;
|
||||||
@ -99,7 +103,7 @@ export default {
|
|||||||
name: this.name,
|
name: this.name,
|
||||||
get doc() {
|
get doc() {
|
||||||
return vm.doc;
|
return vm.doc;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -107,7 +111,7 @@ export default {
|
|||||||
doc: null,
|
doc: null,
|
||||||
titleField: null,
|
titleField: null,
|
||||||
imageField: null,
|
imageField: null,
|
||||||
statusText: null
|
statusText: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
@ -120,7 +124,7 @@ export default {
|
|||||||
fields() {
|
fields() {
|
||||||
return this.meta
|
return this.meta
|
||||||
.getQuickEditFields()
|
.getQuickEditFields()
|
||||||
.filter(df => !(this.hideFields || []).includes(df.fieldname));
|
.filter((df) => !(this.hideFields || []).includes(df.fieldname));
|
||||||
},
|
},
|
||||||
actions() {
|
actions() {
|
||||||
return getActionsForDocument(this.doc);
|
return getActionsForDocument(this.doc);
|
||||||
@ -130,7 +134,7 @@ export default {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this.meta.quickEditWidget(this.doc);
|
return this.meta.quickEditWidget(this.doc);
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async fetchMetaAndDoc() {
|
async fetchMetaAndDoc() {
|
||||||
@ -165,7 +169,7 @@ export default {
|
|||||||
this.doc.once('afterRename', () => {
|
this.doc.once('afterRename', () => {
|
||||||
openQuickEdit({
|
openQuickEdit({
|
||||||
doctype: this.doctype,
|
doctype: this.doctype,
|
||||||
name: this.doc.name
|
name: this.doc.name,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.doc.on('beforeUpdate', () => {
|
this.doc.on('beforeUpdate', () => {
|
||||||
@ -186,8 +190,14 @@ export default {
|
|||||||
insertDoc() {
|
insertDoc() {
|
||||||
this.$refs.form.insert();
|
this.$refs.form.insert();
|
||||||
},
|
},
|
||||||
submitDoc() {
|
async submitDoc() {
|
||||||
this.$refs.form.submit();
|
console.log(this.meta)
|
||||||
|
console.log(this.doc)
|
||||||
|
try {
|
||||||
|
await this.$refs.form.submit();
|
||||||
|
} catch (e) {
|
||||||
|
this.statusText = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
routeToPrevious() {
|
routeToPrevious() {
|
||||||
this.$router.back();
|
this.$router.back();
|
||||||
@ -202,7 +212,7 @@ export default {
|
|||||||
}
|
}
|
||||||
input.size = valueLength;
|
input.size = valueLength;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user