[taxtxf] compact get-acct-tax-info

This commit is contained in:
Christopher Lam 2019-05-10 19:31:52 +08:00
parent 7345a4adfa
commit 101f840255

View File

@ -298,94 +298,34 @@
(string->symbol (if (string-null? code) "N000" code)))) (string->symbol (if (string-null? code) "N000" code))))
(define (get-acct-txf-info info-type acct-type code) (define (get-acct-txf-info info-type acct-type code)
(let ((tax-entity-type (gnc-get-current-book-tax-type))) (let ((categories (assv-ref
(cond (list (cons ACCT-TYPE-INCOME txf-income-categories)
((= acct-type ACCT-TYPE-INCOME) (cons ACCT-TYPE-EXPENSE txf-expense-categories)
(cond (cons ACCT-TYPE-BANK txf-asset-categories)
((eqv? info-type 'form) (cons ACCT-TYPE-CASH txf-asset-categories)
(gnc:txf-get-form txf-income-categories code tax-entity-type)) (cons ACCT-TYPE-ASSET txf-asset-categories)
((eqv? info-type 'desc) (cons ACCT-TYPE-STOCK txf-asset-categories)
(gnc:txf-get-description txf-income-categories code tax-entity-type)) (cons ACCT-TYPE-MUTUAL txf-asset-categories)
((eqv? info-type 'pns) (cons ACCT-TYPE-RECEIVABLE txf-asset-categories)
(gnc:txf-get-payer-name-source txf-income-categories code (cons ACCT-TYPE-CREDIT txf-liab-eq-categories)
tax-entity-type)) (cons ACCT-TYPE-LIABILITY txf-liab-eq-categories)
((eqv? info-type 'format) (cons ACCT-TYPE-EQUITY txf-liab-eq-categories)
(gnc:txf-get-format txf-income-categories code tax-entity-type)) (cons ACCT-TYPE-PAYABLE txf-liab-eq-categories))
((eqv? info-type 'multiple) acct-type))
(gnc:txf-get-multiple txf-income-categories code tax-entity-type)) (get-info-fn
((eqv? info-type 'cat-key) (case info-type
(gnc:txf-get-category-key txf-income-categories code tax-entity-type)) ((form) gnc:txf-get-form)
((eqv? info-type 'line) ((desc) gnc:txf-get-description)
(gnc:txf-get-line-data txf-income-categories code tax-entity-type)) ((pns) gnc:txf-get-payer-name-sourcecategories)
((eqv? info-type 'last-yr) ((format) gnc:txf-get-formatcategories)
(gnc:txf-get-last-year txf-income-categories code tax-entity-type)) ((multiple) gnc:txf-get-multiplecategories)
(else #f))) ((cat-key) gnc:txf-get-category-keycategories)
((= acct-type ACCT-TYPE-EXPENSE) ((line) gnc:txf-get-line-datacategories)
(cond ((last-yr) gnc:txf-get-last-yearcategories)
((eqv? info-type 'form) (else #f))))
(gnc:txf-get-form txf-expense-categories code tax-entity-type)) (and categories
((eqv? info-type 'desc) get-info-fn
(gnc:txf-get-description txf-expense-categories code tax-entity-type)) (get-info-fn categories code (gnc-get-current-book-tax-type)))))
((eqv? info-type 'pns)
(gnc:txf-get-payer-name-source txf-expense-categories code
tax-entity-type))
((eqv? info-type 'format)
(gnc:txf-get-format txf-expense-categories code tax-entity-type))
((eqv? info-type 'multiple)
(gnc:txf-get-multiple txf-expense-categories code tax-entity-type))
((eqv? info-type 'cat-key)
(gnc:txf-get-category-key txf-expense-categories code tax-entity-type))
((eqv? info-type 'line)
(gnc:txf-get-line-data txf-expense-categories code tax-entity-type))
((eqv? info-type 'last-yr)
(gnc:txf-get-last-year txf-expense-categories code tax-entity-type))
(else #f)))
((or (= acct-type ACCT-TYPE-BANK) (= acct-type ACCT-TYPE-CASH)
(= acct-type ACCT-TYPE-ASSET) (= acct-type ACCT-TYPE-STOCK)
(= acct-type ACCT-TYPE-MUTUAL) (= acct-type ACCT-TYPE-RECEIVABLE))
(cond
((eqv? info-type 'form)
(gnc:txf-get-form txf-asset-categories code tax-entity-type))
((eqv? info-type 'desc)
(gnc:txf-get-description txf-asset-categories code tax-entity-type))
((eqv? info-type 'pns)
(gnc:txf-get-payer-name-source txf-asset-categories code
tax-entity-type))
((eqv? info-type 'format)
(gnc:txf-get-format txf-asset-categories code tax-entity-type))
((eqv? info-type 'multiple)
(gnc:txf-get-multiple txf-asset-categories code tax-entity-type))
((eqv? info-type 'cat-key)
(gnc:txf-get-category-key txf-asset-categories code tax-entity-type))
((eqv? info-type 'line)
(gnc:txf-get-line-data txf-asset-categories code tax-entity-type))
((eqv? info-type 'last-yr)
(gnc:txf-get-last-year txf-asset-categories code tax-entity-type))
(else #f)))
((or (= acct-type ACCT-TYPE-CREDIT) (= acct-type ACCT-TYPE-LIABILITY)
(= acct-type ACCT-TYPE-EQUITY) (= acct-type ACCT-TYPE-PAYABLE))
(cond
((eqv? info-type 'form)
(gnc:txf-get-form txf-liab-eq-categories code tax-entity-type))
((eqv? info-type 'desc)
(gnc:txf-get-description txf-liab-eq-categories code tax-entity-type))
((eqv? info-type 'pns)
(gnc:txf-get-payer-name-source txf-liab-eq-categories code
tax-entity-type))
((eqv? info-type 'format)
(gnc:txf-get-format txf-liab-eq-categories code tax-entity-type))
((eqv? info-type 'multiple)
(gnc:txf-get-multiple txf-liab-eq-categories code tax-entity-type))
((eqv? info-type 'cat-key)
(gnc:txf-get-category-key txf-liab-eq-categories code tax-entity-type))
((eqv? info-type 'line)
(gnc:txf-get-line-data txf-liab-eq-categories code tax-entity-type))
((eqv? info-type 'last-yr)
(gnc:txf-get-last-year txf-liab-eq-categories code tax-entity-type))
(else #f)))
(else #f))
)
)
(define (gnc:account-get-txf-payer-source account) (define (gnc:account-get-txf-payer-source account)
(let ((pns (xaccAccountGetTaxUSPayerNameSource account))) (let ((pns (xaccAccountGetTaxUSPayerNameSource account)))