Documentation
¶
Index ¶
- func IssueWHTCertificatePDF(outputPDF io.Writer, taxInfo TaxInfo, sign io.Reader, logo io.Reader) error
- func LoadImageFromFile(file string) (io.Reader, error)
- func LoadImageFromMultiPartFile(r *http.Request, field string) (io.Reader, error)
- func LoadImageFromRequest(req *http.Request) (io.Reader, error)
- func LoadImageFromURL(url string) (io.Reader, error)
- func ValidateTaxInfo(t TaxInfo) error
- type Anchor
- type Certification
- type DateOfIssuance
- type DocumentDetails
- type ImageField
- type IncomeDetail
- type OtherPayments
- type Payee
- type Payer
- type TaxInfo
- type TextField
- type Totals
- type ValidationError
- type WithholdingType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IssueWHTCertificatePDF ¶
func IssueWHTCertificatePDF(outputPDF io.Writer, taxInfo TaxInfo, sign io.Reader, logo io.Reader) error
IssueWHTCertificatePDF generates a filled WHT certificate PDF.
func LoadImageFromFile ¶
LoadImageFromFile loads a PNG or JPEG image from a local file path.
func LoadImageFromMultiPartFile ¶
LoadImageFromMultiPartFile reads a PNG image uploaded via multipart form. field is the form field name (e.g. "signature").
func LoadImageFromRequest ¶
LoadImageFromRequest fetches a PNG image by executing the given HTTP request. Use this when the image URL requires custom headers such as authentication:
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
req.Header.Set("Authorization", "Bearer "+token)
img, err := pdf50tawi.LoadImageFromRequest(req)
func LoadImageFromURL ¶
LoadImageFromURL fetches a PNG image from the given URL.
func ValidateTaxInfo ¶
ValidateTaxInfo validates all fields in TaxInfo and returns a comprehensive error if any.
Types ¶
type Anchor ¶
type Anchor int
Anchor represents a reference point on a PDF page for positioning text and images.
type Certification ¶
type Certification struct {
DateOfIssuance DateOfIssuance `json:"dateOfIssuance"`
}
type DateOfIssuance ¶
type DocumentDetails ¶
type ImageField ¶
type ImageField struct {
Reader io.Reader
Pos Anchor
Dx float64
Dy float64
Scale float64
Opacity float64
Diagonal int
OnTop bool
}
ImageField defines an image (signature or seal) and its position on the certificate form.
func CertificateImageFields ¶
func CertificateImageFields(sign io.Reader, logo io.Reader) []ImageField
CertificateImageFields returns the positioned image fields for the signature and company seal.
type IncomeDetail ¶
type OtherPayments ¶
type Payee ¶
type Payee struct {
TaxID string `json:"taxId"`
TaxID10Digit string `json:"taxId10Digit"`
Name string `json:"name"`
Address string `json:"address"`
SequenceNumber string `json:"sequenceNumber"`
Pnd_1a bool `json:"pnd_1a"` // ภ.ง.ด. 1ก
Pnd_1aSpecial bool `json:"pnd_1aSpecial"` // ภ.ง.ด. 1ก พิเศษ
Pnd_2 bool `json:"pnd_2"` // ภ.ง.ด. 2
Pnd_3 bool `json:"pnd_3"` // ภ.ง.ด. 3
Pnd_2a bool `json:"pnd_2a"` // ภ.ง.ด. 2ก
Pnd_3a bool `json:"pnd_3a"` // ภ.ง.ด. 3ก
Pnd_53 bool `json:"pnd_53"` // ภ.ง.ด. 53
}
type TaxInfo ¶
type TaxInfo struct {
DocumentDetails DocumentDetails `json:"documentDetails"`
Payer Payer `json:"payer"`
Payee Payee `json:"payee"`
Income40_1 IncomeDetail `json:"income40_1"` // 1. เงินเดือน ค่าจาง เบี้ยเลี้ยง โบนัส ฯลฯ ตามมาตรา 40 (1)
Income40_2 IncomeDetail `json:"income40_2"` // 2. ค่าธรรมเนียม ค่านายหน้า ฯลฯ ตามมาตรา 40 (2)
Income40_3 IncomeDetail `json:"income40_3"` // 3. ค่าแห่งลิขสิทธิ์ ฯลฯ ตามมาตรา 40 (3)
Income40_4A IncomeDetail `json:"income40_4A"` // 4. (ก) ดอกเบี้ย ฯลฯ ตามมาตรา 40 (4) (ก)
// 4. (ข) เงินปันผล เงินส่วนแบ่งกำไร ฯลฯ ตามมาตรา 40 (4) (ข)
// 4. (ข) (1) (1) กรณีผู้ได้รับเงินปันผลได้รับเครดิตภาษี โดยจ่ายจาก
// กำไรสุทธิของกิจการที่ต้องเสียภาษีเงินได้นิติบุคคลในอัตราดังนี้
Income40_4B_1_1 IncomeDetail `json:"income40_4B_1_1"` // 4. (ข) (1) (1.1) อัตราร้อยละ 30 ของกำไรสุทธิ
Income40_4B_1_2 IncomeDetail `json:"income40_4B_1_2"` // 4. (ข) (1) (1.2) อัตราร้อยละ 25 ของกำไรสุทธิ
Income40_4B_1_3 IncomeDetail `json:"income40_4B_1_3"` // 4. (ข) (1) (1.3) อัตราร้อยละ 20 ของกำไรสุทธิ
Income40_4B_1_4_Rate string `json:"income40_4B_1_4_rate"` // 4. (ข) (1) (1.4) อัตราอื่น ๆ (ระบุ)... ของกำไรสุทธิ
Income40_4B_1_4 IncomeDetail `json:"income40_4B_1_4"` // 4. (ข) (1) (1.4)
Income40_4B_2_1 IncomeDetail `json:"income40_4B_2_1"` // 4. (ข) (2) (2.1) กำไรสุทธิของกิจการที่ได้รับยกเว้นภาษีเงินได้นิติบุคคล
Income40_4B_2_2 IncomeDetail `json:"income40_4B_2_2"` // 4. (ข) (2) (2.2) เงินปันผลหรือเงินส่วนแบ่งของกำไรที่ได้รับยกเว้นไม่ต้องนำมารวม คำนวณเป็นรายได้เพื่อเสียภาษีเงินได้นิติบุคคล
Income40_4B_2_3 IncomeDetail `json:"income40_4B_2_3"` // 4. (ข) (2) (2.3) กำไรสุทธิส่วนที่ได้หักผลขาดทุนสุทธิยกมาไม่เกิน 5 ปี ก่อนรอบระยะเวลาบัญชีปีปัจจุบัน
Income40_4B_2_4 IncomeDetail `json:"income40_4B_2_4"` // 4. (ข) (2) (2.4) กำไรที่รับรู้ทางบัญชีโดยวิธีส่วนได้เสีย (equity method)
Income40_4B_2_5_Note string `json:"income40_4B_2_5_note"` // 4. (ข) (2) (2.5) อื่น ๆ (ระบุ)... ของกำไรสุทธิ
Income40_4B_2_5 IncomeDetail `json:"income40_4B_2_5"` // 4. (ข) (2) (2.5)
Income5 IncomeDetail `json:"income5"` // 5. การจ่ายเงินได้ที่ต้องหักภาษี ณ ที่จ่าย
Income6 IncomeDetail `json:"income6"` // 6. อื่น ๆ (ระบุ)
Income6_Note string `json:"income6_note"` // 6. อื่น ๆ (ระบุ)
Totals Totals `json:"totals"` // รวมเงิน
OtherPayments OtherPayments `json:"otherPayments"` // จ่ายภาษี
WithholdingType WithholdingType `json:"withholdingType"` // ประเภทการหักภาษี
Certification Certification `json:"certification"` // การยืนยัน
}
type TextField ¶
type TextField struct {
Text string
Dx float64
Dy float64
FontSize int
FontName string
Position Anchor
}
TextField defines a text value and its position on the certificate form.
func TextFieldsFromTaxInfo ¶
TextFieldsFromTaxInfo converts TaxInfo into the complete set of TextField values to be rendered on the certificate form.
type ValidationError ¶
type ValidationError struct {
Errors []string
}
func (*ValidationError) Add ¶
func (v *ValidationError) Add(msg string)
func (*ValidationError) Error ¶
func (v *ValidationError) Error() string
func (*ValidationError) HasErrors ¶
func (v *ValidationError) HasErrors() bool