Project

General

Profile

Bug #2940

Item Master — add purchasePrice, marginPercent fields + opening stock on creation

Added by Shreya Agarwal about 2 hours ago.

Status:
New
Priority:
Normal
Start date:
08/06/2026
Due date:
% Done:

0%

Estimated time:

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.

No data to display

Also available in: Atom PDF