Miracle ERP Integration

Website ↔ ERP — live gateway console

Variant:

What this shows

Live read-only checks for Miracle branches, stores, products, item inventory, customers, and orders. The frontend calls this backend on the same host; the backend authenticates to the live Miracle gateway and keeps the token server-side.

Scenario walkthrough

  1. Register customer Ahmed Ali
  2. Check stock for SKU-001 (starts at 10 / 0)
  3. Create an order for 4 × SKU-001
  4. CS team confirms the order (Pro only)
  5. Re-check stock — reserved should now show 4
  6. Convert to invoice — available drops to 6
  7. Confirm reserved is back to 0

Live gateway reference

Captured from the real Miracle Pro browser session for read-only testing.

Authentication
POST https://internalgateway.elaggar.com/gateway/identity/api/Account/Login
Content-Type: application/json

{
  "username": "mina",
  "password": "123456",
  "language": "ar"
}

Use returned token:
Authorization: Bearer <token>
Accept-Language: en
Content-Type: application/json
Branches
POST https://internalgateway.elaggar.com/gateway/miracleIntegration/api/Branch

{
  "sortBy": "Code",
  "reverse": true,
  "search": "",
  "searchKeys": [
    { "key": "Code", "op": "==", "type": "Number" },
    { "key": "Name", "op": "Contains", "type": "String" }
  ],
  "itemsPerPage": 10,
  "page": 1,
  "filters": { "basicFilters": [], "rangeFilters": [] }
}

Live samples:
[
  { "id": 40, "code": 40, "name": "" },
  { "id": 39, "code": 39, "name": "" },
  { "id": 38, "code": 38, "name": "" }
]
Stores and Warehouse Inventory
POST https://internalgateway.elaggar.com/gateway/StockManagement/api/StoresCodes/getPaged

Live store samples:
[
  { "id": 45, "code": 46, "name": "46", "store1Name": "مجموعه اولي (للمخازن) افتراضي" },
  { "id": 44, "code": 45, "name": "45", "store1Name": "معارض" },
  { "id": 43, "code": 44, "name": "44", "store1Name": "معارض" }
]

POST https://internalgateway.elaggar.com/gateway/StockManagement/api/WarehouseInventoryReport/StockItems

Selected stores filter:
{ "key": "StoreId", "value": "44,45", "op": "In", "type": "Number" }

Live stock samples:
[
  { "itemCode": "1757013jk", "storeId": 44, "mastCode": 45, "mastName": "45", "wholeQuantity": 16, "reservedQuantity": null },
  { "itemCode": "1757013ro1", "storeId": 44, "mastCode": 45, "mastName": "45", "wholeQuantity": 8, "reservedQuantity": null }
]
Single Item Across Stores
Use ItemCode = 300101:
{ "key": "ItemCode", "value": "300101", "op": "==", "type": "String" }

Live aggregate sample:
{
  "itemCode": "300101",
  "itemId": 1570,
  "wholeQuantity": 315157300,
  "qty": 315157300,
  "reservedQuantity": null
}

Store-level detail:
POST https://internalgateway.elaggar.com/gateway/StockManagement/api/WarehouseInventoryReport/getDetailsWithItemIdAndColoCode

{
  "StoresId": [44, 45],
  "ItemId": 1570,
  "ReportLevel": 1,
  "GroupingProperties": [],
  "Colo_code": null,
  "Colo_code2": null,
  "ColoId": null,
  "Colo2Id": null,
  "IsIncludeStoresWithNoStock": false,
  "PriceId": 0
}

Live detail samples:
[
  { "itemCode": "300101", "mastCode": 4, "mastName": "4", "wholeQuantity": 12500000 },
  { "itemCode": "300101", "mastCode": 10, "mastName": "10", "wholeQuantity": 31705000 },
  { "itemCode": "300101", "mastCode": 16, "mastName": "16", "wholeQuantity": 12058500 }
]

Website service surface

One-way calls: the website reads data or submits requests to Miracle ERP.

Add OrderPOST /miracle/order
Cancel OrderDELETE /miracle/order/:id
Get StockGET /miracle/inventory/:itemCode?storeIds=44,45
Get Product DetailsGET /miracle/inventory/products/:productCode
Add CustomerPOST /miracle/customer

① Customer

Register a new customer. Idempotent — if Miracle already has this phone, returns the existing code instead of duplicating.

② Inventory

Real-time available + reserved per the brief. Available stays high until invoicing; reserved tracks open orders.

Available
Reserved
Sellable

③ Order

Create → (confirm for Pro) → invoice or cancel. Reservation timing matches the active variant.

Live checks

Editable batches for stock, customer lookups, and order reads.

Product details

Item inventory list

Stock items

Customers

Orders

Activity log