FPSMS-frontend
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GRN_REPORT_BACKEND_SPEC.md 2.4 KiB

2 weeks ago
2 weeks ago
2 weeks ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # GRN Report – Backend API Spec
  2. The frontend **GRN/入倉明細報告** report calls the following endpoint. The backend must implement it to return JSON (not PDF).
  3. ## Endpoint
  4. - **Method:** `GET`
  5. - **Path:** `/report/grn-report`
  6. - **Query parameters (all optional):**
  7. - `receiptDateStart` – date (e.g. `yyyy-MM-dd`), filter receipt date from
  8. - `receiptDateEnd` – date (e.g. `yyyy-MM-dd`), filter receipt date to
  9. - `itemCode` – string, filter by item code (partial match if desired)
  10. ## Response
  11. - **Content-Type:** `application/json`
  12. - **Body:** Either an array of row objects, or an object with a `rows` array:
  13. ```json
  14. {
  15. "rows": [
  16. {
  17. "poCode": "PO-2025-001",
  18. "deliveryNoteNo": "DN-12345",
  19. "receiptDate": "2025-03-15",
  20. "itemCode": "MAT-001",
  21. "itemName": "Raw Material A",
  22. "acceptedQty": 100,
  23. "receivedQty": 100,
  24. "demandQty": 120,
  25. "uom": "KG",
  26. "purchaseUomDesc": "Kilogram",
  27. "stockUomDesc": "KG",
  28. "productLotNo": "LOT-001",
  29. "expiryDate": "2026-03-01",
  30. "supplierCode": "P06",
  31. "supplier": "Supplier Name",
  32. "status": "completed",
  33. "grnCode": "PPP004GRN26030298",
  34. "grnId": 7854617
  35. }
  36. ]
  37. }
  38. ```
  39. Or a direct array:
  40. ```json
  41. [
  42. { "poCode": "PO-2025-001", "deliveryNoteNo": "DN-12345", ... }
  43. ]
  44. ```
  45. ## Suggested backend implementation
  46. - Use data that “generates the GRN” (Goods Received Note): e.g. **stock-in lines** (or equivalent) linked to **PO** and **delivery note**.
  47. - Filter by:
  48. - `receiptDate` (or equivalent) between `receiptDateStart` and `receiptDateEnd` when provided.
  49. - `itemCode` when provided.
  50. - Return one row per GRN line with at least: **PO/delivery note no.**, **itemCode**, **itemName**, **qty** (e.g. `acceptedQty`), **uom**, and optionally receipt date, lot, expiry, supplier, status.
  51. Frontend builds the Excel from this JSON. Columns include: PO No., Delivery Note No., Receipt Date, Item Code, Item Name, Qty, Demand Qty, UOM, Supplier Lot No. 供應商批次, Expiry Date, Supplier Code, Supplier, 入倉狀態, **GRN Code** (`m18_goods_receipt_note_log.grn_code`), **GRN Id** (`m18_record_id`).
  52. ## Frontend Excel styling (shared standard)
  53. Header colours, number formats (`#,##0.00` for amounts), and column alignment are defined in:
  54. **[`../chart/_components/EXCEL_EXPORT_STANDARD.md`](../chart/_components/EXCEL_EXPORT_STANDARD.md)**
  55. Use that document when adding or changing Excel exports so formatting stays consistent.