* src/business/business-core/business-core.scm: return #f if

we cannot obtain an owner from a split (in the case of a regularly-
	  entered split)
	* src/business/business-reports/aging.scm:
	* src/business/business-reports/owner-report.scm:
	  Cope with not being able to obtain an owner from a split.
	  In particular, ignore it.  Fixes part of #97097.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7800 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins
2003-01-07 23:31:35 +00:00
parent d8cff1cd3c
commit e9b93eeccf
4 changed files with 75 additions and 52 deletions

View File

@@ -17,6 +17,14 @@
Make sure that we're only saving the items that have been fully
created (not half-created). Fixes the cause of bug #102776.
* src/business/business-core/business-core.scm: return #f if
we cannot obtain an owner from a split (in the case of a regularly-
entered split)
* src/business/business-reports/aging.scm:
* src/business/business-reports/owner-report.scm:
Cope with not being able to obtain an owner from a split.
In particular, ignore it. Fixes part of #97097.
2003-01-06 Derek Atkins <derek@ihtfp.com>
* macros/Makefile.am: include the rest of the macros in the dist.

View File

@@ -109,23 +109,29 @@
(set! owner (gnc:invoice-get-owner invoice))
(let ((split-list (gnc:transaction-get-splits trans)))
(define (check-splits splits)
(let* ((split (car splits))
(lot (gnc:split-get-lot split)))
(if lot
(let* ((invoice (gnc:invoice-get-invoice-from-lot lot))
(owner? (gnc:owner-get-owner-from-lot
lot temp-owner)))
(if invoice
(set! owner (gnc:invoice-get-owner invoice))
(if owner?
(set! owner temp-owner)
(check-splits (cdr splits)))))
(check-splits (cdr splits)))))
(if (and splits (not (null? splits)))
(let* ((split (car splits))
(lot (gnc:split-get-lot split)))
(if lot
(let* ((invoice (gnc:invoice-get-invoice-from-lot lot))
(owner? (gnc:owner-get-owner-from-lot
lot temp-owner)))
(if invoice
(set! owner (gnc:invoice-get-owner invoice))
(if owner?
(set! owner temp-owner)
(check-splits (cdr splits)))))
(check-splits (cdr splits))))))
(check-splits split-list)))
(gnc:owner-copy-into-owner (gnc:owner-get-end-owner owner) result-owner)
(gnc:owner-destroy temp-owner)
result-owner))
(if owner
(begin
(gnc:owner-copy-into-owner (gnc:owner-get-end-owner owner) result-owner)
(gnc:owner-destroy temp-owner)
result-owner)
(begin
(gnc:owner-destroy temp-owner)
#f))))
(export gnc:owner-get-name)

View File

@@ -166,45 +166,51 @@
reverse?)
(let* ((transaction (gnc:split-get-parent split))
(temp-owner (gnc:owner-create))
(owner (gnc:owner-from-split split temp-owner))
(guid (gnc:owner-get-guid owner))
(this-currency (gnc:transaction-get-currency transaction))
(value (gnc:split-get-value split))
(this-date (gnc:transaction-get-date-posted transaction))
(company-info (hash-ref hash guid)))
(owner (gnc:owner-from-split split temp-owner)))
(gnc:debug "update-company-hash called")
(gnc:debug "guid" guid)
(gnc:debug "split-value" value)
(if reverse? (set! value (gnc:numeric-neg value)))
(if company-info
;; if it's an existing company, destroy the temp owner and
;; then make sure the currencies match
(begin
(gnc:owner-destroy temp-owner)
(if (not (gnc:commodity-equiv? this-currency
(company-get-currency company-info)))
(cons #f (sprintf (_ "Transactions relating to company %d contain \
(if
owner
(let* ((guid (gnc:owner-get-guid owner))
(this-currency (gnc:transaction-get-currency transaction))
(value (gnc:split-get-value split))
(this-date (gnc:transaction-get-date-posted transaction))
(company-info (hash-ref hash guid)))
(gnc:debug "update-company-hash called")
(gnc:debug "guid" guid)
(gnc:debug "split-value" value)
(if reverse? (set! value (gnc:numeric-neg value)))
(if company-info
;; if it's an existing company, destroy the temp owner and
;; then make sure the currencies match
(begin
(gnc:owner-destroy temp-owner)
(if (not (gnc:commodity-equiv? this-currency
(company-get-currency company-info)))
(cons #f (sprintf (_ "Transactions relating to company %d contain \
more than one currency. This report is not designed to cope with this possibility.")))
(begin
(gnc:debug "it's an old company")
(if (gnc:numeric-negative-p value)
(process-invoice company-info (gnc:numeric-neg value) bucket-intervals this-date)
(process-payment company-info value))
(hash-set! hash guid company-info)
(cons #t guid))))
;; if it's a new company
(begin
(gnc:debug "value" value)
(if (gnc:numeric-negative-p value) ;; if it's a new debt
;; if not ignore it
(begin
(gnc:debug "it's an old company")
(if (gnc:numeric-negative-p value)
(process-invoice company-info (gnc:numeric-neg value) bucket-intervals this-date)
(process-payment company-info value))
(hash-set! hash guid company-info)
(cons #t guid))))
;; if it's a new company
(begin
(gnc:debug "value" value)
(if (gnc:numeric-negative-p value) ;; if it's a new debt
;; if not ignore it
;;; XXX: is this right ?
(let ((new-company (make-company this-currency owner)))
(process-invoice new-company (gnc:numeric-neg value) bucket-intervals this-date)
(hash-set! hash guid new-company))
(gnc:owner-destroy temp-owner))
(cons #t guid)))))
(let ((new-company (make-company this-currency owner)))
(process-invoice new-company (gnc:numeric-neg value) bucket-intervals this-date)
(hash-set! hash guid new-company))
(gnc:owner-destroy temp-owner))
(cons #t guid))))
; else (no owner)
(gnc:owner-destroy temp-owner))))
;; get the total debt from the buckets

View File

@@ -619,7 +619,10 @@
(let* ((temp-owner (gnc:owner-create))
(owner (gnc:owner-from-split split temp-owner))
(res (gnc:owner-report-create owner account)))
(res #f))
(if owner
(set! res (gnc:owner-report-create owner account)))
(gnc:owner-destroy temp-owner)
res))