Invoice Blocking API Testing

API-OVERDUE-001: Validate Sales Order Creation is Blocked due to Overdue Invoice

1
2
POST /api/sales-order/create
Authorization: Bearer <token>

Request Body

1
2
3
4
5
6
7
8
9
10
11
12
13
{
  "customerId": "CUST-DEMO-078",
  "outletId": "OUTLET-001",
  "items": [
    {
      "productCode": "PROD-001",
      "quantity": 10,
      "unitPrice": 750000
    }
  ],
  "orderDate": "2026-06-29",
  "deliveryDate": "2026-07-05"
}

Expected Response (Blocked)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
  "success": false,
  "statusCode": 403,
  "message": "Sales Order cannot be created. Customer has outstanding overdue invoice.",
  "errorCode": "OVERDUE_INVOICE_BLOCK",
  "details": {
    "overdueInvoices": [
      {
        "invoiceId": "INV-20260625-001",
        "dueDate": "2026-06-28",
        "outstandingAmount": 3500000,
        "daysOverdue": 1
      }
    ]
  }
}

API-OVERDUE-002: Validate Sales Order Creation is Allowed after Payment

1
POST /api/sales-order/create

Request Body

1
2
3
4
5
6
{
  "customerId": "CUST-DEMO-078",
  "items": [
    { "productCode": "PROD-001", "quantity": 5 }
  ]
}

Expected Response

1
2
3
4
5
6
7
8
{
  "success": true,
  "statusCode": 201,
  "orderId": "SO-20260629-0045",
  "status": "SUBMITTED",
  "message": "Sales Order created successfully",
  "totalAmount": 3750000
}

API-OVERDUE-003: Check Customer Order Eligibility

1
GET /api/customer/CUST-DEMO-078/eligibility

Expected Response (Blocked)

1
2
3
4
5
6
7
8
{
  "customerId": "CUST-DEMO-078",
  "isEligibleForOrder": false,
  "blockingReason": "OVERDUE_INVOICE",
  "overdueInvoiceCount": 1,
  "oldestOverdueDate": "2026-06-28",
  "totalOutstandingOverdue": 3500000
}

Expected Response (Eligible)

1
2
3
4
5
6
{
  "customerId": "CUST-DEMO-078",
  "isEligibleForOrder": true,
  "blockingReason": null,
  "overdueInvoiceCount": 0
}

API-OVERDUE-004: Apply Payment and Recalculate Eligibility

1
POST /api/payment/apply

Request Body

1
2
3
4
5
6
7
{
  "invoiceId": "INV-20260625-001",
  "customerId": "CUST-DEMO-078",
  "amountPaid": 3500000,
  "paymentDate": "2026-06-29",
  "paymentMethod": "CASH"
}

Expected Response

1
2
3
4
5
6
7
{
  "success": true,
  "message": "Payment applied successfully",
  "updatedEligibility": {
    "isEligibleForOrder": true
  }
}

Coverage Matrix

Test Case Endpoint Method Focus
SO Creation - Blocked /api/sales-order/create POST Overdue validation
SO Creation - Allowed /api/sales-order/create POST After payment
Customer Eligibility /api/customer/{id}/eligibility GET Real-time status
Apply Payment /api/payment/apply POST Eligibility recalculation

Back to Project