update readme

This commit is contained in:
2026-07-22 14:15:44 +07:00
parent a008204865
commit 796fa04a37

108
README.md
View File

@@ -1,14 +1,106 @@
# be-accone
## Generate payment instruction cicilan
### curl command
`
Backend service for Accone.
---
## Generate Monthly Installments (Cicilan Aset)
Automatically creates `supplier_installment` rows for all eligible active contracts every month. This is designed to be executed via **CRON daily at 1:00 AM**.
> **Note:** No journal entries are created here — that happens at cashier payment time. The contract's `InstallmentPaid` field is also **not** updated here — it's updated when payment is received.
### Endpoint
```
POST /one-api/mockup/scheduler/PurchaseInvoiceInstallment/GenerateMonthlyInvoices
```
### Request
| Field | Value |
|---------------|--------------------|
| **Method** | `POST` |
| **Content-Type** | `application/json` |
| **Body** | `{}` (optional `startDate` / `endDate`) |
```bash
curl -s -X POST "https://accone.aplikasi.web.id/one-api/mockup/scheduler/PurchaseInvoiceInstallment/GenerateMonthlyInvoices" \
-H "Content-Type: application/json" \
-d '{}'
`
```
### response
`
{"status":"OK","data":{"startDate":"2026-07-01","endDate":"2026-07-31","totalEligible":1,"totalInserted":1,"created":[{"installmentID":6,"contractID":"11","purchaseOrderID":"20","parentInvoiceID":"16","parentInvoiceNumber":"PI-016\/SDM-14\/SM-1\/VII\/2026","amount":5000000,"installDate":"2026-07-22","dueDate":"2026-07-29"}]}}
`
**Optional body parameters:**
```json
{
"startDate": "2026-07-01",
"endDate": "2026-07-31"
}
```
If omitted, defaults to the current month (`startDate` = first day, `endDate` = last day).
### Eligibility Logic (Steps 15)
A contract is eligible for installment generation only if **all** of the following conditions are met:
| Step | Condition |
|------|-----------|
| **1** | Contract is **active** (`IsActive = 'Y'`), status is **"belum lunas"**, has a positive `InstallmentPayAmount`, `InstallmentPaid < InstallmentNumber`, falls within the date range, and the scheduled day of month has been reached |
| **2** | Associated **Purchase Order** is **Approved** and **Active** |
| **3** | Associated **Receive Order** is **Confirmed** and **Active** |
| **4** | A parent **Supplier Invoice** exists with `IsInstallment = 'Y'` |
| **5** | No `supplier_installment` record already exists for the same PO in the same month |
### Step 6 — Insert
For each eligible contract, a row is inserted into `supplier_installment` with:
- `SupplierInstallmentStatus` = `"Pending"`
- `SupplierInstallmentIsLunas` = `"N"`
- `SupplierInstallmentDate` = the contract's scheduled day of month (capped to the last day of the month)
- `SupplierInstallmentDueDate` = same as InstallmentDate, can be changed at payment instrutions manu
### Response
```json
{
"status": "OK",
"data": {
"startDate": "2026-07-01",
"endDate": "2026-07-31",
"totalEligible": 1,
"totalInserted": 1,
"created": [
{
"installmentID": 6,
"contractID": "11",
"purchaseOrderID": "20",
"parentInvoiceID": "16",
"parentInvoiceNumber": "PI-016/SDM-14/SM-1/VII/2026",
"amount": 5000000,
"installDate": "2026-07-22",
"dueDate": "2026-07-22"
}
]
}
}
```
| Field | Type | Description |
|-------|------|-------------|
| `status` | `string` | `"OK"` on success |
| `data.startDate` | `string` | Start of the billing period (`YYYY-MM-DD`) |
| `data.endDate` | `string` | End of the billing period (`YYYY-MM-DD`) |
| `data.totalEligible` | `number` | Total contracts that passed eligibility |
| `data.totalInserted` | `number` | Total installments successfully created |
| `data.created` | `array` | List of generated installment records |
| `data.created[].installmentID` | `number` | ID of the created `supplier_installment` row |
| `data.created[].contractID` | `string` | Associated contract ID (`PurchaseOrderAssetContract`) |
| `data.created[].purchaseOrderID` | `string` | Associated purchase order ID |
| `data.created[].parentInvoiceID` | `string` | Source supplier invoice ID |
| `data.created[].parentInvoiceNumber` | `string` | Source supplier invoice number |
| `data.created[].amount` | `number` | Installment amount (IDR) |
| `data.created[].installDate` | `string` | Date the installment is issued |
| `data.created[].dueDate` | `string` | Payment due date (`installDate + 7 days`) |