The Commodity Financing module enables commodity financing (cars, laptops, etc.) for employees of an organization under a Shariah-compliant murabahah scheme. Two controllers are involved: CommodityFinancingController at /commodity-financings (employee CRUD + sign agreement) and AdminCommodityFinancingController (summary, approve/reject, admin withdraw). The status lifecycle follows a state machine: pending → under_review → legal_agreement → signed → active → completed (with branches for rejected/cancelled). Architecture B: a per-financing holding account is created automatically by the service and owned by the organization — the borrower has no direct claim on the holding account.
Property
Value
Base URL
{HOST}/v1
Auth
Bearer JWT (header Authorization) or cookie access_token
An employee (INDIVIDUAL) submits an application via POST /commodity-financings; organization/MORIA admins can also create one on behalf of the employee (the body uses AdminCreateCommodityFinancingDto). The admin then approves/rejects via PATCH /commodity-financings/:id/approve; after approval, the employee signs the legal agreement via POST /commodity-financings/:id/sign. Auto-deduction then runs from the employee’s source pocket. Admins can withdraw funds from the holding account to forward them to the destination org account.
Method
Path
Auth
Summary
POST
/v1/commodity-financings
bearer
Create a commodity financing (employee or admin-for-employee)
POST
/v1/commodity-financings/:financing_id/sign
bearer
Employee signs the legal agreement
GET
/v1/commodity-financings
bearer
Paginated list with status/user/account filters
GET
/v1/commodity-financings/:financing_id
bearer
Detail of a single financing (response differs for mobile vs web)
PATCH
/v1/commodity-financings/:financing_id
bearer
Update financing parameters (except those already completed)
DELETE
/v1/commodity-financings/:financing_id
bearer
Soft-delete a financing
GET
/v1/summary/commodity-financings
bearer
Organization statistics summary (admin only)
PATCH
/v1/commodity-financings/:financing_id/approve
bearer
Admin approves/rejects an application
POST
/v1/commodity-financings/:financing_id/withdraw
bearer
Admin withdraws from the holding account to the destination org account
Create a commodity financing application. If the caller is INDIVIDUAL, the body uses CreateCommodityFinancingDto. If MORIA/ORGANIZATION admin, the body uses AdminCreateCommodityFinancingDto (with a user_id field). The service decides the path based on user.user_type.
bearercreate-commodity-financingRESOURCE_CREATED
Request body — CreateCommodityFinancingDto (employee)
Paginated list of financings. INDIVIDUAL only sees their own; ORGANIZATION admin sees all within the org; MORIA is unrestricted. The user_id/account_id filters are validated against the caller’s scope — sending an ID outside the scope → 403.
Detail of a single financing. Response differs based on the client (header x-client-type): MOBILE gets member_contributions via the with-summary variant; WEB gets the formatted variant.
Aggregate commodity financing statistics for the caller’s organization. Only admins (MORIA/ORGANIZATION) are allowed. Useful for analytics dashboards (totals, status breakdowns, averages).
Admin approves or rejects an application. Sets a new status + (optional) approved_installment_amount + requested_installment_period. Valid statuses: legal_agreement for approve, rejected/cancelled for reject.
Admin withdraws funds from the per-financing holding account to the destination org account. Architecture B: only org admins have access to the holding account; the borrower has no claim. Used to forward funds to a vendor / supplier.