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