gnucash master: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Sat Mar 11 10:04:41 EST 2017


Updated	 via  https://github.com/Gnucash/gnucash/commit/d9303023 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/8c8af544 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9d57447f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6bba5512 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4949499b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/80e64a12 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3889606d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/bc50f3da (commit)
	 via  https://github.com/Gnucash/gnucash/commit/97598c43 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/03ff5d37 (commit)
	from  https://github.com/Gnucash/gnucash/commit/be260a43 (commit)



commit d9303023e0766bf2b033240c3a63c354f141bf08
Author: Christoph Rohland <christoph at rohland.net>
Date:   Sat Mar 11 11:56:59 2017 +0100

    Fix logic error for discounts
    
    Got it all wrong before. Don’t use to complex expressions!

diff --git a/src/report/business-reports/taxinvoice.eguile.scm b/src/report/business-reports/taxinvoice.eguile.scm
index 3d9d4ca..1fc7189 100644
--- a/src/report/business-reports/taxinvoice.eguile.scm
+++ b/src/report/business-reports/taxinvoice.eguile.scm
@@ -105,7 +105,8 @@
               (set! units? #t))
             (if (not (= (gnc-numeric-to-double qty) 1.0))
               (set! qty? #t))
-            (if (not (or cust-doc? (gnc-numeric-zero-p discount))) (set! discount? #t))
+            (if cust-doc? ; Only invoices have discounts
+                (if (not (gnc-numeric-zero-p discount)) (set! discount? #t)))
             ;(if taxable - no, this flag is redundant
             (if taxable? ; Also check if the taxable flag is set
               (if  (not (eq? taxtable '()))

commit 8c8af54420909941a85b1cce7ee9e9024bd59a9e
Author: Christoph Rohland <christoph at rohland.net>
Date:   Fri Mar 10 19:31:09 2017 +0100

    Fix taxinvoice for bill entries with taxes
    
    taxinvoice was throwing an exception when there were taxes on bill entries.
    It also did scan the invoice parts to determine if there were taxes and discounts.

diff --git a/src/report/business-reports/taxinvoice.eguile.scm b/src/report/business-reports/taxinvoice.eguile.scm
index ea7bc77..3d9d4ca 100644
--- a/src/report/business-reports/taxinvoice.eguile.scm
+++ b/src/report/business-reports/taxinvoice.eguile.scm
@@ -82,18 +82,30 @@
                          (< (car (gnc-transaction-get-date-posted t1))
                             (car (gnc-transaction-get-date-posted t2))))))))
 
+
+      ;; Is this an invoice or something else
+      (if (not (null? opt-invoice))
+          (begin
+            (set! owner (gncInvoiceGetOwner  opt-invoice))
+            (let ((type (gncInvoiceGetType  opt-invoice)))
+              (cond
+               ((eqv? type GNC-INVOICE-CUST-INVOICE)
+                (set! cust-doc? #t))
+               
+               ))))
+      
       ; pre-scan invoice entries to look for discounts and taxes
       (for entry in entries do
           (let ((action    (gncEntryGetAction entry))
                 (qty       (gncEntryGetDocQuantity entry credit-note?))
                 (discount  (gncEntryGetInvDiscount entry))
-                (taxable?   (gncEntryGetInvTaxable entry))
-                (taxtable  (gncEntryGetInvTaxTable entry)))
+                (taxable?  (if cust-doc? (gncEntryGetInvTaxable entry) (gncEntryGetBillTaxable entry)))
+                (taxtable  (if cust-doc? (gncEntryGetInvTaxTable entry) (gncEntryGetBillTaxTable entry))))
             (if (not (string=? action ""))
               (set! units? #t))
             (if (not (= (gnc-numeric-to-double qty) 1.0))
               (set! qty? #t))
-            (if (not (gnc-numeric-zero-p discount)) (set! discount? #t))
+            (if (not (or cust-doc? (gnc-numeric-zero-p discount))) (set! discount? #t))
             ;(if taxable - no, this flag is redundant
             (if taxable? ; Also check if the taxable flag is set
               (if  (not (eq? taxtable '()))
@@ -106,16 +118,6 @@
             (if (not (equal? t txn))
               (set! payments? #t))))
 
-  ;; Is this an invoice or something else
-  (if (not (null? opt-invoice))
-    (begin
-      (set! owner (gncInvoiceGetOwner  opt-invoice))
-      (let ((type (gncInvoiceGetType  opt-invoice)))
-        (cond
-          ((eqv? type GNC-INVOICE-CUST-INVOICE)
-           (set! cust-doc? #t))
-
-  ))))
 
 ?>
 
@@ -331,11 +333,11 @@
                   (rval      (gncEntryGetDocValue entry #t cust-doc? credit-note?))
                   (rdiscval  (gncEntryGetDocDiscountValue entry #t cust-doc? credit-note?))
                   (rtaxval   (gncEntryGetDocTaxValue entry #t cust-doc? credit-note?))
-                  (disc  (if cust-doc? (gncEntryGetInvDiscount entry)))
+                  (disc      (if cust-doc? (gncEntryGetInvDiscount entry)))
                   (disctype  (gncEntryGetInvDiscountType entry))
                   (acc       (if cust-doc? (gncEntryGetInvAccount entry)(gncEntryGetBillAccount entry)))
                   (taxable   (if cust-doc? (gncEntryGetInvTaxable entry)(gncEntryGetBillTaxable entry)))
-                  (taxtable  (if cust-doc? (gncEntryGetInvTaxTable entry)(gncEntryGetBillTaxable entry))))
+                  (taxtable  (if cust-doc? (gncEntryGetInvTaxTable entry)(gncEntryGetBillTaxTable entry))))
               (inv-total 'add currency rval)
               (inv-total 'add currency rtaxval)
               (tax-total 'add currency rtaxval)

commit 9d57447fe1468288b48382c1bcf265a0d92b13bd
Author: Christoph Rohland <christoph at rohland.net>
Date:   Wed Mar 8 15:08:54 2017 +0100

    Let taxinvoice optionally show the net instead of the given price
    
    This is needed if there is a mix of entries with tax included and
    excluded

diff --git a/src/report/business-reports/taxinvoice.eguile.scm b/src/report/business-reports/taxinvoice.eguile.scm
index c2557d0..ea7bc77 100644
--- a/src/report/business-reports/taxinvoice.eguile.scm
+++ b/src/report/business-reports/taxinvoice.eguile.scm
@@ -326,8 +326,7 @@
             (inv-total (gnc:make-commodity-collector)))
         (for entry in entries do
             (let ((qty       (gncEntryGetDocQuantity entry credit-note?))
-                  ;;(each      (gncEntryGetInvPrice entry))
-                  (each  (if cust-doc? (gncEntryGetInvPrice entry)(gncEntryGetBillPrice entry)))
+                  (each      (gncEntryGetPrice entry cust-doc? opt-netprice))
                   (action    (gncEntryGetAction entry))
                   (rval      (gncEntryGetDocValue entry #t cust-doc? credit-note?))
                   (rdiscval  (gncEntryGetDocDiscountValue entry #t cust-doc? credit-note?))
diff --git a/src/report/business-reports/taxinvoice.scm b/src/report/business-reports/taxinvoice.scm
index 6df64d1..dc864db 100644
--- a/src/report/business-reports/taxinvoice.scm
+++ b/src/report/business-reports/taxinvoice.scm
@@ -102,6 +102,7 @@
 (define optname-jobnumber-text		(N_ "Job Number text"))
 (define optname-jobname-show		(N_ "Show Job name"))
 (define optname-jobnumber-show		(N_ "Show Job number"))
+(define optname-netprice		(N_ "Show net price"))
 (define optname-invnum-next-to-title	(N_ "Invoice number next to title"))
 (define optname-border-collapse		(N_ "table-border-collapse"))
 (define optname-border-color-th		(N_ "table-header-border-color"))
@@ -170,6 +171,7 @@
 (add-option (gnc:make-simple-boolean-option	elementspage	optname-invnum-next-to-title	"h" (N_ "Invoice Number next to title?") #f))
 (add-option (gnc:make-simple-boolean-option	elementspage	optname-jobname-show		"i" (N_ "Display Job name?") #t))
 (add-option (gnc:make-simple-boolean-option	elementspage	optname-jobnumber-show		"j" (N_ "Invoice Job number?") #f))
+(add-option (gnc:make-simple-boolean-option	elementspage	optname-netprice		"k" (N_ "Show net price?") #f))
 
   ;; Display options
   (add-option (gnc:make-string-option displaypage optname-template-file "a" 
@@ -282,6 +284,7 @@
          (opt-invnum-next-to-title  (opt-value elementspage  optname-invnum-next-to-title))
          (opt-jobname-show          (opt-value elementspage  optname-jobname-show))
          (opt-jobnumber-show        (opt-value elementspage  optname-jobnumber-show))
+         (opt-netprice              (opt-value elementspage  optname-netprice))
          (opt-report-currency       (opt-value gnc:pagename-general optname-report-currency))
          (opt-css-border-collapse   (if (opt-value displaypage optname-border-collapse) "border-collapse:collapse;"))
          (opt-css-border-color-th   (opt-value displaypage optname-border-color-th))

commit 6bba55128f31a9ff7419fe30ca87d015ac5371e7
Merge: be260a4 4949499
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Sat Mar 11 15:57:44 2017 +0100

    Merge branch 'maint'

diff --cc src/engine/SX-ttinfo.c
index 66ce1cd,7af023f..3eec40a
--- a/src/engine/SX-ttinfo.c
+++ b/src/engine/SX-ttinfo.c
@@@ -27,11 -27,12 +27,11 @@@
  
  #include "SX-ttinfo.h"
  
 -/* KvpFrame policy? */
  struct TTInfo_s
  {
-     /* FIXME add notes field */
      char *description; /* owned by us */
      char *num;         /* owned  by us */
+     char *notes;
      gnc_commodity *common_currency; /* not freed */
  
      GList *splits; /* list of template splits, owned by us */

commit 4949499bd44581419298a4b220fdbbe2c639a257
Author: Christoph Rohland <christoph at rohland.net>
Date:   Thu Mar 9 15:01:11 2017 +0100

    Charge back net value of bill entries in invoices
    
    When charging entries from bills we need to exclude taxes since the tax
    rate of the invoice might be different than that of the bill.
    
    This fixes Bug 776380 - Gross value of bills charged back instead of
    net value (https://bugzilla.gnome.org/show_bug.cgi?id=776380)

diff --git a/src/engine/gncInvoice.c b/src/engine/gncInvoice.c
index 222553f..a624b7b 100644
--- a/src/engine/gncInvoice.c
+++ b/src/engine/gncInvoice.c
@@ -1465,7 +1465,11 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
 
             /* If this is a bill, and the entry came from an invoice originally, copy the price */
             if (gncEntryGetBillable (entry))
-                gncEntrySetInvPrice (entry, gncEntryGetBillPrice (entry));
+            {
+                /* We need to set the net price since it may be another tax rate for invoices than bills */
+                gncEntrySetInvPrice (entry, gncEntryGetPrice (entry, FALSE, TRUE));
+                gncEntrySetInvTaxIncluded (entry, FALSE);
+            }
         }
         gncEntryCommitEdit (entry);
 

commit 80e64a129607f0bd4f02480ee10e85201420c6a8
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Mar 10 14:23:20 2017 -0800

    Fix failed unit test from previous commit.

diff --git a/src/engine/test/utest-Split.c b/src/engine/test/utest-Split.c
index a383b70..64a2a60 100644
--- a/src/engine/test/utest-Split.c
+++ b/src/engine/test/utest-Split.c
@@ -748,10 +748,10 @@ test_get_currency_denom (Fixture *fixture, gconstpointer pData)
     const gint denom = gnc_commodity_get_fraction (fixture->curr);
     g_assert_cmpint (fixture->func->get_currency_denom (NULL), ==, 0);
     fixture->split->parent = NULL;
-    g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, 100000);
+    g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, 1000000);
     fixture->split->parent = txn;
     txn->common_currency = NULL;
-    g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, 100000);
+    g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, 1000000);
     txn->common_currency = fixture->curr;
     g_assert_cmpint (fixture->func->get_currency_denom (fixture->split), ==, denom);
 }
@@ -766,7 +766,7 @@ test_get_commodity_denom (Fixture *fixture, gconstpointer pData)
     const gint denom = gnc_commodity_get_fraction (fixture->comm);
     g_assert_cmpint (fixture->func->get_commodity_denom (NULL), ==, 0);
     fixture->split->acc = NULL;
-    g_assert_cmpint (fixture->func->get_commodity_denom (fixture->split), ==, 100000);
+    g_assert_cmpint (fixture->func->get_commodity_denom (fixture->split), ==, 1000000);
     fixture->split->acc = acc;
     g_assert_cmpint (fixture->func->get_commodity_denom (fixture->split), ==, denom);
 }

commit 3889606dd6779564341247ec796a905b54d36426
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Mar 10 13:21:02 2017 -0800

    Bug 779217 - Transactions rounded to 5 decimal places when opening file.
    
    xaccSplitSetValue and xaccSplitSetAmount round to the denominator found by
    get_currency_denom and get_commodity_denom. The problem was that if the
    commodity was unfindable because either the split’s parent or account hadn’t
    been set (as is the case during loading, because the parent isn’t yet complete)
    the returned denominator would be 100000, smaller than the max supported.
    That would cause the value/amount to be prematurely rounded.

diff --git a/src/engine/Split.c b/src/engine/Split.c
index 8d34c23..6ed3a4e 100644
--- a/src/engine/Split.c
+++ b/src/engine/Split.c
@@ -928,7 +928,7 @@ get_currency_denom(const Split * s)
     }
     else if (!s->parent || !s->parent->common_currency)
     {
-        return 100000;
+        return 1000000; /* Max supported denom to avoid premature rounding. */
     }
     else
     {
@@ -945,7 +945,7 @@ get_commodity_denom(const Split * s)
     }
     else if (!s->acc)
     {
-        return 100000;
+        return 1000000; /* Max supported denom to avoid premature rounding. */
     }
     else
     {

commit bc50f3da005d707067a83d74852ad1bcc69f857b
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Mar 10 10:54:22 2017 -0800

    Bug 777949 - Accounts implicitly created in ledger attempt creation twice
    
    Guard against recursively calling the account doesn’t exist query or creation
    dialog if one is already in the account creation dialog.
    
    The underlying problem is that creating the dialog forces a UI update that
    in turn sets the cell value and checks for the existence of the account.
    In basic view the cell being displayed (“transfer”) isn’t the one being
    changed (“account”) so the account check isn’t invoked, but in
    multi-split view the “account” cell *is* displayed so the check is invoked
    again.

diff --git a/src/register/ledger-core/split-register.c b/src/register/ledger-core/split-register.c
index 3e4eb74..2e2aebd 100644
--- a/src/register/ledger-core/split-register.c
+++ b/src/register/ledger-core/split-register.c
@@ -1833,6 +1833,7 @@ gnc_split_register_get_account_by_name (SplitRegister *reg, BasicCell * bcell,
     char *account_name;
     ComboCell *cell = (ComboCell *) bcell;
     Account *account;
+    static gboolean creating_account = FALSE;
 
     if (!name || (strlen(name) == 0))
         return NULL;
@@ -1842,15 +1843,16 @@ gnc_split_register_get_account_by_name (SplitRegister *reg, BasicCell * bcell,
     if (!account)
         account = gnc_account_lookup_by_code(gnc_get_current_root_account(), name);
 
-    if (!account)
+    if (!account && !creating_account)
     {
         /* Ask if they want to create a new one. */
         if (!gnc_verify_dialog (gnc_split_register_get_parent (reg),
                                 TRUE, missing, name))
             return NULL;
-
+        creating_account = TRUE;
         /* User said yes, they want to create a new account. */
         account = gnc_ui_new_accounts_from_name_window (name);
+        creating_account = FALSE;
         if (!account)
             return NULL;
     }

commit 97598c430693239d6aeab9dc4ff6f49e789cebff
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu Mar 9 11:38:42 2017 -0800

    Bug 776564 - Creating a scheduled transaction from an existing...
    
    transaction does not include the notes field.
    
    In fact, notes support was entirely missing from scheduled transactions.

diff --git a/src/engine/SX-ttinfo.c b/src/engine/SX-ttinfo.c
index 052d964..7af023f 100644
--- a/src/engine/SX-ttinfo.c
+++ b/src/engine/SX-ttinfo.c
@@ -30,9 +30,9 @@
 /* KvpFrame policy? */
 struct TTInfo_s
 {
-    /* FIXME add notes field */
     char *description; /* owned by us */
     char *num;         /* owned  by us */
+    char *notes;
     gnc_commodity *common_currency; /* not freed */
 
     GList *splits; /* list of template splits, owned by us */
@@ -67,6 +67,7 @@ void gnc_ttinfo_free(TTInfo *info)
 
     g_free(info->description);
     g_free(info->num);
+    g_free (info->notes);
     g_list_foreach(info->splits,
                    delete_splitinfo,
                    NULL);
@@ -127,6 +128,28 @@ gnc_ttinfo_get_num(TTInfo *tti)
     return tti->num;
 }
 
+void
+gnc_ttinfo_set_notes (TTInfo *tti, const char *notes)
+{
+    g_return_if_fail (tti);
+
+    if (tti->notes)
+    {
+        g_free (tti->notes);
+    }
+
+    tti->notes = g_strdup (notes);
+
+    return;
+}
+
+const char*
+gnc_ttinfo_get_notes (TTInfo *tti)
+{
+    g_return_val_if_fail (tti, NULL);
+
+    return tti->notes;
+}
 
 void
 gnc_ttinfo_set_currency(TTInfo *tti, gnc_commodity *common_currency)
diff --git a/src/engine/SX-ttinfo.h b/src/engine/SX-ttinfo.h
index 0844757..72486f7 100644
--- a/src/engine/SX-ttinfo.h
+++ b/src/engine/SX-ttinfo.h
@@ -41,7 +41,7 @@ void gnc_ttinfo_free(TTInfo *info);
 /* these two deep-copy their arguments */
 void gnc_ttinfo_set_description(TTInfo *tti, const char *description);
 void gnc_ttinfo_set_num(TTInfo *tti, const char *num);
-
+void gnc_ttinfo_set_notes (TTInfo *tti, const char *notes);
 
 /* this one points to a persistent pointer so ownership isn't relevant */
 void gnc_ttinfo_set_currency(TTInfo *tti, gnc_commodity *common_currency);
@@ -52,6 +52,7 @@ void gnc_ttinfo_set_template_splits(TTInfo *tti, GList *splits);
 
 const char    * gnc_ttinfo_get_description(TTInfo *tti);
 const char    * gnc_ttinfo_get_num(TTInfo *tti);
+const char *gnc_ttinfo_get_notes (TTInfo *tti);
 gnc_commodity * gnc_ttinfo_get_currency(TTInfo *tti);
 GList         * gnc_ttinfo_get_template_splits(TTInfo *tti);
 
diff --git a/src/engine/SchedXaction.c b/src/engine/SchedXaction.c
index 1bdcb0b..23ffb1f 100644
--- a/src/engine/SchedXaction.c
+++ b/src/engine/SchedXaction.c
@@ -1039,6 +1039,7 @@ xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list,
          * xaccTransSetNum with these arguments */
         gnc_set_num_action(new_trans, NULL,
                         gnc_ttinfo_get_num(tti), NULL);
+        xaccTransSetNotes (new_trans, gnc_ttinfo_get_notes (tti));
         xaccTransSetCurrency( new_trans,
                               gnc_ttinfo_get_currency(tti) );
 
diff --git a/src/gnome/dialog-sx-from-trans.c b/src/gnome/dialog-sx-from-trans.c
index 596512c..f8be47b 100644
--- a/src/gnome/dialog-sx-from-trans.c
+++ b/src/gnome/dialog-sx-from-trans.c
@@ -221,6 +221,7 @@ sxftd_add_template_trans(SXFromTransInfo *sxfti)
 
     gnc_ttinfo_set_description(tti, xaccTransGetDescription(tr));
     gnc_ttinfo_set_num(tti, gnc_get_num_action(tr, NULL));
+    gnc_ttinfo_set_notes (tti, xaccTransGetNotes (tr));
     gnc_ttinfo_set_currency(tti, xaccTransGetCurrency(tr));
 
     for (splits = xaccTransGetSplitList(tr); splits; splits = splits->next)

commit 03ff5d3778c9d3148f08b72dca0b984a36ec74df
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Sat Mar 4 12:25:56 2017 +0100

    Allow only date entry for opening balances on new accounts
    
    This anomaly was spotted by Christopher Lam

diff --git a/src/gnome-utils/dialog-account.c b/src/gnome-utils/dialog-account.c
index c4895b5..66a1317 100644
--- a/src/gnome-utils/dialog-account.c
+++ b/src/gnome-utils/dialog-account.c
@@ -1373,7 +1373,7 @@ gnc_account_window_create(AccountWindow *aw)
     gtk_label_set_mnemonic_widget (GTK_LABEL(label), amount);
 
     box = GTK_WIDGET(gtk_builder_get_object (builder, "opening_balance_date_box"));
-    date_edit = gnc_date_edit_new (gnc_time (NULL), 1, 1);
+    date_edit = gnc_date_edit_new (gnc_time (NULL), 0, 0);
     aw->opening_balance_date_edit = date_edit;
     gtk_box_pack_start(GTK_BOX(box), date_edit, TRUE, TRUE, 0);
     gtk_widget_show (date_edit);



Summary of changes:
 src/engine/SX-ttinfo.c                            | 25 +++++++++++++++-
 src/engine/SX-ttinfo.h                            |  3 +-
 src/engine/SchedXaction.c                         |  1 +
 src/engine/Split.c                                |  4 +--
 src/engine/gncInvoice.c                           |  6 +++-
 src/engine/test/utest-Split.cpp                   |  6 ++--
 src/gnome-utils/dialog-account.c                  |  2 +-
 src/gnome/dialog-sx-from-trans.c                  |  1 +
 src/register/ledger-core/split-register.c         |  6 ++--
 src/report/business-reports/taxinvoice.eguile.scm | 36 ++++++++++++-----------
 src/report/business-reports/taxinvoice.scm        |  3 ++
 11 files changed, 65 insertions(+), 28 deletions(-)



More information about the gnucash-changes mailing list