2
0
mirror of https://github.com/frappe/books.git synced 2025-02-02 03:58:26 +00:00

fix: hide UOM conversion and batches behind flags

- add enable uom conversions flag
- add enable batches flag
- remove batch no from table fields and move to quick edit
This commit is contained in:
18alantom 2023-02-27 18:11:35 +05:30
parent a6b051ac04
commit 869cdebed7
10 changed files with 57 additions and 11 deletions

View File

@ -430,9 +430,13 @@ export abstract class InvoiceItem extends Doc {
!(this.enableDiscounting && !!this.setItemDiscountAmount),
itemDiscountPercent: () =>
!(this.enableDiscounting && !this.setItemDiscountAmount),
transferUnit: () => !this.enableInventory,
transferQuantity: () => !this.enableInventory,
unitConversionFactor: () => !this.enableInventory,
batchNumber: () => !this.fyo.singles.InventorySettings?.enableBatches,
transferUnit: () =>
!this.fyo.singles.InventorySettings?.enableUomConversions,
transferQuantity: () =>
!this.fyo.singles.InventorySettings?.enableUomConversions,
unitConversionFactor: () =>
!this.fyo.singles.InventorySettings?.enableUomConversions,
};
static filters: FiltersMap = {

View File

@ -146,9 +146,11 @@ export class Item extends Doc {
!this.fyo.singles.AccountingSettings?.enableInventory ||
this.itemType !== 'Product' ||
(this.inserted && !this.trackItem),
hasBatchNumber: () => !this.trackItem,
barcode: () => !this.fyo.singles.InventorySettings?.enableBarcodes,
uomConversions: () => !this.fyo.singles.AccountingSettings?.enableInventory,
hasBatchNumber: () =>
!(this.fyo.singles.InventorySettings?.enableBatches && this.trackItem),
uomConversions: () =>
!this.fyo.singles.InventorySettings?.enableUomConversions,
};
readOnly: ReadOnlyMap = {

View File

@ -4,6 +4,7 @@ import { Doc } from 'fyo/model/doc';
import {
FiltersMap,
FormulaMap,
HiddenMap,
ReadOnlyMap,
RequiredMap,
ValidationMap,
@ -233,6 +234,16 @@ export class StockMovementItem extends Doc {
toLocation: () => this.isIssue,
};
override hidden: HiddenMap = {
batchNumber: () => !this.fyo.singles.InventorySettings?.enableBatches,
transferUnit: () =>
!this.fyo.singles.InventorySettings?.enableUomConversions,
transferQuantity: () =>
!this.fyo.singles.InventorySettings?.enableUomConversions,
unitConversionFactor: () =>
!this.fyo.singles.InventorySettings?.enableUomConversions,
};
static createFilters: FiltersMap = {
item: () => ({ trackItem: true, itemType: 'Product' }),
};

View File

@ -1,7 +1,12 @@
import { t } from 'fyo';
import { DocValue } from 'fyo/core/types';
import { Doc } from 'fyo/model/doc';
import { FiltersMap, FormulaMap, ValidationMap } from 'fyo/model/types';
import {
FiltersMap,
FormulaMap,
HiddenMap,
ValidationMap,
} from 'fyo/model/types';
import { ValidationError } from 'fyo/utils/errors';
import { ModelNameEnum } from 'models/types';
import { Money } from 'pesa';
@ -21,7 +26,7 @@ export class StockTransferItem extends Doc {
amount?: Money;
description?: string;
hsnCode?: number;
batchNumber?: string
batchNumber?: string;
formulas: FormulaMap = {
description: {
@ -200,4 +205,14 @@ export class StockTransferItem extends Doc {
return { for: ['not in', [itemNotFor]], trackItem: true };
},
};
override hidden: HiddenMap = {
batchNumber: () => !this.fyo.singles.InventorySettings?.enableBatches,
transferUnit: () =>
!this.fyo.singles.InventorySettings?.enableUomConversions,
transferQuantity: () =>
!this.fyo.singles.InventorySettings?.enableUomConversions,
unitConversionFactor: () =>
!this.fyo.singles.InventorySettings?.enableUomConversions,
};
}

View File

@ -134,7 +134,7 @@
"readOnly": true
}
],
"tableFields": ["item", "tax", "batchNumber", "quantity", "rate", "amount"],
"tableFields": ["item", "tax", "quantity", "rate", "amount"],
"keywordFields": ["item", "tax"],
"quickEditFields": [
"item",

View File

@ -158,7 +158,6 @@
"barcode",
"hsnCode",
"trackItem",
"hasBatchNumber",
"uom"
],
"keywordFields": ["name", "itemType", "for"]

View File

@ -50,6 +50,16 @@
"fieldname": "enableBarcodes",
"label": "Enable Barcodes",
"fieldtype": "Check"
},
{
"fieldname": "enableBatches",
"label": "Enable Batches",
"fieldtype": "Check"
},
{
"fieldname": "enableUomConversions",
"label": "Enable UOM Conversion",
"fieldtype": "Check"
}
]
}

View File

@ -84,7 +84,7 @@
"readOnly": true
}
],
"tableFields": ["item", "fromLocation", "toLocation", "batchNumber", "quantity", "rate"],
"tableFields": ["item", "fromLocation", "toLocation", "quantity", "rate"],
"keywordFields": ["item"],
"quickEditFields": [
"item",

View File

@ -86,7 +86,7 @@
"placeholder": "HSN/SAC Code"
}
],
"tableFields": ["item", "location", "batchNumber", "quantity", "rate", "amount"],
"tableFields": ["item", "location", "quantity", "rate", "amount"],
"quickEditFields": [
"item",

View File

@ -234,6 +234,11 @@ function getListViewList(fyo: Fyo): SearchItem[] {
);
}
const hasBatch = fyo.doc.singles.InventorySettings?.enableBatches;
if (hasBatch) {
schemaNames.push(ModelNameEnum.BatchNumber);
}
if (fyo.store.isDevelopment) {
schemaNames = Object.keys(fyo.schemaMap) as ModelNameEnum[];
}