feat: implement business pricing service and money utilities

- Added `businessPricing.service.js` to handle business customer pricing logic.
- Introduced `money.js` for money parsing, formatting, and calculations.
- Created `pricing.service.js` to manage variant quoting and promotion application.
- Updated validation schemas in `catalogue.schemas.js` and `inventoryMerchandising.schemas.js` for new pricing and inventory features.
- Implemented cron job for inventory reservation expiry in `inventoryReservationExpiry.cron.js`.
- Created database migrations for catalogue and inventory structures.
- Added unit tests for catalogue localization, validation, and inventory merchandising functionalities.
This commit is contained in:
Sathira Sri Sathara
2026-09-03 19:25:13 +05:30
parent fd4e324571
commit 5643d89236
75 changed files with 663 additions and 1 deletions
@@ -0,0 +1,2 @@
const money=require("../../app/services/pricing/money");const inventory=require("../../app/services/inventory/inventory.service");
describe("Phase 5 decimal and availability rules",()=>{test("money remains integer-scaled and floors discounts at zero",()=>{expect(money.parse("900.05")).toBe(90005n);expect(money.percentOff("1000.00","12.50")).toBe("125.00");expect(money.subtractFloor("5.00","10.00")).toBe("0.00");});test.each([[{on_hand:10,reserved:1,low_stock_threshold:2},"IN_STOCK"],[{on_hand:3,reserved:1,low_stock_threshold:2},"LOW_STOCK"],[{on_hand:3,reserved:3,low_stock_threshold:2},"OUT_OF_STOCK"]])("availability projection",(balance,status)=>expect(inventory.availabilityStatus(balance)).toBe(status));test("reservation TTL is centralized",()=>expect(inventory.ttlMinutes()).toBeGreaterThan(0));});