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

incr: add amount paid on entering writeoff

This commit is contained in:
18alantom 2022-07-15 14:00:25 +05:30
parent 02f1b11203
commit 099324217d
4 changed files with 20 additions and 6 deletions

View File

@ -10,14 +10,14 @@ import {
HiddenMap,
ListViewSettings,
RequiredMap,
ValidationMap,
ValidationMap
} from 'fyo/model/types';
import { ValidationError } from 'fyo/utils/errors';
import {
getDocStatus,
getLedgerLinkAction,
getStatusMap,
statusColor,
statusColor
} from 'models/helpers';
import { LedgerPosting } from 'models/Transactional/LedgerPosting';
import { Transactional } from 'models/Transactional/Transactional';
@ -366,6 +366,10 @@ export class Payment extends Transactional {
formula: async () => this.getSum('for', 'amount', false),
dependsOn: ['for'],
},
amountPaid: {
formula: async () => this.amount!.sub(this.writeoff!),
dependsOn: ['amount', 'writeoff', 'for'],
},
};
validations: ValidationMap = {
@ -404,6 +408,7 @@ export class Payment extends Transactional {
hidden: HiddenMap = {
referenceId: () => this.paymentMethod === 'Cash',
clearanceDate: () => this.paymentMethod === 'Cash',
amountPaid: () => this.writeoff?.isZero() ?? true,
};
static filters: FiltersMap = {

View File

@ -120,6 +120,12 @@
"label": "Write Off",
"fieldtype": "Currency"
},
{
"fieldname": "amountPaid",
"label": "Amount Paid",
"fieldtype": "Currency",
"computed": true
},
{
"fieldname": "for",
"label": "Payment Reference",
@ -141,6 +147,7 @@
"clearanceDate",
"amount",
"writeoff",
"amountPaid",
"for"
],
"keywordFields": ["name", "party", "paymentType"]

View File

@ -8,7 +8,7 @@
ref="input"
:class="inputClasses"
:type="inputType"
:value="value.round()"
:value="value?.round()"
:placeholder="inputPlaceholder"
:readonly="isReadOnly"
@blur="onBlur"
@ -69,7 +69,7 @@ export default {
},
computed: {
formattedValue() {
return fyo.format(this.value, this.df, this.doc);
return fyo.format(this.value ?? fyo.pesa(0), this.df, this.doc);
},
},
};

View File

@ -233,11 +233,13 @@ export default {
return;
}
if (readOnly && !this?.doc[fieldname]) {
const isManual = this.schema.naming === 'manual';
const isNumberSeries = fyo.getField(this.schemaName, 'numberSeries');
if (readOnly && (!this?.doc[fieldname] || isNumberSeries)) {
this.doc.set(fieldname, t`New ${this.schema.label}`);
}
if (this?.doc[fieldname]) {
if (this?.doc[fieldname] && !isManual) {
return;
}