Customization

Customizing totals section

You can customize how document-level discounts and charges appear on the final invoice PDF. You would pass such configurations in the template.config key for the Report Invoice API.

The example below demonstrates how to add Retention and Other Deductions as additional lines after the invoice total.

Example: Retention and Other Deductions

  • We pass two discountlines to the document: one for "Retention" and another for "Other Deductions". Retention has a discount reason 45 ( Pro-rata Retention), and Other Deductions has a discount reason of 57(Miscellaneous charges). Both are out of scope for VAT, so we pass an exemption_reason as well.
  • In template.config, we define the labels we'd like to display for each reason code.

Example payload

{
    "language": "en",
    "document": {
        // your invoice payload
        "discounts": [
            {
                "amount": 50, // retention amount goes here
                "reason": "45",
                "tax": {
                    "type": "O",
                    "percent": 0,
                    "exemption_reason": "VATEX-SA-OOS"
                }
            },
            {
                "amount": 50, // other deductions go here
                "reason": "57",
                "tax": {
                    "type": "O",
                    "percent": 0,
                    "exemption_reason": "VATEX-SA-OOS"
                }
            }
        ]
    },
    "template": {
        "config": {
            "discounts": [
                {
                    "reason_codes": [
                        "57"
                    ],
                    "labels": {
                        "en": "Other deductions",
                        "ar": "خصم آخر"
                    }
                },
                {
                    "reason_codes": [
                        "45",
                        "46",
                        "47"
                    ],
                    "labels": {
                        "en": "Retention",
                        "ar": "خصم حجوزات حسن التنفيذ"
                    }
                }
            ]
        }
    }
}

The totals section of the resulting PDF would look like this:

Using your own template

If Wafeq's standard PDF layout doesn't meet your requirements, you can simply retrieve the QR code from the Report Invoice endpoint response and display it on your own invoice template.