2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00

feat: create manual return

This commit is contained in:
akshayitzme 2023-09-25 15:45:20 +05:30
parent d291b27d30
commit 04faff1f6f

View File

@ -86,6 +86,10 @@ export abstract class InvoiceItem extends Doc {
return this.parentdoc?.isMultiCurrency ?? false;
}
get isReturn() {
return !!this.parentdoc?.isReturn;
}
constructor(schema: Schema, data: DocValueMap, fyo: Fyo) {
super(schema, data, fyo);
this._setGetCurrencies();
@ -210,6 +214,15 @@ export abstract class InvoiceItem extends Doc {
const unitDoc = itemDoc.getLink('uom');
let quantity: number = this.quantity ?? 1;
if (this.isReturn && quantity > 0) {
quantity *= -1;
}
if (!this.isReturn && quantity < 0) {
quantity *= -1;
}
if (fieldname === 'transferQuantity') {
quantity = this.transferQuantity! * this.unitConversionFactor!;
}
@ -225,6 +238,8 @@ export abstract class InvoiceItem extends Doc {
'transferQuantity',
'transferUnit',
'unitConversionFactor',
'item',
'isReturn',
],
},
unitConversionFactor: {