2
0
mirror of https://github.com/frappe/books.git synced 2025-01-03 07:12:21 +00:00

feat: batch transactions

This commit is contained in:
akshayitzme 2023-01-13 18:46:52 +05:30
parent 665e341450
commit 08e46592a9
15 changed files with 46 additions and 3 deletions

View File

@ -18,6 +18,8 @@ export class Item extends Doc {
trackItem?: boolean; trackItem?: boolean;
itemType?: 'Product' | 'Service'; itemType?: 'Product' | 'Service';
for?: 'Purchases' | 'Sales' | 'Both'; for?: 'Purchases' | 'Sales' | 'Both';
hasBatchNumber?: boolean;
batchNumber?:string;
formulas: FormulaMap = { formulas: FormulaMap = {
incomeAccount: { incomeAccount: {

View File

@ -11,6 +11,7 @@ export class PurchaseReceipt extends StockTransfer {
formRoute: ({ name }) => `/edit/PurchaseReceipt/${name}`, formRoute: ({ name }) => `/edit/PurchaseReceipt/${name}`,
columns: [ columns: [
'name', 'name',
'batchNumber',
getTransactionStatusColumn(), getTransactionStatusColumn(),
'party', 'party',
'date', 'date',

View File

@ -10,4 +10,5 @@ export class StockLedgerEntry extends Doc {
location?: string; location?: string;
referenceName?: string; referenceName?: string;
referenceType?: string; referenceType?: string;
batchNumber?: string;
} }

View File

@ -204,6 +204,7 @@ class StockManagerItem {
referenceType: string; referenceType: string;
fromLocation?: string; fromLocation?: string;
toLocation?: string; toLocation?: string;
batchNumber?: string;
stockLedgerEntries?: StockLedgerEntry[]; stockLedgerEntries?: StockLedgerEntry[];
@ -218,6 +219,7 @@ class StockManagerItem {
this.toLocation = details.toLocation; this.toLocation = details.toLocation;
this.referenceName = details.referenceName; this.referenceName = details.referenceName;
this.referenceType = details.referenceType; this.referenceType = details.referenceType;
this.batchNumber = details.batchNumber;
this.fyo = fyo; this.fyo = fyo;
} }
@ -270,6 +272,7 @@ class StockManagerItem {
date: this.date, date: this.date,
item: this.item, item: this.item,
rate: this.rate, rate: this.rate,
batchNumber: this.batchNumber,
quantity, quantity,
location, location,
referenceName: this.referenceName, referenceName: this.referenceName,

View File

@ -84,6 +84,7 @@ export class StockMovement extends Transfer {
item: row.item!, item: row.item!,
rate: row.rate!, rate: row.rate!,
quantity: row.quantity!, quantity: row.quantity!,
batchNumber: row.batchNumber!,
fromLocation: row.fromLocation, fromLocation: row.fromLocation,
toLocation: row.toLocation, toLocation: row.toLocation,
})); }));

View File

@ -19,6 +19,7 @@ export class StockMovementItem extends Doc {
rate?: Money; rate?: Money;
amount?: Money; amount?: Money;
parentdoc?: StockMovement; parentdoc?: StockMovement;
batchNumber? : string;
get isIssue() { get isIssue() {
return this.parentdoc?.movementType === MovementType.MaterialIssue; return this.parentdoc?.movementType === MovementType.MaterialIssue;

View File

@ -68,6 +68,7 @@ export abstract class StockTransfer extends Transfer {
item: row.item!, item: row.item!,
rate: row.rate!, rate: row.rate!,
quantity: row.quantity!, quantity: row.quantity!,
batchNumber: row.batchNumber!,
fromLocation, fromLocation,
toLocation, toLocation,
}; };

View File

@ -12,6 +12,7 @@ export class StockTransferItem extends Doc {
unit?: string; unit?: string;
description?: string; description?: string;
hsnCode?: number; hsnCode?: number;
batchNumber?: string
formulas: FormulaMap = { formulas: FormulaMap = {
description: { description: {

View File

@ -21,6 +21,7 @@ export interface SMTransferDetails {
item: string; item: string;
rate: Money; rate: Money;
quantity: number; quantity: number;
batchNumber?: string;
fromLocation?: string; fromLocation?: string;
toLocation?: string; toLocation?: string;
} }

View File

@ -17,6 +17,7 @@ export async function getRawStockLedgerEntries(fyo: Fyo) {
'name', 'name',
'date', 'date',
'item', 'item',
"batchNumber",
'rate', 'rate',
'quantity', 'quantity',
'location', 'location',
@ -42,7 +43,7 @@ export function getStockLedgerEntries(
const name = safeParseInt(sle.name); const name = safeParseInt(sle.name);
const date = new Date(sle.date); const date = new Date(sle.date);
const rate = safeParseFloat(sle.rate); const rate = safeParseFloat(sle.rate);
const { item, location, quantity, referenceName, referenceType } = sle; const { item, location, batchNumber, quantity, referenceName, referenceType } = sle;
if (quantity === 0) { if (quantity === 0) {
continue; continue;
@ -81,6 +82,7 @@ export function getStockLedgerEntries(
item, item,
location, location,
batchNumber,
quantity, quantity,
balanceQuantity, balanceQuantity,

View File

@ -5,6 +5,7 @@ export interface RawStockLedgerEntry {
date: string; date: string;
item: string; item: string;
rate: string; rate: string;
batchNumber: string;
quantity: number; quantity: number;
location: string; location: string;
referenceName: string; referenceName: string;
@ -20,6 +21,7 @@ export interface ComputedStockLedgerEntry{
item: string; item: string;
location:string; location:string;
batchNumber: string;
quantity: number; quantity: number;
balanceQuantity: number; balanceQuantity: number;

View File

@ -93,9 +93,16 @@
"label": "Stock Not Transferred", "label": "Stock Not Transferred",
"fieldtype": "Float", "fieldtype": "Float",
"readOnly": true "readOnly": true
},
{
"fieldname": "batchNumber",
"label": "Batch No",
"fieldtype": "Data",
"create": true,
"placeholder": "Batch No"
} }
], ],
"tableFields": ["item", "tax", "quantity", "rate", "amount"], "tableFields": ["item", "tax", "quantity", "rate", "amount", "batchNumber"],
"keywordFields": ["item", "tax"], "keywordFields": ["item", "tax"],
"quickEditFields": [ "quickEditFields": [
"item", "item",
@ -110,6 +117,7 @@
"itemDiscountAmount", "itemDiscountAmount",
"itemDiscountPercent", "itemDiscountPercent",
"itemDiscountedTotal", "itemDiscountedTotal",
"itemTaxedTotal" "itemTaxedTotal",
"batchNumber"
] ]
} }

View File

@ -31,6 +31,12 @@
"default": "Unit", "default": "Unit",
"placeholder": "Unit Type" "placeholder": "Unit Type"
}, },
{
"fieldname": "hasBatchNumber",
"label": "Has Batch No",
"fieldtype": "Check",
"default": false
},
{ {
"fieldname": "itemType", "fieldname": "itemType",
"label": "Type", "label": "Type",
@ -116,6 +122,7 @@
"quickEditFields": [ "quickEditFields": [
"rate", "rate",
"unit", "unit",
"hasBatchNumber",
"itemType", "itemType",
"for", "for",
"tax", "tax",

View File

@ -49,6 +49,13 @@
"label": "Ref. Type", "label": "Ref. Type",
"fieldtype": "Data", "fieldtype": "Data",
"readOnly": true "readOnly": true
},
{
"fieldname": "batchNumber",
"label": "Batch No",
"fieldtype": "Data",
"create": true,
"placeholder": "Batch No"
} }
] ]
} }

View File

@ -17,6 +17,11 @@
"target": "Location", "target": "Location",
"required": true "required": true
}, },
{
"fieldname": "batchNumber",
"label": "Batch No",
"fieldtype": "Data"
},
{ {
"fieldname": "quantity", "fieldname": "quantity",
"label": "Quantity", "label": "Quantity",