mirror of
https://github.com/frappe/books.git
synced 2024-11-08 14:50:56 +00:00
incr: complete quick payment function
- fix quick view display update
This commit is contained in:
parent
bc909f630a
commit
759bedf764
@ -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;
|
||||
}
|
||||
|
||||
|
@ -35,36 +35,54 @@ 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() {
|
||||
const fields: Field[] = (this.schema?.fields ?? []).filter(
|
||||
(f) =>
|
||||
f &&
|
||||
f.fieldtype !== 'Table' &&
|
||||
f.fieldtype !== 'AttachImage' &&
|
||||
f.fieldtype !== 'Attachment' &&
|
||||
f.fieldname !== 'name' &&
|
||||
!f.hidden &&
|
||||
!f.meta &&
|
||||
!f.abstract
|
||||
);
|
||||
await this.setValues();
|
||||
},
|
||||
methods: {
|
||||
async setValues() {
|
||||
const fields: Field[] = (this.schema?.fields ?? []).filter(
|
||||
(f) =>
|
||||
f &&
|
||||
f.fieldtype !== 'Table' &&
|
||||
f.fieldtype !== 'AttachImage' &&
|
||||
f.fieldtype !== 'Attachment' &&
|
||||
f.fieldname !== 'name' &&
|
||||
!f.hidden &&
|
||||
!f.meta &&
|
||||
!f.abstract &&
|
||||
!f.computed
|
||||
);
|
||||
|
||||
const data = (
|
||||
await this.fyo.db.getAll(this.schemaName, {
|
||||
fields: fields.map((f) => f.fieldname),
|
||||
filters: { name: this.name },
|
||||
})
|
||||
)[0];
|
||||
const data = (
|
||||
await this.fyo.db.getAll(this.schemaName, {
|
||||
fields: fields.map((f) => f.fieldname),
|
||||
filters: { name: this.name },
|
||||
})
|
||||
)[0];
|
||||
|
||||
this.values = fields
|
||||
.map((f) => {
|
||||
const value = data[f.fieldname];
|
||||
if (isFalsy(value)) {
|
||||
return { value: '', label: '' };
|
||||
}
|
||||
this.values = fields
|
||||
.map((f) => {
|
||||
const value = data[f.fieldname];
|
||||
if (isFalsy(value)) {
|
||||
return { value: '', label: '' };
|
||||
}
|
||||
|
||||
return { value: this.fyo.format(data[f.fieldname], f), label: f.label };
|
||||
})
|
||||
.filter((i) => !!i.value);
|
||||
return {
|
||||
value: this.fyo.format(data[f.fieldname], f),
|
||||
label: f.label,
|
||||
};
|
||||
})
|
||||
.filter((i) => !!i.value);
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
schema() {
|
||||
|
Loading…
Reference in New Issue
Block a user