fix: certificate button only on paid Purchase Invoices

The certificate is issued when the tax is withheld, i.e. on payment;
show the button once the submitted invoice's status is Paid.
This commit is contained in:
2026-09-22 03:58:04 +00:00
parent 2ee381f369
commit baff8de0d3
3 changed files with 4 additions and 18 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ without a Thai system font. Switch a user or the print language to `th` to use i
### Withholding tax certificate
A Purchase Invoice with *Apply Tax Withholding Amount* gets a **Withholding Tax Certificate**
A paid Purchase Invoice with *Apply Tax Withholding Amount* gets a **Withholding Tax Certificate**
button that downloads the Revenue Department's Sec. 50 bis form (หนังสือรับรองการหักภาษี ณ ที่จ่าย,
two copies) as a PDF: the *Withholding Tax Certificate* print format lays the invoice's data
over the official form (`public/images`). The row the payment is reported on comes from
@@ -1,23 +1,10 @@
frappe.ui.form.on("Purchase Invoice", {
refresh(frm) {
frm.events.toggle_withholding_certificate(frm);
},
apply_tds(frm) {
frm.events.toggle_withholding_certificate(frm);
},
toggle_withholding_certificate(frm) {
const label = __("Withholding Tax Certificate");
frm.remove_custom_button(label);
if (!frm.doc.apply_tds || frm.is_new() || frm.doc.docstatus === 2) return;
// The certificate is issued once the tax has been withheld, i.e. on payment.
if (!frm.doc.apply_tds || frm.doc.docstatus !== 1 || frm.doc.status !== "Paid") return;
// The Withholding Tax Certificate print format renders the Revenue Department's
// Sec. 50 bis form (fixtures/print_format.json) as a PDF.
frm.add_custom_button(label, () => {
if (frm.is_dirty()) {
frappe.msgprint(__("Please save the document before generating the certificate."));
return;
}
frm.add_custom_button(__("Withholding Tax Certificate"), () => {
const params = new URLSearchParams({
doctype: frm.doctype,
name: frm.docname,
-1
View File
@@ -61,7 +61,6 @@ Withholding Tax Receivable,ภาษีถูกหัก ณ ที่จ่า
Output VAT,ภาษีขาย
Input VAT,ภาษีซื้อ
Withholding Tax Certificate,หนังสือรับรองการหักภาษี ณ ที่จ่าย
Please save the document before generating the certificate.,กรุณาบันทึกเอกสารก่อนออกหนังสือรับรองการหักภาษี ณ ที่จ่าย
Type of Income Paid,ประเภทเงินได้พึงประเมินที่จ่าย
Salary and Wages - Sec. 40(1),เงินเดือน ค่าจ้าง ฯลฯ ตามมาตรา 40(1)
Fees and Commissions - Sec. 40(2),ค่าธรรมเนียม ค่านายหน้า ฯลฯ ตามมาตรา 40(2)
1 Net Payable After Withholding Tax ยอดชำระสุทธิหลังหักภาษี ณ ที่จ่าย
61 Output VAT ภาษีขาย
62 Input VAT ภาษีซื้อ
63 Withholding Tax Certificate หนังสือรับรองการหักภาษี ณ ที่จ่าย
Please save the document before generating the certificate. กรุณาบันทึกเอกสารก่อนออกหนังสือรับรองการหักภาษี ณ ที่จ่าย
64 Type of Income Paid ประเภทเงินได้พึงประเมินที่จ่าย
65 Salary and Wages - Sec. 40(1) เงินเดือน ค่าจ้าง ฯลฯ ตามมาตรา 40(1)
66 Fees and Commissions - Sec. 40(2) ค่าธรรมเนียม ค่านายหน้า ฯลฯ ตามมาตรา 40(2)