BUGFIX: invoice posted-date is no longer 0 for unposted invoices

This commit fixes business reports caused by 91f4b19039
whereby the posted-date for unposted invoice was changed
from 0 to MAXINT. Now we need to use (gncInvoiceIsPosted)
or (gncInvoiceDateExists) instead.
This commit is contained in:
Christopher Lam
2018-01-30 19:29:04 +08:00
parent 00c4bac65b
commit 862956a760
8 changed files with 31 additions and 39 deletions

View File

@@ -776,12 +776,11 @@
(add-html! document "</tr></table>") (add-html! document "</tr></table>")
) )
; add the date ;; add the date
(let ((date-table #f) (if (gncInvoiceIsPosted invoice)
(post-date (gncInvoiceGetDatePosted invoice)) (let ((date-table #f)
(due-date (gncInvoiceGetDateDue invoice))) (post-date (gncInvoiceGetDatePosted invoice))
(if (not (zero? post-date)) (due-date (gncInvoiceGetDateDue invoice)))
(begin
(set! date-table (make-date-table)) (set! date-table (make-date-table))
(make-date-row! date-table (_ "Date") post-date date-format) (make-date-row! date-table (_ "Date") post-date date-format)
(if (opt-val "Display" "Due Date") (if (opt-val "Display" "Due Date")
@@ -790,7 +789,7 @@
(add-html! document (add-html! document
(string-append "<font color='red'>" (string-append "<font color='red'>"
(_ "INVOICE NOT POSTED") (_ "INVOICE NOT POSTED")
"</font>")))) "</font>")))
(make-break! document) (make-break! document)

View File

@@ -857,19 +857,17 @@
'attribute (list "cellpadding" 0) 'attribute (list "cellpadding" 0)
'attribute (list "width" "100%")) 'attribute (list "width" "100%"))
(set! date-object (let ((date-table #f) (set! date-object
(post-date (gncInvoiceGetDatePosted invoice)) (if (gncInvoiceIsPosted invoice)
(due-date (gncInvoiceGetDateDue invoice))) (let ((date-table #f)
(post-date (gncInvoiceGetDatePosted invoice))
(if (not (zero? post-date)) (due-date (gncInvoiceGetDateDue invoice)))
(begin
(set! date-table (make-date-table)) (set! date-table (make-date-table))
;; oli-custom - moved invoice number here
(gnc:html-table-append-row! (gnc:html-table-append-row!
;; Translators: %s below is "Invoice" or "Bill" or even the ;; Translators: %s below is "Invoice" or "Bill" or even the
;; custom title from the options. The next column contains ;; custom title from the options. The next column contains
;; the number of the document. ;; the number of the document.
date-table (list (sprintf #f (_ "%s&nbsp;#") title) (gncInvoiceGetID invoice))) date-table (list (sprintf #f (_ "%s&nbsp;#") title) (gncInvoiceGetID invoice)))
;; Translators: The first %s below is "Invoice" or ;; Translators: The first %s below is "Invoice" or
;; "Bill" or even the custom title from the ;; "Bill" or even the custom title from the
;; options. This string sucks for i18n, but I don't ;; options. This string sucks for i18n, but I don't
@@ -879,10 +877,8 @@
(make-date-row! date-table (_ "Due&nbsp;Date") due-date date-format) (make-date-row! date-table (_ "Due&nbsp;Date") due-date date-format)
date-table) date-table)
(gnc:make-html-text (gnc:make-html-text
;; oli-custom - FIXME: I have a feeling I broke a (string-append title "<br>"
;; translation by not using string-expand for &nbsp; (_ "Invoice in progress...")))))
(string-append title "<br>"
(_ "Invoice in progress..."))))))
(gnc:html-table-append-row! (gnc:html-table-append-row!
helper-table helper-table

View File

@@ -708,22 +708,18 @@
document document
(make-myname-table book date-format)) (make-myname-table book date-format))
(let ((date-table #f) (if (gncInvoiceIsPosted invoice)
(post-date (gncInvoiceGetDatePosted invoice)) (let ((date-table #f)
(due-date (gncInvoiceGetDateDue invoice))) (post-date (gncInvoiceGetDatePosted invoice))
(due-date (gncInvoiceGetDateDue invoice)))
(if (not (zero? post-date)) (set! date-table (make-date-table))
(begin (make-date-row! date-table (string-append title " " (_ "Date")) post-date date-format)
(set! date-table (make-date-table)) (make-date-row! date-table (_ "Due Date") due-date date-format)
(make-date-row! date-table (string-append title " " (_ "Date")) post-date date-format) (gnc:html-document-add-object! document date-table))
(make-date-row! date-table (_ "Due Date") due-date date-format) (gnc:html-document-add-object!
(gnc:html-document-add-object! document date-table)) document
(gnc:html-document-add-object! (gnc:make-html-text
document (_ "Invoice in progress..."))))
(gnc:make-html-text
(_ "Invoice in progress...")))))
(make-break! document) (make-break! document)
(make-break! document) (make-break! document)

View File

@@ -193,7 +193,7 @@
(if (date-due-col column-vector) (if (date-due-col column-vector)
(addto! row-contents (addto! row-contents
(if (and due-date (if (and due-date
(not (zero? due-date))) (gncInvoiceDateExists due-date))
(qof-print-date due-date) (qof-print-date due-date)
""))) "")))
(if (num-col column-vector) (if (num-col column-vector)

View File

@@ -291,7 +291,7 @@
(if (date-due-col column-vector) (if (date-due-col column-vector)
(addto! row-contents (addto! row-contents
(if (and due-date (if (and due-date
(not (zero? due-date))) (gncInvoiceDateExists due-date))
(qof-print-date due-date) (qof-print-date due-date)
""))) "")))
(if (num-col column-vector) (if (num-col column-vector)

View File

@@ -246,7 +246,7 @@
<td align="right" class="invnum"><big><strong><?scm:d invoiceid ?></strong></big></td> <td align="right" class="invnum"><big><strong><?scm:d invoiceid ?></strong></big></td>
</tr> </tr>
<?scm )) ?> <?scm )) ?>
<?scm (if (zero? postdate) (begin ?> <?scm (if (not (gncInvoiceDateExists postdate)) (begin ?>
<tr> <tr>
<td colspan="2" align="right"><?scm:d (_ "Invoice in progress...") ?></td> <td colspan="2" align="right"><?scm:d (_ "Invoice in progress...") ?></td>
</tr> </tr>

View File

@@ -1856,7 +1856,7 @@ gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn,
gncOwnerAutoApplyPaymentsWithLots (owner, selected_lots); gncOwnerAutoApplyPaymentsWithLots (owner, selected_lots);
} }
static gboolean gncInvoiceDateExists (time64 date) gboolean gncInvoiceDateExists (time64 date)
{ {
return date != INT64_MAX; return date != INT64_MAX;
} }

View File

@@ -275,6 +275,7 @@ static inline GncInvoice * gncInvoiceLookup (const QofBook *book, const GncGUID
void gncInvoiceBeginEdit (GncInvoice *invoice); void gncInvoiceBeginEdit (GncInvoice *invoice);
void gncInvoiceCommitEdit (GncInvoice *invoice); void gncInvoiceCommitEdit (GncInvoice *invoice);
int gncInvoiceCompare (const GncInvoice *a, const GncInvoice *b); int gncInvoiceCompare (const GncInvoice *a, const GncInvoice *b);
gboolean gncInvoiceDateExists (time64 date);
gboolean gncInvoiceIsPosted (const GncInvoice *invoice); gboolean gncInvoiceIsPosted (const GncInvoice *invoice);
gboolean gncInvoiceIsPaid (const GncInvoice *invoice); gboolean gncInvoiceIsPaid (const GncInvoice *invoice);