85 lines
6.4 KiB
Plaintext
85 lines
6.4 KiB
Plaintext
Recalculating with Solution Batch Size = 40 Ltr (manual override) instead of the BOM-derived figure:
|
||
|
||
|
||
rf = Batch Size(Ltr) × 1000 / 100 = 40 × 10 = 400
|
||
Original calculation — no Ovg
|
||
|
||
|
||
Qty Req./100 ml = 2.958 gm (straight from BOM)
|
||
Qty Req. (grams) = 2.958 × 400 = 1183.2 gm
|
||
Qty Req. (Kg) = 1183.2 / 1000 = 1.183 Kg
|
||
Ovg. shown = Nil / 0
|
||
With 2% Ovg pre-calculated (setting-driven subtract logic)
|
||
|
||
|
||
1. BOM Qty Req./100 ml = 2.958 gm
|
||
2. Ovg qty (2% of BOM value) = 2.958 × 2/100 = 0.05916 gm
|
||
3. New Qty Req./100 ml = 2.958 − 0.05916 = 2.89884 → 2.899 gm
|
||
4. Ovg. column shown = 2 (pulled from the setting)
|
||
|
||
Qty Req. (grams) = 2.899 × 400 = 1159.6 gm
|
||
Qty Req. (Kg) = 1159.6 / 1000 = 1.16 Kg
|
||
So at 40 Ltr batch size: 1.183 Kg → 1.16 Kg, a reduction of 0.023 Kg (≈2% of the original, as expected).
|
||
|
||
------------------------------+++++++++++++++++++++++++++++
|
||
------------------------------+++++++++++++++++++++++++++++
|
||
------------------------------+++++++++++++++++++++++++++++
|
||
------------------------------+++++++++++++++++++++++++++++
|
||
|
||
"Total Pending Qty" (the per-item cell values, and the totals row) comes from SAP's own live open-order tracking too — same principle as Current Stock: the portal reads a number SAP already maintains, it doesn't compute the pending quantity itself.
|
||
|
||
Source field: each Sales Order line in SAP B1 carries a property called RemainingOpenQuantity (confirmed by testing directly against your SAP instance — not OpenQuantity, which doesn't exist as a real value here). SAP maintains this live: it's the line's original ordered Quantity minus whatever has already been consumed by downstream documents drawn from that line (Deliveries, Invoices) — updated automatically every time a delivery or invoice is posted against that order.
|
||
|
||
What the report does with it (routes/ppc.js):
|
||
|
||
Only fetches orders whose header is still open — DocumentStatus eq 'bost_Open'. A closed header can't have anything pending, so this is a pure efficiency filter (skips scanning years of fully-fulfilled history) — it never excludes a genuinely pending order.
|
||
|
||
Per line, on each order, it only counts a line toward pending qty if both:
|
||
|
||
RemainingOpenQuantity > 0, and
|
||
LineStatus === 'bost_Open'
|
||
(a header can stay "Open" while some of its individual lines are already fully delivered/closed — those specific lines are excluded even though the order as a whole still shows up for its other still-open lines).
|
||
|
||
Per row (= one order), if the same item appears on more than one line within that single order, their RemainingOpenQuantity values are summed into one cell.
|
||
|
||
The "Total Pending Qty" footer row sums that per-row value straight down each item column, across whichever rows are currently visible (respecting your Customer/Product search and Item Group filter).
|
||
|
||
Item Group filter interaction: if you've restricted to certain groups, a line whose item falls outside the allowed group(s) is dropped from the sum entirely — it doesn't appear in that item's column or count toward the total.
|
||
|
||
So in short: Total Pending Qty = Σ RemainingOpenQuantity, across every currently-open Sales Order line for that item that hasn't been fully delivered/invoiced yet — a live figure sourced directly from SAP, filtered to the rows and item groups your report is currently showing.
|
||
|
||
|
||
------------------------------------------------------------------------------------------------------
|
||
------------------------------------------------------------------------------------------------------
|
||
|
||
|
||
"Current Stock" for each item comes straight from SAP's own live inventory figure — no calculation happens in the portal itself. Here's exactly how it's produced:
|
||
|
||
Source field: SAP B1 Service Layer's Items entity has a property called QuantityOnStock on every item master record. This is SAP's own standard, always-current on-hand quantity — the same number you'd see on the item master's "In Stock" field in the SAP B1 client, or via Inventory → Item Master Data.
|
||
|
||
What it represents: it's the sum of "In Stock" across every warehouse that item has activity in — company-wide, not filtered to one warehouse. Internally in SAP, QuantityOnStock is itself a live total that SAP maintains from each warehouse's own stock ledger (OITW.OnHand per warehouse, summed) — every goods receipt, delivery, transfer, and inventory adjustment updates it in real time. The portal just reads this pre-computed value; it doesn't total anything itself.
|
||
|
||
How the report fetches it (routes/ppc.js): when building the pivot table's column list, it already needs each item's name and group anyway — so QuantityOnStock is added to that same batched request:
|
||
|
||
|
||
GET Items?$filter=(ItemCode eq 'A' or ItemCode eq 'B' ...)&$select=ItemCode,ItemName,ItemsGroupCode,QuantityOnStock
|
||
That value is stored as stock alongside each item column and rendered in the "Current Stock" footer row.
|
||
|
||
What it does not include: it's gross on-hand stock, not "available to promise" — it does not subtract SAP's own Committed (quantity already allocated to open sales orders) or add Ordered (incoming on open purchase orders). So a large "Current Stock" number next to a large "Total Pending Qty" doesn't automatically mean the pending orders are already covered — some of that stock may already be committed elsewhere. If you want a true "available to fulfill pending" figure (Stock − Committed, or Stock − Total Pending), let me know and I can add that as its own row.
|
||
|
||
|
||
|
||
-------------------------------------------------------------------------------------------------------------
|
||
-------------------------------------------------------------------------------------------------------------
|
||
|
||
How to pull PPC report data into an external app
|
||
Go to Admin → System Settings → PPC Report → click Generate New Key, then Save. This turns on external access (it's off by default).
|
||
From your external script/app, call:
|
||
|
||
GET https://<your-server>/api/ppc/invoice-report?company=MI-NewDB2&from=YYYY-MM-DD&to=YYYY-MM-DD
|
||
Header: X-API-Key: <the generated key>
|
||
(from/to optional — omit for all open orders. Same filters as the UI: itemGroup, salesType, customerType.)
|
||
It returns the same JSON the report page uses: { success: true, data: { itemCodes: [...], rows: [...] } }.
|
||
There's also GET /api/ppc/item-groups (same auth) if the external app wants the Item Group filter list.
|
||
To revoke access later, clear the key field in Admin and Save.
|
||
This key is separate from any user's login — rotating or clearing it never affects real portal users. |