2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 23:00:56 +00:00

incr: complete quick payment function

- fix quick view display update
This commit is contained in:
18alantom 2023-04-20 11:55:48 +05:30
parent bc909f630a
commit 759bedf764
2 changed files with 56 additions and 26 deletions

View File

@ -129,6 +129,13 @@ export abstract class Invoice extends Transactional {
const party = (await this.fyo.doc.getDoc('Party', this.party!)) as Party;
await party.updateOutstandingAmount();
if (this.makeQuickPayment && this.quickPaymentAccount) {
const payment = this.getPayment();
await payment?.sync();
await payment?.submit();
await this.load();
}
}
async afterCancel() {
@ -556,6 +563,11 @@ export abstract class Invoice extends Transactional {
],
};
if (this.makeQuickPayment && this.quickPaymentAccount) {
const quickPaymentAccount = this.isSales ? 'paymentAccount' : 'account';
data[quickPaymentAccount] = this.quickPaymentAccount;
}
return this.fyo.doc.getNewDoc(ModelNameEnum.Payment, data) as Payment;
}

View File

@ -35,7 +35,20 @@ export default defineComponent({
data() {
return { values: [] } as { values: { label: string; value: string }[] };
},
watch: {
async name(v1, v2) {
if (v1 === v2) {
return;
}
await this.setValues();
},
},
async mounted() {
await this.setValues();
},
methods: {
async setValues() {
const fields: Field[] = (this.schema?.fields ?? []).filter(
(f) =>
f &&
@ -45,7 +58,8 @@ export default defineComponent({
f.fieldname !== 'name' &&
!f.hidden &&
!f.meta &&
!f.abstract
!f.abstract &&
!f.computed
);
const data = (
@ -62,10 +76,14 @@ export default defineComponent({
return { value: '', label: '' };
}
return { value: this.fyo.format(data[f.fieldname], f), label: f.label };
return {
value: this.fyo.format(data[f.fieldname], f),
label: f.label,
};
})
.filter((i) => !!i.value);
},
},
computed: {
schema() {
return this.fyo.schemaMap[this.schemaName];