mirror of
https://github.com/frappe/books.git
synced 2024-12-22 10:58:59 +00:00
fix: update display order, fix formulas
This commit is contained in:
parent
140b99a401
commit
52bf777d8d
@ -157,26 +157,31 @@ export abstract class InvoiceItem extends Doc {
|
||||
dependsOn: ['item'],
|
||||
},
|
||||
transferUnit: {
|
||||
formula: async () =>
|
||||
(await this.fyo.getValue(
|
||||
formula: async (fieldname) => {
|
||||
if (fieldname === 'quantity' || fieldname === 'unit') {
|
||||
return this.unit;
|
||||
}
|
||||
|
||||
return (await this.fyo.getValue(
|
||||
'Item',
|
||||
this.item as string,
|
||||
'unit'
|
||||
)) as string,
|
||||
dependsOn: ['item'],
|
||||
)) as string;
|
||||
},
|
||||
dependsOn: ['item', 'unit'],
|
||||
},
|
||||
transferQuantity: {
|
||||
formula: async () => {
|
||||
if (this.unit === this.transferUnit) {
|
||||
formula: async (fieldname) => {
|
||||
if (fieldname === 'quantity' || this.unit === this.transferUnit) {
|
||||
return this.quantity;
|
||||
}
|
||||
|
||||
return this.transferQuantity;
|
||||
},
|
||||
dependsOn: ['item'],
|
||||
dependsOn: ['item', 'quantity'],
|
||||
},
|
||||
quantity: {
|
||||
formula: async () => {
|
||||
formula: async (fieldname) => {
|
||||
if (!this.item) {
|
||||
return this.quantity as number;
|
||||
}
|
||||
@ -186,17 +191,24 @@ export abstract class InvoiceItem extends Doc {
|
||||
this.item as string
|
||||
);
|
||||
const unitDoc = itemDoc.getLink('uom');
|
||||
if (unitDoc?.isWhole) {
|
||||
return Math.round(
|
||||
this.transferQuantity! * this.unitConversionFactor!
|
||||
);
|
||||
|
||||
let quantity: number = this.quantity ?? 1;
|
||||
if (fieldname === 'transferQuantity') {
|
||||
quantity = this.transferQuantity! * this.unitConversionFactor!;
|
||||
}
|
||||
|
||||
return safeParseFloat(
|
||||
this.transferQuantity! * this.unitConversionFactor!
|
||||
);
|
||||
if (unitDoc?.isWhole) {
|
||||
return Math.round(quantity);
|
||||
}
|
||||
|
||||
return safeParseFloat(quantity);
|
||||
},
|
||||
dependsOn: ['quantity', 'transferQuantity', 'unitConversionFactor'],
|
||||
dependsOn: [
|
||||
'quantity',
|
||||
'transferQuantity',
|
||||
'transferUnit',
|
||||
'unitConversionFactor',
|
||||
],
|
||||
},
|
||||
unitConversionFactor: {
|
||||
formula: async () => {
|
||||
@ -420,6 +432,7 @@ export abstract class InvoiceItem extends Doc {
|
||||
!(this.enableDiscounting && !this.setItemDiscountAmount),
|
||||
transferUnit: () => !this.enableInventory,
|
||||
transferQuantity: () => !this.enableInventory,
|
||||
unitConversionFactor: () => !this.enableInventory,
|
||||
};
|
||||
|
||||
static filters: FiltersMap = {
|
||||
|
@ -108,26 +108,31 @@ export class StockMovementItem extends Doc {
|
||||
dependsOn: ['item'],
|
||||
},
|
||||
transferUnit: {
|
||||
formula: async () =>
|
||||
(await this.fyo.getValue(
|
||||
formula: async (fieldname) => {
|
||||
if (fieldname === 'quantity' || fieldname === 'unit') {
|
||||
return this.unit;
|
||||
}
|
||||
|
||||
return (await this.fyo.getValue(
|
||||
'Item',
|
||||
this.item as string,
|
||||
'unit'
|
||||
)) as string,
|
||||
dependsOn: ['item'],
|
||||
)) as string;
|
||||
},
|
||||
dependsOn: ['item', 'unit'],
|
||||
},
|
||||
transferQuantity: {
|
||||
formula: async () => {
|
||||
if (this.unit === this.transferUnit) {
|
||||
formula: async (fieldname) => {
|
||||
if (fieldname === 'quantity' || this.unit === this.transferUnit) {
|
||||
return this.quantity;
|
||||
}
|
||||
|
||||
return this.transferQuantity;
|
||||
},
|
||||
dependsOn: ['item'],
|
||||
dependsOn: ['item', 'quantity'],
|
||||
},
|
||||
quantity: {
|
||||
formula: async () => {
|
||||
formula: async (fieldname) => {
|
||||
if (!this.item) {
|
||||
return this.quantity as number;
|
||||
}
|
||||
@ -137,17 +142,24 @@ export class StockMovementItem extends Doc {
|
||||
this.item as string
|
||||
);
|
||||
const unitDoc = itemDoc.getLink('uom');
|
||||
if (unitDoc?.isWhole) {
|
||||
return Math.round(
|
||||
this.transferQuantity! * this.unitConversionFactor!
|
||||
);
|
||||
|
||||
let quantity: number = this.quantity ?? 1;
|
||||
if (fieldname === 'transferQuantity') {
|
||||
quantity = this.transferQuantity! * this.unitConversionFactor!;
|
||||
}
|
||||
|
||||
return safeParseFloat(
|
||||
this.transferQuantity! * this.unitConversionFactor!
|
||||
);
|
||||
if (unitDoc?.isWhole) {
|
||||
return Math.round(quantity);
|
||||
}
|
||||
|
||||
return safeParseFloat(quantity);
|
||||
},
|
||||
dependsOn: ['quantity', 'transferQuantity', 'unitConversionFactor'],
|
||||
dependsOn: [
|
||||
'quantity',
|
||||
'transferQuantity',
|
||||
'transferUnit',
|
||||
'unitConversionFactor',
|
||||
],
|
||||
},
|
||||
unitConversionFactor: {
|
||||
formula: async () => {
|
||||
|
@ -42,26 +42,31 @@ export class StockTransferItem extends Doc {
|
||||
dependsOn: ['item'],
|
||||
},
|
||||
transferUnit: {
|
||||
formula: async () =>
|
||||
(await this.fyo.getValue(
|
||||
formula: async (fieldname) => {
|
||||
if (fieldname === 'quantity' || fieldname === 'unit') {
|
||||
return this.unit;
|
||||
}
|
||||
|
||||
return (await this.fyo.getValue(
|
||||
'Item',
|
||||
this.item as string,
|
||||
'unit'
|
||||
)) as string,
|
||||
dependsOn: ['item'],
|
||||
)) as string;
|
||||
},
|
||||
dependsOn: ['item', 'unit'],
|
||||
},
|
||||
transferQuantity: {
|
||||
formula: async () => {
|
||||
if (this.unit === this.transferUnit) {
|
||||
formula: async (fieldname) => {
|
||||
if (fieldname === 'quantity' || this.unit === this.transferUnit) {
|
||||
return this.quantity;
|
||||
}
|
||||
|
||||
return this.transferQuantity;
|
||||
},
|
||||
dependsOn: ['item'],
|
||||
dependsOn: ['item', 'quantity'],
|
||||
},
|
||||
quantity: {
|
||||
formula: async () => {
|
||||
formula: async (fieldname) => {
|
||||
if (!this.item) {
|
||||
return this.quantity as number;
|
||||
}
|
||||
@ -71,17 +76,24 @@ export class StockTransferItem extends Doc {
|
||||
this.item as string
|
||||
);
|
||||
const unitDoc = itemDoc.getLink('uom');
|
||||
if (unitDoc?.isWhole) {
|
||||
return Math.round(
|
||||
this.transferQuantity! * this.unitConversionFactor!
|
||||
);
|
||||
|
||||
let quantity: number = this.quantity ?? 1;
|
||||
if (fieldname === 'transferQuantity') {
|
||||
quantity = this.transferQuantity! * this.unitConversionFactor!;
|
||||
}
|
||||
|
||||
return safeParseFloat(
|
||||
this.transferQuantity! * this.unitConversionFactor!
|
||||
);
|
||||
if (unitDoc?.isWhole) {
|
||||
return Math.round(quantity);
|
||||
}
|
||||
|
||||
return safeParseFloat(quantity);
|
||||
},
|
||||
dependsOn: ['quantity', 'transferQuantity', 'unitConversionFactor'],
|
||||
dependsOn: [
|
||||
'quantity',
|
||||
'transferQuantity',
|
||||
'transferUnit',
|
||||
'unitConversionFactor',
|
||||
],
|
||||
},
|
||||
unitConversionFactor: {
|
||||
formula: async () => {
|
||||
|
@ -28,6 +28,7 @@
|
||||
"label": "Transfer Unit",
|
||||
"fieldtype": "Link",
|
||||
"target": "UOM",
|
||||
"default": "Unit",
|
||||
"placeholder": "Unit"
|
||||
},
|
||||
{
|
||||
@ -48,7 +49,7 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "quantity",
|
||||
"label": "Qty. in Stock Unit",
|
||||
"label": "Quantity",
|
||||
"fieldtype": "Float",
|
||||
"required": true,
|
||||
"default": 1
|
||||
@ -134,11 +135,13 @@
|
||||
"hsnCode",
|
||||
"tax",
|
||||
"rate",
|
||||
"transferUnit",
|
||||
|
||||
"transferQuantity",
|
||||
"unit",
|
||||
"transferUnit",
|
||||
"quantity",
|
||||
"unit",
|
||||
"unitConversionFactor",
|
||||
|
||||
"amount",
|
||||
"setItemDiscountAmount",
|
||||
"itemDiscountAmount",
|
||||
|
@ -62,6 +62,7 @@
|
||||
"fieldtype": "Table",
|
||||
"target": "StockMovementItem",
|
||||
"required": true,
|
||||
"edit": true,
|
||||
"section": "Items"
|
||||
},
|
||||
{
|
||||
|
@ -31,6 +31,7 @@
|
||||
"label": "Transfer Unit",
|
||||
"fieldtype": "Link",
|
||||
"target": "UOM",
|
||||
"default": "Unit",
|
||||
"placeholder": "Unit"
|
||||
},
|
||||
{
|
||||
@ -51,7 +52,7 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "quantity",
|
||||
"label": "Qty. in Stock Unit",
|
||||
"label": "Quantity",
|
||||
"fieldtype": "Float",
|
||||
"required": true,
|
||||
"default": 1
|
||||
@ -82,11 +83,13 @@
|
||||
"item",
|
||||
"fromLocation",
|
||||
"toLocation",
|
||||
"transferUnit",
|
||||
|
||||
"transferQuantity",
|
||||
"unit",
|
||||
"transferUnit",
|
||||
"quantity",
|
||||
"unit",
|
||||
"unitConversionFactor",
|
||||
|
||||
"rate",
|
||||
"amount"
|
||||
]
|
||||
|
@ -22,6 +22,7 @@
|
||||
"label": "Transfer Unit",
|
||||
"fieldtype": "Link",
|
||||
"target": "UOM",
|
||||
"default": "Unit",
|
||||
"placeholder": "Unit"
|
||||
},
|
||||
{
|
||||
@ -42,7 +43,7 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "quantity",
|
||||
"label": "Qty. in Stock Unit",
|
||||
"label": "Quantity",
|
||||
"fieldtype": "Float",
|
||||
"required": true,
|
||||
"default": 1
|
||||
@ -82,11 +83,13 @@
|
||||
"tableFields": ["item", "location", "quantity", "rate", "amount"],
|
||||
"quickEditFields": [
|
||||
"item",
|
||||
"transferUnit",
|
||||
|
||||
"transferQuantity",
|
||||
"unit",
|
||||
"transferUnit",
|
||||
"quantity",
|
||||
"unit",
|
||||
"unitConversionFactor",
|
||||
|
||||
"description",
|
||||
"hsnCode",
|
||||
"location",
|
||||
|
Loading…
Reference in New Issue
Block a user