Skip to content

Commit c25373c

Browse files
[new-owner-report.scm] insert job-ID if available
1 parent 2798ed7 commit c25373c

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

gnucash/report/reports/standard/new-owner-report.scm

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
(define desc-header (N_ "Description"))
5454
(define sale-header (N_ "Sale"))
5555
(define tax-header (N_ "Tax"))
56+
(define job-header (N_ "Job"))
5657
(define credit-header (N_ "Credits"))
5758
(define debit-header (N_ "Debits"))
5859
(define balance-header (N_ "Balance"))
@@ -158,13 +159,16 @@
158159
(vector-ref columns-used 9))
159160
(define (doclink-col columns-used)
160161
(vector-ref columns-used 10))
162+
(define (job-col columns-used)
163+
(vector-ref columns-used 11))
161164

162165
(define (num-cols columns-used section)
163166
(let* ((date? (date-col columns-used))
164167
(due? (date-due-col columns-used))
165168
(ref? (ref-col columns-used))
166169
(type? (type-col columns-used))
167170
(desc? (desc-col columns-used))
171+
(job? (job-col columns-used))
168172
(sale? (sale-col columns-used))
169173
(tax? (tax-col columns-used))
170174
(credit? (credit-col columns-used))
@@ -175,9 +179,9 @@
175179
(amt? (or credit? debit?))
176180
(cols-alist
177181
(list
178-
(list 'lhs-cols date? due? ref? type? desc? sale? tax? credit? debit? bal?
182+
(list 'lhs-cols date? due? ref? type? job? desc? sale? tax? credit? debit? bal?
179183
doclink?)
180-
(list 'ptt-span date? due? ref? type? desc? doclink?)
184+
(list 'ptt-span date? due? ref? type? job? desc? doclink?)
181185
(list 'mid-spac spacer?)
182186
(list 'rhs-cols date? ref? type? desc? amt? amt?)
183187
(list 'rhs-span date? ref? type? desc?)))
@@ -191,7 +195,7 @@
191195
(map opt-val
192196
(list date-header due-date-header reference-header type-header
193197
desc-header sale-header tax-header debit-header credit-header
194-
balance-header doclink-header))))
198+
balance-header doclink-header job-header))))
195199

196200
(define (make-heading-list column-vector link-option)
197201
(let ((heading-list '()))
@@ -205,6 +209,8 @@
205209
(addto! heading-list (G_ type-header)))
206210
(if (desc-col column-vector)
207211
(addto! heading-list (G_ desc-header)))
212+
(if (job-col column-vector)
213+
(addto! heading-list (G_ job-header)))
208214
(if (doclink-col column-vector)
209215
(addto! heading-list (C_ "Column header for 'Document Link'" "L")))
210216
(if (sale-col column-vector)
@@ -259,6 +265,10 @@
259265
(gnc:invoice-anchor-text inv)
260266
(gncInvoiceGetID inv)))
261267

268+
(define (invoice->job invoice)
269+
(let ((owner (gncInvoiceGetOwner invoice)))
270+
(and (eqv? (gncOwnerGetType owner) GNC-OWNER-JOB) (gncOwnerGetJob owner))))
271+
262272
(define (split->reference split)
263273
(let* ((txn (xaccSplitGetParent split))
264274
(type (xaccTransGetTxnType txn)))
@@ -336,7 +346,7 @@
336346
;;
337347
;; Make a row list based on the visible columns
338348
;;
339-
(define (add-row table odd-row? column-vector date due-date ref type-str
349+
(define (add-row table odd-row? column-vector date due-date ref type-str job
340350
desc doclink currency amt debit credit sale tax lhs-class
341351
link-option link-rows)
342352
(define nrows (if link-rows (length link-rows) 1))
@@ -429,6 +439,7 @@
429439
(addif (ref-col column-vector) ref)
430440
(addif (type-col column-vector) type-str)
431441
(addif (desc-col column-vector) desc)
442+
(addif (job-col column-vector) job)
432443
(addif (doclink-col column-vector) doclink)))
433444
(map
434445
(lambda (str)
@@ -548,7 +559,7 @@ and do not match the transaction."))))))))
548559
payable? date-type currency)))))
549560

550561
(define (add-balance-row odd-row? total)
551-
(add-row table odd-row? used-columns start-date #f "" (G_ "Balance") "" #f
562+
(add-row table odd-row? used-columns start-date #f #f #f (G_ "Balance") "" #f
552563
currency total #f #f #f #f #f
553564
link-option (case link-option
554565
((none) '(()))
@@ -794,6 +805,8 @@ and do not match the transaction."))))))))
794805
table odd-row? used-columns date (gncInvoiceGetDateDue invoice)
795806
(split->reference split)
796807
(split->type-str split payable?)
808+
(let ((job (invoice->job invoice)))
809+
(and job (gnc:make-html-text (gncJobGetID job))))
797810
(splits->desc (list split))
798811
(and (not (string-null? (gncInvoiceGetDocLink invoice)))
799812
(gnc:html-invoice-doclink-anchor
@@ -834,6 +847,7 @@ and do not match the transaction."))))))))
834847
table odd-row? used-columns date #f
835848
(split->reference split)
836849
(split->type-str split payable?)
850+
#f
837851
(splits->desc (xaccTransGetAPARAcctSplitList txn #t) #t)
838852
(and (not (string-null? (xaccTransGetDocLink txn)))
839853
(gnc:html-transaction-doclink-anchor
@@ -887,6 +901,11 @@ and do not match the transaction."))))))))
887901
(N_ "Display Columns") type-header
888902
"g" (N_ "Display the transaction type?") #t)
889903

904+
(unless (eqv? GNC-OWNER-JOB owner-type)
905+
(gnc-register-simple-boolean-option
906+
options (N_ "Display Columns") job-header
907+
"gg" (N_ "Display the associated job?") #f))
908+
890909
(gnc-register-simple-boolean-option options
891910
(N_ "Display Columns") desc-header
892911
"ha" (N_ "Display the transaction description?") #t)

0 commit comments

Comments
 (0)