Skip to content

Commit

Permalink
[taxtxf] compact get-acct-tax-info
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed May 10, 2019
1 parent 7345a4a commit 101f840
Showing 1 changed file with 28 additions and 88 deletions.
116 changes: 28 additions & 88 deletions gnucash/report/locale-specific/us/taxtxf.scm
Expand Up @@ -298,94 +298,34 @@
(string->symbol (if (string-null? code) "N000" code))))

(define (get-acct-txf-info info-type acct-type code)
(let ((tax-entity-type (gnc-get-current-book-tax-type)))
(cond
((= acct-type ACCT-TYPE-INCOME)
(cond
((eqv? info-type 'form)
(gnc:txf-get-form txf-income-categories code tax-entity-type))
((eqv? info-type 'desc)
(gnc:txf-get-description txf-income-categories code tax-entity-type))
((eqv? info-type 'pns)
(gnc:txf-get-payer-name-source txf-income-categories code
tax-entity-type))
((eqv? info-type 'format)
(gnc:txf-get-format txf-income-categories code tax-entity-type))
((eqv? info-type 'multiple)
(gnc:txf-get-multiple txf-income-categories code tax-entity-type))
((eqv? info-type 'cat-key)
(gnc:txf-get-category-key txf-income-categories code tax-entity-type))
((eqv? info-type 'line)
(gnc:txf-get-line-data txf-income-categories code tax-entity-type))
((eqv? info-type 'last-yr)
(gnc:txf-get-last-year txf-income-categories code tax-entity-type))
(else #f)))
((= acct-type ACCT-TYPE-EXPENSE)
(cond
((eqv? info-type 'form)
(gnc:txf-get-form txf-expense-categories code tax-entity-type))
((eqv? info-type 'desc)
(gnc:txf-get-description txf-expense-categories code tax-entity-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))
)
)
(let ((categories (assv-ref
(list (cons ACCT-TYPE-INCOME txf-income-categories)
(cons ACCT-TYPE-EXPENSE txf-expense-categories)
(cons ACCT-TYPE-BANK txf-asset-categories)
(cons ACCT-TYPE-CASH txf-asset-categories)
(cons ACCT-TYPE-ASSET txf-asset-categories)
(cons ACCT-TYPE-STOCK txf-asset-categories)
(cons ACCT-TYPE-MUTUAL txf-asset-categories)
(cons ACCT-TYPE-RECEIVABLE txf-asset-categories)
(cons ACCT-TYPE-CREDIT txf-liab-eq-categories)
(cons ACCT-TYPE-LIABILITY txf-liab-eq-categories)
(cons ACCT-TYPE-EQUITY txf-liab-eq-categories)
(cons ACCT-TYPE-PAYABLE txf-liab-eq-categories))
acct-type))
(get-info-fn
(case info-type
((form) gnc:txf-get-form)
((desc) gnc:txf-get-description)
((pns) gnc:txf-get-payer-name-sourcecategories)

This comment has been minimized.

Copy link
@gjanssens

gjanssens Jun 12, 2019

Member

@christopherlam I believe this is a copy and paste bug. The added categories in gnc:txf-get-payer-name-sourcecategories and below functions result in unbound variable errors when running the tax reports.

((format) gnc:txf-get-formatcategories)
((multiple) gnc:txf-get-multiplecategories)
((cat-key) gnc:txf-get-category-keycategories)
((line) gnc:txf-get-line-datacategories)
((last-yr) gnc:txf-get-last-yearcategories)
(else #f))))
(and categories
get-info-fn
(get-info-fn categories code (gnc-get-current-book-tax-type)))))

(define (gnc:account-get-txf-payer-source account)
(let ((pns (xaccAccountGetTaxUSPayerNameSource account)))
Expand Down

0 comments on commit 101f840

Please sign in to comment.