Vcl Kra Cuin Checker
Custom Frappe app for Vimit Converters Limited that validates KRA Control Unit Invoice Numbers (CUINs) against the public iTax and eTIMS portals when a Purchase Invoice is being entered in ERPNext.
- Author: tjharia93
- Repository: https://github.com/tjharia93/vcl_kra_cuin_checker
- GitHub stars: 1
- Forks: 0
- License: MIT
- Category: Other
- Maintenance: Actively Maintained
Install Vcl Kra Cuin Checker
bench get-app https://github.com/tjharia93/vcl_kra_cuin_checker
Add the Frappe Gems badge to your README
Maintain Vcl Kra Cuin Checker? Paste this into your README:
[](https://frappegems.com/gems/apps/tjharia93/vcl_kra_cuin_checker)
About Vcl Kra Cuin Checker
VCL KRA Validation
Custom Frappe app for Vimit Converters Limited that validates KRA Control Unit Invoice Numbers (CUINs) against the public iTax and eTIMS portals when a Purchase Invoice is being entered in ERPNext.
What it does
On every Purchase Invoice form, when the user fills in the Supplier Invoice No.
(bill_no) field, the app:
- Calls a whitelisted server method that POSTs the CUIN to
https://itax.kra.go.ke/KRA-Portal/middlewareController.htm?actionCode=fetchInvoiceDtl. - Parses the JSON response from KRA.
- Populates four read-only custom fields on the form:
custom_kra_supplier_name— supplier name as registered with KRAcustom_kra_invoice_number— the supplier's own invoice number (KRA'straderSystemInvNo)custom_kra_tax_amount— VAT amount from KRAcustom_kra_total_amount— grand total from KRA
- Alerts the user (red banner) if the KRA buyer PIN on the invoice is not
Vimit Converters Limited (
P000606160U). - On
validate(before save), warns if the ERPNext-computedgrand_totalortotal_taxes_and_chargesdoes not match the KRA values within KES 1.
Components
vcl_kra_validation/api.py— whitelistedvalidate_cuinmethod.vcl_kra_validation/fixtures/custom_field.json— four custom fields + section/column breaks.vcl_kra_validation/fixtures/client_script.json— the Purchase Invoice client script.vcl_kra_validation/hooks.py— fixture registration.
KRA endpoint notes
- iTax (digit-only CUINs):
https://itax.kra.go.ke/KRA-Portal/middlewareController.htm?actionCode=fetchInvoiceDtl. Public, no login, no API key; a single POST withReferer+X-Requested-Withheaders returns JSON. - eTIMS (slash-containing CUINs, e.g.
KRACU0100065004/379):https://etims.kra.go.ke/common/link/etims/receipt/indexEtimsInvoiceData?Data=. Public HTML page; parsed server-side with regex. Credit notes return signed (negative) amounts which the client compares against the base-currency totals of return Purchase Invoices. validate_cuindispatches on CUIN shape:/-containing → eTIMS, otherwise → iTax. Both return the same response dict shape with an additionalsource: "itax" | "etims"key.
Install on a Frappe Cloud bench
- Push this repo to GitHub (private is fine — add the Frappe Cloud deploy key to the repo's Deploy Keys so the bench can clone).
- In the Frappe Cloud dashboard: Bench Group → Apps → Add App → Install from GitHub → paste the repo URL.
- Deploy the bench group. After deploy, install the app on the
vimitconverters.frappe.cloudsite. - After install, fixtures sync automatically — the four custom fields and the client script appear on Purchase Invoice.
Rollback
If anything goes wrong, uninstall the app from the site. The custom fields are
marked fieldname: custom_kra_* so they are easy to identify and remove. The
client script is named VCL KRA CUIN Validation — delete that record from the
Client Script list to disable immediately without a deploy.
Related Other apps for Frappe & ERPNext
- Erpnext — Free and Open Source Enterprise Resource Planning (ERP)
- Helpdesk — Modern, Streamlined, Free and Open Source Customer Service Software
- Print Designer — Visual print designer for Frappe / ERPNext
- Ctr — CTR模型代码和学习笔记总结
- Whitelabel — Whitelabel ERPNext
- Fossunited — fossunited.org
- Helm — Helm Chart Repository for Frappe/ERPNext
- Frappe Attachments S3 — A frappe app to upload file attachments in doctypes to s3.