Bug #2940
Item Master — add purchasePrice, marginPercent fields + opening stock on creation
Added by Shreya Agarwal about 2 months ago.
Updated about 1 month ago.
Description
Description
Item Master currently has no cost/margin fields and no way to seed starting stock when creating a new item. Add:
purchasePrice (decimal, nullable) — the item's standard/expected purchase rate. Informational for now; intended to eventually pre-fill the rate on a new Purchase Order line (no PO code change in this ticket).
marginPercent (decimal, nullable, 0–100) — markup % over purchasePrice. Stored as a percentage, not a fixed sale price, so it stays valid if purchasePrice changes later.
Opening stock on item creation (new): let the create-item flow optionally seed a starting quantity for a PRODUCT/stockable item, without a separate step. Implementation approach not yet decided — pick one during grooming:
Option A (backend field): add openingStockWarehouseId + openingStockQuantity to the create-item payload; when both are supplied, insert the warehouse stock ledger entry + balance update in the same transaction as the item insert. Only valid for itemType: PRODUCT with isStockable: true.
Option B (no backend change): UI-only — after Item create succeeds, prompt "Add opening stock?" and fire the existing POST /stock-adjustment call if confirmed. Reuses the Stock Adjustment endpoint as-is.
Explicitly out of scope:
salePrice / MRP — not needed until a sales/billing module exists.
Any change to Purchase Order line auto-fill logic.
Open questions for grooming:
Should gstApplicable (boolean, distinct from defaultGstRate, for genuinely tax-exempt items) be bundled into this ticket or split out?
Opening stock: Option A vs Option B above — depends on whether the UI wants this as a single API call or can live with two.
Affected areas: inventory_items table/migration, InventoryItem.cs, ItemDto.cs, ItemRepository.cs, ItemService.cs, PURCHASE_ORDER_INVENTORY_UI_INTEGRATION_GUIDE.md — plus, if Option A is chosen, StockAdjustmentRepository.cs's ledger-insert pattern gets reused inside ItemRepository.CreateItemAsync's transaction.
Acceptance criteria:
Migration adds nullable purchase_price and margin_percent columns to inventory_items (all tenant schemas, idempotent).
POST/PUT /item accept both fields; GET /item/GET /item/{id} return them.
Validation: marginPercent 0–100 if provided; purchasePrice ≥ 0 if provided.
Opening-stock approach decided and implemented per the chosen option above.
UI integration guide updated with all new fields/flows.
Both projects build with 0 errors.
Today, I successfully completed two major features: (Item Master Enhancement) (Item Category Master & Work Order Integration)
Added purchase_price, margin_percent, and opening stock seeding functionality to inventory items.
Added database migration introducing purchase_price and margin_percent columns.
DTO updates, repository with transaction support, service layer validations and audit logging. All CRUD operations were tested and verified - POST creates items with opening stock, PUT updates price and margin successfully, and GET returns all new fields.
Added audit logging for purchase_price and margin_percent fields.
Updated integration documentation (PURCHASE_ORDER_INVENTORY_UI_INTEGRATION_GUIDE.md).
Completed Item Category Master with full CRUD support, category hierarchy management, and validations
Today I worked on the Item Master module and enhanced the Total Cost functionality by adding the TotalCost field to the Item GET API. I also fixed the issue where Purchase Price was not being saved when an opening stock warehouse was not selected by updating the item creation logic to persist purchase_price in the non-opening-stock flow and verifying the database values. Additionally, I updated the Item Master UI so that the Opening Stock Warehouse and Opening Stock Quantity fields are disabled when the Item Type is Service, since opening stock is applicable only to stockable/product items.
implementation of SERVICE item type handling across both Item Master and Stock Adjustment pages.
Added core item fields including Item Type (GOODS/SERVICE), Category, UOM, HSN/SAC Code, and Default GST % to Stock Adjustment pages.
Added new fields including Purchase Price, Margin Percentage, and Opening Stock details to both the main Item form and the Stock Adjustment drawer's quick item creation flow. Adjusted drawer width to 90% for better visibility of all fields. Optimized category and warehouse data fetching by consolidating into a single useEffect. Integrated dynamic form validation and state management for SERVICE vs GOODS item types, ensuring opening stock fields auto-clear and disable when SERVICE is selected.
Continuing to learn React JS and TypeScript for better understanding.
Fixed the response and request binding issue for purchasePrice and marginPercent fields in GET /api/v1/master-data/item and Create/Update endpoints
ALSO Tested by adding new items with various purchase price and margin values.
Today, I continued learning React.js and explored additional concepts to strengthen my understanding. I also started learning Tailwind CSS, along with React components and other related topics. I practiced the concepts and will continue exploring and implementing more React and Tailwind concepts
worked on the firmware management module and added multilingual translations for the related UI labels, descriptions, and file-upload messages. I also updated translations for charger tag combinations and firmware deployment steps and many more . Reviewed the wording to keep the terminology clear and consistent across supported languages.
also tested the item functionality in the dev environment by adding multiple items and checked what error is occurring
Also available in: Atom
PDF