Ctrl K

AP voucher validation rules

Audience: accountants, consultants, integration vendors
Updated: 2026-11-04
Code: validateRecord in PCE_LIB_AP_Validate.js
Applies to: transaction sublist save, PCE AP invoice save, AP CSV import, and AP Write. UI, CSV, and API share this rule set.
HTML: HTML

A failure blocks the save or write. A tax difference inside the tolerance is a warning only; the save still succeeds. On the API, warnings come back in warnings.

Formats 21 and 25 must first resolve to one format master row via invCatCode or docFormatName. A miss is a lookup error, not one of the field rules below.

These fields are not in this validation: total, file business tax, already filed, source transaction, clientRef.

Traditional Chinese: 進項憑證檢核規則.

1. Document formats

CodeName
21Triplicate GUI (invCatCode 01) / computer GUI (05)
22Duplicate cash-register GUI, and other vouchers that show tax
23Purchase return or allowance for triplicate / computer / triplicate cash-register GUI (line by line)
24Purchase return or allowance for duplicate cash-register GUI and other tax-bearing vouchers (line by line)
25Input triplicate cash-register GUI (06) / general-tax e-invoice (07)
26Summary of input triplicate and computer GUI with tax of 500 or less per document
27Summary of input duplicate cash-register GUI and other tax-bearing vouchers with tax of 500 or less per document
28Customs-collected business tax payment certificate
29Customs refund of overpaid business tax

Document format is required. If it is missing, nothing else is checked. Code DocTypeRequired.

2. Fields checked on every row

FieldRuleCode
Document dateRequiredDocDateRequired
Document periodRequired. If blank, the document date is converted. ROC 5-digit YYYMM (3-digit year + 2-digit month 01–12, e.g. 11508)DocPeriodRequired, DocPeriodFormat
Filing periodRequired. It is not filled in automatically. Same YYYMM formatFilingPeriodRequired, FilingPeriodFormat
Buyer tax IDRequired, 8 digits, checksum must passBuyerTaxIdRequired, BuyerTaxIdLengthNotValid, BuyerTaxIdNotValid
Tax typeRequired. Only 1 taxable, 2 zero-rated, 3 exemptTaxTypeRequired, TaxTypeInvalid
Deduction codeRequired. Taxable may be 1–4. Zero-rated or exempt may only be 3 or 4DeductionCodeRequired, DeductionCodeInvalid

Deduction codes: 1 deductible purchases and expenses, 2 deductible fixed assets, 3 non-deductible purchases and expenses, 4 non-deductible fixed assets.

The tax-type list may also contain F (void) and D (blank / unused). This validation still accepts only 1, 2, and 3.

3. Number fields: required, one-of, or forbidden

A row follows one number path. Filling both, or filling neither when one is required, is rejected.

FormatInvoice no.Other doc no.Utility carrier serialCustoms certificate
21RequiredForbiddenForbiddenForbidden
22, not summarizedOne of invoice no. or other doc no.One of the twoForbiddenForbidden
22, summary (A)ForbiddenRequiredForbiddenForbidden
23RequiredForbiddenForbiddenForbidden
24One of invoice no. or other doc no.One of the twoForbiddenForbidden
25One of invoice no. or carrier serialForbiddenOne of the twoForbidden
26RequiredForbiddenForbiddenForbidden
27One of invoice no. or other doc no.One of the twoForbiddenForbidden
28, 29ForbiddenForbiddenForbiddenRequired

One-of failures: invoice vs other doc is GuiNumberCommonNumberConflict; format 25 invoice vs carrier is GuiNumberUtilityConflict. Forbidden-field codes: GuiNumberMustNotHave, CommonNumberMustNotHave, UtilityCarrierMustNotHave, CustomsAuthCodeMustNotHave. Format 22 summary with an invoice number: GuiNumberMustNotHaveOnSummary. Format 22 summary without an other-doc number: SummaryMarkRequiresOtherDoc.

3.1 Invoice number format, track, and duplicates

When an invoice number is present:

  1. It must be 1–2 uppercase letters plus 8 digits. Zero letters, or lowercase, is rejected. Codes GuiFormatError, GuiTrackRequired.
  2. The track must be on the MOF track table. The period prefers the bi-monthly period of the document date (an odd month rolls forward; 11507 and 11508 are both period 11508). If there is no date, the document period is used. Format 23 is checked against tracks for 21 and 25. Format 24 is checked against tracks for 22. Other formats use their own code. Codes GuiTrackPeriodRequired, GuiTrackDocTypeRequired, GuiTrackNotAllowed.
  3. The number must be unique on the same format master row (the lookup row selected). Format 21 triplicate and format 21 computer GUI are two master rows and do not collide with each other. The search covers active PCE AP invoices (the current record is excluded on edit). If the account has API intake rows, pending and failed rows are included; rejected and posted rows are not. In one API call or one CSV file, a later row also treats a number that already passed validation as a duplicate. Formats 23 and 24 skip the duplicate check. Code GuiNumberDuplicated.

3.2 Other document number

On formats 22, 24, and 27, an other-doc number may not look like an invoice track (leading letters plus 8 digits). Code CommonNumberSimilarToGuiNumber.

3.3 Utility carrier serial

Format 25 only, and only on the carrier path:

  • Length 10. Code UtilityCarrierLength.
  • Must start with BB (the value is uppercased before the check). Code UtilityCarrierPrefix.
  • Must not duplicate an existing AP invoice (the current record is excluded on edit). Code UtilityCarrierDuplicated.

3.4 Customs certificate

Formats 28 and 29 only:

  • Required, length 14. Codes CustomsAuthCodeRequired, CustomsAuthCodeLength.
  • Character 1 may not be blank. Code CustomsAuthCodePos1.
  • Character 3 may not be 1. Code CustomsAuthCodePos3.

4. Seller tax ID

CaseRule
Formats 28, 29Forbidden. Code SellerTaxIdMustNotHave
Summary mark A (including formats 26 and 27, which must be A)Forbidden. Code SellerTaxIdMustNotHave
Formats 21, 23, 25, and not summary ARequired
Formats 22, 24, with an invoice numberRequired

Missing when required: SellerTaxIdRequired. A value must be 8 digits with a valid checksum: SellerTaxIdLengthError, SellerTaxIdValueError.

Format 22 on the other-doc path, without summary A, may leave the seller tax ID blank.

5. Sales amount

After removing decimal points, more than 12 characters is rejected (the minus sign counts). Code SalesAmtLengthError.

CaseRuleCode
Formats 28, 29Required. This field is the business-tax baseTaxBaseRequired
Format 29Must be about tax ÷ 5% (rounded). The difference may not exceed 1TaxBaseNotMatchTaxAmt
Tax type 1, and not 28 or 29Must be greater than 0SalesAmtShouldBeGreaterThanZero

Formats 28 and 29 do not use the “taxable amount must be greater than 0” rule. Zero-rated and exempt rows have no “greater than 0” rule.

6. Tax amount

Tax type 2 or 3: tax must be 0. Code TaxAmtShouldBeZero.

If the tax type is not 1, 2, or 3, the tax formula is skipped (the tax type itself is rejected first).

If format 22, 24, 27, or 25 has not chosen exactly one number path, tax is not checked yet, so the one-of error is not repeated.

When the path is chosen and the tax type is taxable:

CaseRule
22 or 27, with an invoice numberTax must be 0 (sales amount is tax-inclusive). Code TaxAmtShouldBeZero
21, 23, 24, 25Tax must equal sales × 5% (rounded). Format 24 has no “tax 0 means tax-inclusive” path
26, 28, 29The × 5% check is not applied

× 5% difference: 0 passes; 1–5 is a warning and the save still succeeds; more than 5 is rejected. Default path code TaxAmtNotEqual (warning TaxAmtToleranceWarning). The 22/27 other-doc path uses TaxAmtOtherDocInvalid (warning TaxAmtOtherDocToleranceWarning).

6.1 Average tax per summarized document

Formats 26 and 27, when taxable and the summary quantity is greater than 0: average tax per document may not exceed 500. Code SummaryTaxPerDocExceed.

  • Format 26: entered tax ÷ summary quantity.
  • Format 27 with tax 0 (tax-inclusive): implied tax is sales × 5% ÷ 1.05, rounded, then divided by the quantity.
  • Format 27 with non-zero tax: entered tax ÷ quantity.

7. Tax type by format

FormatAllowed tax typesCode
28Taxable (1) or exempt (3) only. Zero-rated is not allowedTaxTypeNotAllowed
29Taxable (1) onlyTaxTypeNotAllowed
Others1, 2, 3TaxTypeInvalid

8. Summary mark and quantity

Summary mark: A summary, B allocation.

RuleCode
Formats 26 and 27 must be summary (A)SummaryMarkMustBeA
Format 22 may not be allocation (B)SummaryMarkShareNotAllowed
Allocation (B) may not have a summary quantity (including format 25)ShareMarkNoSummaryQty
Formats 26 and 27, or formats 22/25 with summary (A): quantity must be a number greater than 1SummaryQtyInvalid

9. Document period and filing period

After both values are valid YYYMM:

FormatRuleCode
23, 24, 29Document period and filing period must fall in the same bi-monthly period. An odd month rolls forward; 11507 and 11508 are both period 11508DocPeriodMustEqualFiling
21, 22, 25, 26, 27, 28Document period may not be later than the filing periodDocPeriodAfterFiling
21, 22, 25, 26, 27, 28Document period may not be more than 120 months (10 years) before the filing period. Exactly 120 months is allowedDeductionPeriodExceed10Years

Formats 23, 24, and 29 do not also run the 10-year check. They are already limited to the same bi-monthly period.

10. Error codes

CodeMeaning
DocTypeRequiredDocument format is required
DocDateRequiredDocument date is required
DocPeriodRequiredDocument period is required
DocPeriodFormatDocument period is not ROC YYYMM
FilingPeriodRequiredFiling period is required
FilingPeriodFormatFiling period is not ROC YYYMM
DocPeriodMustEqualFiling23/24/29 are not in the same bi-monthly period
DocPeriodAfterFilingDocument period is after the filing period
DeductionPeriodExceed10YearsDeduction window exceeds 10 years
BuyerTaxIdRequiredBuyer tax ID is required
BuyerTaxIdLengthNotValidBuyer tax ID is not 8 digits
BuyerTaxIdNotValidBuyer tax ID checksum failed
SellerTaxIdRequiredSeller tax ID is required
SellerTaxIdLengthErrorSeller tax ID is not 8 digits
SellerTaxIdValueErrorSeller tax ID checksum failed
SellerTaxIdMustNotHaveSeller tax ID is not allowed in this case
GuiNumberRequiredInvoice number is required
GuiFormatErrorInvoice number format is invalid
GuiTrackRequiredInvoice number has no track
GuiTrackPeriodRequiredTrack period cannot be determined
GuiTrackDocTypeRequiredDocument format cannot be determined
GuiTrackNotAllowedTrack is not on the MOF table
GuiNumberDuplicatedDuplicate invoice number
GuiNumberMustNotHaveInvoice number is not allowed for this format
GuiNumberMustNotHaveOnSummaryFormat 22 summary may not have an invoice number
GuiNumberCommonNumberConflictInvoice number and other doc no. must be one of the two
GuiNumberUtilityConflictFormat 25 invoice number and carrier serial must be one of the two
CommonNumberMustNotHaveOther doc no. is not allowed for this format
CommonNumberSimilarToGuiNumberOther doc no. looks like an invoice track
SummaryMarkRequiresOtherDocFormat 22 summary requires an other doc no.
UtilityCarrierMustNotHaveCarrier serial is not allowed for this format
UtilityCarrierLengthCarrier serial is not 10 characters
UtilityCarrierPrefixCarrier serial does not start with BB
UtilityCarrierDuplicatedDuplicate carrier serial
CustomsAuthCodeMustNotHaveCustoms certificate is not allowed for this format
CustomsAuthCodeRequiredCustoms certificate is required
CustomsAuthCodeLengthCustoms certificate is not 14 characters
CustomsAuthCodePos1Customs certificate character 1 is blank
CustomsAuthCodePos3Customs certificate character 3 is 1
SalesAmtLengthErrorSales amount is too long
SalesAmtShouldBeGreaterThanZeroTaxable sales amount must be greater than 0
TaxBaseRequiredFormats 28/29 require a tax base
TaxBaseNotMatchTaxAmtFormat 29 tax base does not match the tax
TaxAmtShouldBeZeroTax must be 0
TaxAmtNotEqualTax differs from sales × 5% by more than 5
TaxAmtToleranceWarningTax differs by 1–5 (warning)
TaxAmtOtherDocInvalidOther-doc tax is not valid
TaxAmtOtherDocToleranceWarningOther-doc tax differs by 1–5 (warning)
SummaryTaxPerDocExceedAverage tax per document is over 500
TaxTypeRequiredTax type is required
TaxTypeInvalidTax type is not 1, 2, or 3
TaxTypeNotAllowedTax type is not allowed for format 28/29
DeductionCodeRequiredDeduction code is required
DeductionCodeInvalidDeduction code does not match the tax type
SummaryMarkMustBeAFormats 26/27 must be summary
SummaryMarkShareNotAllowedFormat 22 may not be allocation
ShareMarkNoSummaryQtyAllocation may not have a summary quantity
SummaryQtyInvalidSummary quantity must be greater than 1