From 6342414fda8f87f5a40dc9904ce110620a53c74b Mon Sep 17 00:00:00 2001 From: Dave Peticolas Date: Fri, 23 Mar 2001 12:43:08 +0000 Subject: [PATCH] * src/scm/html-utilities.scm (gnc:assign-colors): make the order of color assignment stable * src/engine/Account.c: add api for tax info * src/engine/kvp_frame.c: handle NULL pointers * src/engine/kvp_doc.txt: add tax kvp keys * doc/gnucash-gdb-cmds: remove, out of date and misc. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3827 57a11ea4-9604-0410-9ed3-97b8803252fd --- AUTHORS | 4 +- ChangeLog | 13 +++ doc/Makefile.am | 3 +- doc/gnucash-gdb-cmds | 20 ----- doc/sgml/C/xacc-about.sgml | 2 +- src/engine/Account.c | 71 ++++++++++++++++ src/engine/Account.h | 6 ++ src/engine/kvp_doc.txt | 10 +++ src/engine/kvp_frame.c | 21 ++++- src/scm/html-utilities.scm | 12 +-- src/scm/report/taxtxf.scm | 127 ++++++++--------------------- src/scm/report/txf-export-help.scm | 1 - src/scm/report/txf-export.scm | 7 +- 13 files changed, 169 insertions(+), 128 deletions(-) delete mode 100644 doc/gnucash-gdb-cmds diff --git a/AUTHORS b/AUTHORS index b37a719c98..7e4b243d7d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -41,7 +41,7 @@ Fixes & Patches: Andrew Arensburger for FreeBSD & other patches Matt Armstrong for misc fixes -Derek Atkins build system patch +Derek Atkins build system patch, rpc backend Fred Baube for attempted Java port/MoneyDance Dennis Björklund Swedish translation Per Bojsen several core dump fixes @@ -98,7 +98,7 @@ Juan Manuel Garc Christopher Molnar build system patch Tim Mooney port to alpha-dec-osf4.0f G. Allen Morris III for QIF core dump -James LewisMoss design doc patches +James LewisMoss design doc patches, xml, test suite Steven Murdoch gnc-prices fix for London exchange Brent Neal TIAA-CREF support. Johnny Ernst Nielsen Danish translation diff --git a/ChangeLog b/ChangeLog index 3b944120f8..8a8a182d04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2001-03-23 Dave Peticolas + + * src/scm/html-utilities.scm (gnc:assign-colors): make the order + of color assignment stable + + * src/engine/Account.c: add api for tax info + + * src/engine/kvp_frame.c: handle NULL pointers + + * src/engine/kvp_doc.txt: add tax kvp keys + + * doc/gnucash-gdb-cmds: remove, out of date + 2001-03-23 Christian Stimming * src/scm/report/income-or-expense-pie.scm: Included new option to diff --git a/doc/Makefile.am b/doc/Makefile.am index ee541b31c6..6fb2a580a2 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -28,5 +28,4 @@ EXTRA_DIST = \ build-suse.txt \ gnome-hackers.txt \ gnc-prices.1 \ - gnucash.1 \ - gnucash-gdb-cmds + gnucash.1 diff --git a/doc/gnucash-gdb-cmds b/doc/gnucash-gdb-cmds deleted file mode 100644 index 75b213595f..0000000000 --- a/doc/gnucash-gdb-cmds +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/gdb -x -# You can debug gnucash by running gdb as "gdb -x gnucash.gdb-cmds" -# and then executing "run-gnucash somefile". -# -# Secrets: gdb requires that parens be escaped as well as quotes ... - -file gnucash.bin - -set env GNC_BOOTSTRAP_SCM ./share/scm/bootstrap.scm -set env GNC_SCM_LOAD_PATH ("./share/scm") -set env GNC_DEBUG t -define run-gnucash - - set args --debug \ - --share-dir ./share \ - --config-dir ./etc \ - --doc-path \(\"\(./Docs\)\"\"\(./Reports\)\"\) \ - $arg0 - run -end diff --git a/doc/sgml/C/xacc-about.sgml b/doc/sgml/C/xacc-about.sgml index d901263fa1..6c903d3ab8 100644 --- a/doc/sgml/C/xacc-about.sgml +++ b/doc/sgml/C/xacc-about.sgml @@ -288,7 +288,7 @@ provide an accurate Profit & Loss statement. warlord@MIT.EDU Derek Atkins -build system patch +build system patch, rpc backend diff --git a/src/engine/Account.c b/src/engine/Account.c index 7c39b73972..4b3cfd1596 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -1556,6 +1556,77 @@ xaccAccountSetTaxRelated (Account *account, gboolean tax_related) xaccAccountCommitEdit (account); } +const char * +xaccAccountGetTaxCode (Account *account) +{ + kvp_value *value; + + if (!account) + return FALSE; + + value = kvp_frame_get_slot_path (account->kvp_data, "tax", "code", NULL); + if (!value) + return NULL; + + return kvp_value_get_string (value); +} + +void +xaccAccountSetTaxCode (Account *account, const char *code) +{ + kvp_frame *frame; + + if (!account) + return; + + xaccAccountBeginEdit (account); + + frame = kvp_frame_get_frame (account->kvp_data, "tax", NULL); + + kvp_frame_set_slot_nc (frame, "code", + code ? kvp_value_new_string (code) : NULL); + + mark_account (account); + account->core_dirty = TRUE; + xaccAccountCommitEdit (account); +} + +const char * +xaccAccountGetTaxPayerNameSource (Account *account) +{ + kvp_value *value; + + if (!account) + return FALSE; + + value = kvp_frame_get_slot_path (account->kvp_data, + "tax", "payer-name-source", NULL); + if (!value) + return NULL; + + return kvp_value_get_string (value); +} + +void +xaccAccountSetTaxPayerNameSource (Account *account, const char *source) +{ + kvp_frame *frame; + + if (!account) + return; + + xaccAccountBeginEdit (account); + + frame = kvp_frame_get_frame (account->kvp_data, "tax", NULL); + + kvp_frame_set_slot_nc (frame, "payer-name-source", + source ? kvp_value_new_string (source) : NULL); + + mark_account (account); + account->core_dirty = TRUE; + xaccAccountCommitEdit (account); +} + /********************************************************************\ \********************************************************************/ diff --git a/src/engine/Account.h b/src/engine/Account.h index 241b564f42..bc25845fbf 100644 --- a/src/engine/Account.h +++ b/src/engine/Account.h @@ -261,6 +261,12 @@ gboolean xaccAccountGetTaxRelated (Account *account); void xaccAccountSetTaxRelated (Account *account, gboolean tax_related); +const char * xaccAccountGetTaxCode (Account *account); +void xaccAccountSetTaxCode (Account *account, const char *code); +const char * xaccAccountGetTaxPayerNameSource (Account *account); +void xaccAccountSetTaxPayerNameSource (Account *account, + const char *source); + /* The xaccAccountGetFullName routine returns the fully qualified name * of the account using the given separator char. The name must be freed * after use. The fully qualified name of an account is the concatenation diff --git a/src/engine/kvp_doc.txt b/src/engine/kvp_doc.txt index cefa404a6b..879d5a197b 100644 --- a/src/engine/kvp_doc.txt +++ b/src/engine/kvp_doc.txt @@ -98,6 +98,16 @@ Entities: Split Use: xaccSplitGetType, xaccSplitMakeStockSplit Store a string representing the type of split, if not normal. +Name: tax/code +Type: string +Entities: Account +Use: see src/scm/report/[tax,txf]*.scm + +Name: tax/payer-name-source +Type: string +Entities: Account +Use: see src/scm/report/[tax,txf]*.scm + Name: tax-related Type: gint64 Entities: Account diff --git a/src/engine/kvp_frame.c b/src/engine/kvp_frame.c index 07d451a23b..7f66ab3cbc 100644 --- a/src/engine/kvp_frame.c +++ b/src/engine/kvp_frame.c @@ -685,11 +685,13 @@ kvp_value_delete(kvp_value * value) { kvp_value_t kvp_value_get_type(const kvp_value * value) { + if (!value) return -1; return value->type; } gint64 kvp_value_get_gint64(const kvp_value * value) { + if (!value) return 0; if(value->type == KVP_TYPE_GINT64) { return value->value.int64; } @@ -700,6 +702,7 @@ kvp_value_get_gint64(const kvp_value * value) { double kvp_value_get_double(const kvp_value * value) { + if (!value) return 0.0; if(value->type == KVP_TYPE_DOUBLE) { return value->value.dbl; } @@ -710,6 +713,7 @@ kvp_value_get_double(const kvp_value * value) { gnc_numeric kvp_value_get_numeric(const kvp_value * value) { + if (!value) return gnc_numeric_zero (); if(value->type == KVP_TYPE_NUMERIC) { return value->value.numeric; } @@ -720,6 +724,7 @@ kvp_value_get_numeric(const kvp_value * value) { char * kvp_value_get_string(const kvp_value * value) { + if (!value) return NULL; if(value->type == KVP_TYPE_STRING) { return value->value.str; } @@ -730,6 +735,7 @@ kvp_value_get_string(const kvp_value * value) { GUID * kvp_value_get_guid(const kvp_value * value) { + if (!value) return NULL; if(value->type == KVP_TYPE_GUID) { return value->value.guid; } @@ -740,18 +746,28 @@ kvp_value_get_guid(const kvp_value * value) { void * kvp_value_get_binary(const kvp_value * value, guint64 * size_return) { + if (!value) + { + if (size_return) + *size_return = 0; + return NULL; + } + if(value->type == KVP_TYPE_BINARY) { - *size_return = value->value.binary.datasize; + if (size_return) + *size_return = value->value.binary.datasize; return value->value.binary.data; } else { - *size_return = 0; + if (size_return) + *size_return = 0; return NULL; } } GList * kvp_value_get_glist(const kvp_value * value) { + if (!value) return NULL; if(value->type == KVP_TYPE_GLIST) { return value->value.list; } @@ -762,6 +778,7 @@ kvp_value_get_glist(const kvp_value * value) { kvp_frame * kvp_value_get_frame(const kvp_value * value) { + if (!value) return NULL; if(value->type == KVP_TYPE_FRAME) { return value->value.frame; } diff --git a/src/scm/html-utilities.scm b/src/scm/html-utilities.scm index 17c65a2701..6b823877e6 100644 --- a/src/scm/html-utilities.scm +++ b/src/scm/html-utilities.scm @@ -75,11 +75,13 @@ "red3" "orange3" "yellow3" "green3" "cyan3" "blue3" "purple3" "magenta3" "orchid3" "khaki3" "gold3" "orange3")) - (if (<= num-colors 0) - '() - (cons (list-ref base-colors - (modulo (- num-colors 1) (length base-colors))) - (gnc:assign-colors (- num-colors 1))))) + (define (assign-colors i) + (if (<= num-colors i) + '() + (cons (list-ref base-colors + (modulo i (length base-colors))) + (assign-colors (+ i 1))))) + (assign-colors 0)) ;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gnc:html-build-acct-table diff --git a/src/scm/report/taxtxf.scm b/src/scm/report/taxtxf.scm index d5c0066040..9f890f177b 100644 --- a/src/scm/report/taxtxf.scm +++ b/src/scm/report/taxtxf.scm @@ -8,8 +8,6 @@ ;; income to different accounts, as well as deductible and non ;; deductible expenses. ;; -;; Tax related accounts have "{tax}" in the notes field. This can be -;; set/reset from the parameters dialog. ;; The user selects the accounts(s) to be printed, if none, all are checked. ;; Automatically prints up to 15 sub-account levels below selected ;; account. Accounts below that are not printed. If you really need @@ -139,6 +137,7 @@ (cons (current-time) 0))))) (set-tm:mday bdtm 1) ; 01 (set-tm:mon bdtm 0) ; Jan + (set-tm:isdst bdtm -1) (cons 'absolute (cons (car (mktime bdtm)) 0)))) #f 'absolute #f)) @@ -197,27 +196,6 @@ tab-title (N_ "Print Full account names") "g" (N_ "Print all Parent account names") #f)) - (gnc:register-tax-option - (gnc:make-multichoice-option - tab-title (N_ "Set/Reset Tax Status") - "h" (N_ "Set/Reset Selected Account Tax Status") 'tax-no-change - (list (list->vector - (list 'tax-no-change (N_ "No Change") (N_ "No Change"))) - (list->vector - (list 'tax-set (N_ "Set Tax Related") - (N_ "Set Selected accounts as Tax Related"))) - (list->vector - (list 'tax-reset (N_ "Reset Tax Related") - (N_ "Reset Selected accounts as not Tax Related"))) - (list->vector - (list 'tax-set-kids (N_ "Set Tax Related & sub-accounts") - (N_ "Set Selected & sub-accounts as Tax Related"))) - (list->vector - (list 'tax-reset-kids - (N_ "Reset Tax Related & sub-accounts") - (N_ "Reset Selected & sub-accounts as not Tax Related"))) - ))) - (gnc:register-tax-option (gnc:make-account-list-option (N_ "TXF Export Init") (N_ "Select Account") @@ -235,18 +213,18 @@ (gnc:make-list-option (N_ "TXF Export Init") (N_ "For INCOME accounts, select here. < ^ # see help") - "c" (N_ "Select a TXF Income catagory") + "c" (N_ "Select a TXF Income category") '() - txf-income-catagories)) + txf-income-categories)) (gnc:register-tax-option ;;(gnc:make-multichoice-option (gnc:make-list-option (N_ "TXF Export Init") (N_ "For EXPENSE accounts, select here. < ^ # see help") - "d" (N_ "Select a TXF Expense catagory") + "d" (N_ "Select a TXF Expense category") '() - txf-expense-catagories)) + txf-expense-categories)) (gnc:register-tax-option (gnc:make-multichoice-option @@ -334,7 +312,7 @@ ;; return a string to insert in account-notes, or an error symbol ;; We only want one, but list-option returns a list. - (define (txf-string code-lst catagories-lst) + (define (txf-string code-lst categories-lst) (cond ((or (null? code-lst) (not (symbol? (car code-lst)))) 'none) @@ -343,7 +321,7 @@ ((eq? 'N000 (car code-lst)) #f) (else - (let ((txf-vec (txfq-ref (car code-lst) catagories-lst))) + (let ((txf-vec (txfq-ref (car code-lst) categories-lst))) (if txf-vec (let ((str (vector-ref txf-vec 1))) (if (equal? "#" (substring str 0 1)) @@ -353,7 +331,7 @@ " \\ " (symbol->string (car code-lst)))))))))) - ;; insert help strings in txf catagories + ;; insert help strings in txf categories (define (txf-help cat-list) (do ((i 0 (+ i 1)) (len (length cat-list))) @@ -460,9 +438,9 @@ (if (gnc:account-is-inc-exp? acc) (let* ((str (if (eq? txf-type 'income) (txf-string txf-inc - txf-income-catagories) + txf-income-categories) (txf-string txf-exp - txf-expense-catagories))) + txf-expense-categories))) (fun (case str ((mult) (set! str @@ -672,33 +650,6 @@ (list a)))) accounts))) - ;; Set or Reset key in account notes - (define (key-status accounts set key end-key kids) - (let ((key-len (string-length key))) - (map (lambda (a) - (let* ((notes (gnc:account-get-notes a)) - (notes (if notes notes "")) - (key-start (string-search notes key 0)) - (notes-len (string-length notes))) - (if key-start - (if (not set) ; reset tax status - (let* ((end-start (string-search notes end-key 0)) - (end (if end-start - (+ end-start (string-length end-key)) - (+ key-start key-len)))) - (gnc:account-set-notes a - (string-append - (substring notes 0 key-start) - (substring notes end - notes-len))))) - (if set ; set tax status - (gnc:account-set-notes a (string-append notes key)))) - (if kids ; recurse to all sub accounta - (key-status - (gnc:group-get-subaccounts (gnc:account-get-children a)) - set key end-key #t)))) - accounts))) - (define (generate-tax-or-txf report-name report-description report-obj @@ -776,6 +727,7 @@ (set-tm:mon bdtm 6)) ((4th-est 4th-last) ; Oct 1 (set-tm:mon bdtm 9)))) + (set-tm:isdst bdtm -1) (cons (car (mktime bdtm)) 0)))) (to-value (gnc:timepair-end-day-time @@ -818,6 +770,7 @@ (set-tm:mon bdtm 11)) (else (set! bdtm (gnc:timepair->date to-value))))) + (set-tm:isdst bdtm -1) (cons (car (mktime bdtm)) 0)))) (txf-help (get-option "TXF Export Init" @@ -830,13 +783,14 @@ (if (and (gnc:account-get-txf account) (txf-special-split? (gnc:account-get-txf-code account))) (let* - ((full-year? - (and (equal? (strftime "%Y" (localtime (car to-value))) - (strftime "%Y" (localtime (car from-value)))) - (equal? (strftime "%m%d" (localtime (car from-value))) - "0101") - (equal? (strftime "%m%d" (localtime (car to-value))) - "1231"))) + ((full-year? + (let ((bdto (localtime (car to-value))) + (bdfrom (localtime (car from-value)))) + (and (equal? (tm:year bdto) (tm:year bdfrom)) + (equal? (tm:mon bdfrom) 0) + (equal? (tm:mday bdfrom) 1) + (equal? (tm:mon bdto) 11) + (equal? (tm:mday bdto) 31)))) ;; Adjust dates so we get the final Estimated Tax ;; paymnent from the right year (from-est (if full-year? @@ -845,6 +799,7 @@ from-value)))) (set-tm:mday bdtm 1) ; 01 (set-tm:mon bdtm 2) ; Mar + (set-tm:isdst bdtm -1) (cons (car (mktime bdtm)) 0)) from-value)) (to-est (if full-year? @@ -854,7 +809,8 @@ (set-tm:mday bdtm 28) ; 28 (set-tm:mon bdtm 1) ; Feb (set-tm:year bdtm (+ (tm:year bdtm) 1)) - (cons (car (mktime bdtm)) 0)) + (set-tm:isdst bdtm -1) + (cons (car (mktime bdtm)) 0)) to-value)) (split-filter-pred (split-report-make-date-filter-predicate from-est to-est)) @@ -866,12 +822,12 @@ (let* ((tmp-date (gnc:transaction-get-date-posted (gnc:split-get-parent spl))) (value (gnc:numeric-to-double - (gnc:split-get-value spl))) - ;; TurboTax '99 ignores dates after 12/31/1999 - (date (if (and full-year? - (gnc:timepair-lt to-value tmp-date)) - to-value - tmp-date))) + (gnc:split-get-value spl))) + ;; TurboTax '99 ignores dates after 12/31/1999 + (date (if (and full-year? + (gnc:timepair-lt to-value tmp-date)) + to-value + tmp-date))) (if tax-mode (render-level-x-account table lev max-level account value suppress-0 #f date #f) @@ -924,8 +880,7 @@ (handle-level-x-account (+ 1 level) x))) children))))))) - (let* ((tax-stat (get-option tab-title "Set/Reset Tax Status")) - (txf-acc-lst (get-option "TXF Export Init" "Select Account")) + (let* ((txf-acc-lst (get-option "TXF Export Init" "Select Account")) (txf-account (if (null? txf-acc-lst) (begin (set! txf-acc-lst '(#f)) #f) @@ -942,16 +897,6 @@ (map gnc:account-get-full-name txf-acc-lst) '(#f))) - (not-used - (case tax-stat - ((tax-set) - (key-status user-sel-accnts #t tax-key tax-end-key #f)) - ((tax-reset) - (key-status user-sel-accnts #f tax-key tax-end-key #f)) - ((tax-set-kids) - (key-status user-sel-accnts #t tax-key tax-end-key #t)) - ((tax-reset-kids) - (key-status user-sel-accnts #f tax-key tax-end-key #t)))) (txf-fun-str-lst (map (lambda (a) (txf-function a txf-income txf-expense @@ -1120,11 +1065,11 @@ txf file!"))))))) (if txf-help (begin (map (lambda (x) (txf-print-help table x #t)) - txf-help-catagories) + txf-help-categories) (map (lambda (x) (txf-print-help table x #t)) - txf-income-catagories) + txf-income-categories) (map (lambda (x) (txf-print-help table x #f)) - txf-expense-catagories)) + txf-expense-categories)) (map (lambda (x) (handle-level-x-account 1 x)) selected-accounts)) @@ -1139,9 +1084,9 @@ Go the the Tax Information dialog to set up tax-related accounts."))))) doc))) ;; copy help strings to category structures. - (txf-help txf-income-catagories) - (txf-help txf-expense-catagories) - (txf-help txf-help-catagories) + (txf-help txf-income-categories) + (txf-help txf-expense-categories) + (txf-help txf-help-categories) (gnc:define-report 'version 1 diff --git a/src/scm/report/txf-export-help.scm b/src/scm/report/txf-export-help.scm index e129fe9396..8220af44c1 100644 --- a/src/scm/report/txf-export-help.scm +++ b/src/scm/report/txf-export-help.scm @@ -1,5 +1,4 @@ ;; -*-scheme-*- -;; $Id$ ;; ;; Richard -Gilligan- Uschold ;; These are help strings for each TXF code. See taxtxf.scm and diff --git a/src/scm/report/txf-export.scm b/src/scm/report/txf-export.scm index 9b9429895d..49fe40b9ac 100644 --- a/src/scm/report/txf-export.scm +++ b/src/scm/report/txf-export.scm @@ -1,5 +1,4 @@ ;; -*-scheme-*- -;; $Id$ ;; ;; Richard -Gilligan- Uschold ;; These are TXF codes and a brief description of each. See taxtxf.scm @@ -8,12 +7,12 @@ (gnc:support "report/txf-export.scm") ;; #(code " form x \\ description" "help" format multiple) -(define txf-help-catagories +(define txf-help-categories (list #(H001 "< help \\ Name of Current account is exported." "" 0 #f) #(H002 "^ help \\ Name of Parent account is exported." "" 0 #f) #(H003 "# help \\ Not implimented yet, Do NOT Use!" "" 0 #f))) -(define txf-income-catagories +(define txf-income-categories (list #(N000 " none \\ Tax Report Only - No TXF Export" "" 0 #f) #(N261 " F1040 \\ Alimony received" "" 1 #f) #(N257 " F1040 \\ Other income, misc." "" 1 #f) @@ -120,7 +119,7 @@ #(N506 " W-2 \\ Salary or wages, spouse" "" 1 #t) #(N549 " W-2G \\ Gross winnings" "" 1 #t))) -(define txf-expense-catagories +(define txf-expense-categories (list #(N000 " none \\ Tax Report Only - No TXF Export" "" 0 #f) #(N264 " F1040 \\ Alimony paid" "" 1 #f) #(N265 "< F1040 \\ Early withdrawal penalty" "" 3 #f)