gnucash master: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Sat Mar 4 04:39:44 EST 2017


Updated	 via  https://github.com/Gnucash/gnucash/commit/be260a43 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/de360cab (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3445ef88 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/78c5203d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ece85970 (commit)
	from  https://github.com/Gnucash/gnucash/commit/3e9d0c1f (commit)



commit be260a4305a77b6c481cb9aaba3e329c1d54a438
Merge: 3e9d0c1 de360ca
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Sat Mar 4 10:28:31 2017 +0100

    Merge branch 'maint'


commit de360cabb33395c2dd668b08b7b8c12dd6e33b80
Author: hcrohland <christoph at Hobbes.fritz.box>
Date:   Thu Mar 2 20:53:40 2017 +0100

    Revert the taxinvoice.scm changes
    
    Since they touch strings and user behavior they cannot go into maint.
    The pull request now only includes the backend change. By that you can
    easily tweak the invoice reports to show the net price.

diff --git a/src/report/business-reports/taxinvoice.eguile.scm b/src/report/business-reports/taxinvoice.eguile.scm
index e5fa8ea..74aa684 100644
--- a/src/report/business-reports/taxinvoice.eguile.scm
+++ b/src/report/business-reports/taxinvoice.eguile.scm
@@ -311,7 +311,7 @@
             (inv-total (gnc:make-commodity-collector)))
         (for entry in entries do
             (let ((qty       (gncEntryGetDocQuantity entry credit-note?))
-                  (each      (gncEntryGetPrice entry #t opt-netprice))
+                  (each      (gncEntryGetInvPrice entry)) 
                   (action    (gncEntryGetAction entry)) 
                   (rval      (gncEntryGetDocValue entry #t #t credit-note?)) 
                   (rdiscval  (gncEntryGetDocDiscountValue entry #t #t credit-note?)) 
diff --git a/src/report/business-reports/taxinvoice.scm b/src/report/business-reports/taxinvoice.scm
index 59e6cb7..16a925e 100644
--- a/src/report/business-reports/taxinvoice.scm
+++ b/src/report/business-reports/taxinvoice.scm
@@ -108,7 +108,6 @@
 (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"))
@@ -177,7 +176,6 @@
 (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" 
@@ -290,7 +288,6 @@
          (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 3445ef8845315dbe06b4f9a9296fd0b7181bd4f9
Author: hcrohland <christoph at hobbes.fritz.box>
Date:   Wed Mar 1 18:22:02 2017 +0100

    Make the net price option better compatible with master
    
    Create one gncEntryGetPrice function which can create given price or
    net price for both invoices and bills based on option parameters.
    The master version of taxinvoice.eguile.scm needs this for bills too.

diff --git a/src/engine/gncEntry.c b/src/engine/gncEntry.c
index 5539aaa..f63fd34 100644
--- a/src/engine/gncEntry.c
+++ b/src/engine/gncEntry.c
@@ -1423,25 +1423,34 @@ static gnc_numeric gncEntryGetIntDiscountValue (GncEntry *entry, gboolean round,
         return (is_cust_doc ? entry->i_disc_value : gnc_numeric_zero());
 }
 
-gnc_numeric gncEntryGetInvNetPrice (const GncEntry *entry)
+gnc_numeric gncEntryGetPrice (const GncEntry *entry, gboolean cust_doc, gboolean net)
 {
-    gnc_numeric result = gnc_numeric_zero();
-    if (entry)
-    {
-	int denom;
+    gnc_numeric result;
+    int denom;
+
+    if (!entry) return gnc_numeric_zero();
+    if (!net) return (cust_doc ? entry->i_price : entry->b_price);
 	
-	/* Determine the commodity denominator */
-	denom = get_entry_commodity_denom (entry);
+    /* Determine the commodity denominator */
+    denom = get_entry_commodity_denom (entry);
       
-	/* Compute the invoice values */
-	gncEntryComputeValueInt (entry->quantity, entry->i_price,
-				 (entry->i_taxable ? entry->i_tax_table : NULL),
-				 entry->i_taxincluded,
-				 entry->i_discount, entry->i_disc_type,
-				 entry->i_disc_how,
-				 denom,
-				 NULL, NULL, NULL, &result);
-    }
+    /* Compute the net price */
+    if (cust_doc)
+        gncEntryComputeValueInt (entry->quantity, entry->i_price,
+                                 (entry->i_taxable ? entry->i_tax_table : NULL),
+                                 entry->i_taxincluded,
+                                 entry->i_discount, entry->i_disc_type,
+                                 entry->i_disc_how,
+                                 denom,
+                                 NULL, NULL, NULL, &result);
+    else
+        gncEntryComputeValueInt (entry->quantity, entry->b_price,
+                                 (entry->b_taxable ? entry->b_tax_table : NULL),
+                                 entry->b_taxincluded,
+                                 gnc_numeric_zero(), GNC_AMT_TYPE_VALUE, GNC_DISC_PRETAX,
+                                 denom,
+                                 NULL, NULL, NULL, &result);
+
     return result;
 }
 
diff --git a/src/engine/gncEntry.h b/src/engine/gncEntry.h
index 1be0d64..8440396 100644
--- a/src/engine/gncEntry.h
+++ b/src/engine/gncEntry.h
@@ -182,7 +182,7 @@ gnc_numeric gncEntryGetDocQuantity (const GncEntry *entry, gboolean is_cn);
  @{ */
 Account * gncEntryGetInvAccount (const GncEntry *entry);
 gnc_numeric gncEntryGetInvPrice (const GncEntry *entry);
-gnc_numeric gncEntryGetInvNetPrice (const GncEntry *entry);
+gnc_numeric gncEntryGetPrice (const GncEntry *entry, const gboolean cust_doc, const gboolean net);
 gnc_numeric gncEntryGetInvDiscount (const GncEntry *entry);
 GncAmountType gncEntryGetInvDiscountType (const GncEntry *entry);
 GncDiscountHow gncEntryGetInvDiscountHow (const GncEntry *entry);
diff --git a/src/report/business-reports/taxinvoice.eguile.scm b/src/report/business-reports/taxinvoice.eguile.scm
index 8a985cf..e5fa8ea 100644
--- a/src/report/business-reports/taxinvoice.eguile.scm
+++ b/src/report/business-reports/taxinvoice.eguile.scm
@@ -311,7 +311,7 @@
             (inv-total (gnc:make-commodity-collector)))
         (for entry in entries do
             (let ((qty       (gncEntryGetDocQuantity entry credit-note?))
-                  (each      (if opt-netprice (gncEntryGetInvNetPrice entry) (gncEntryGetInvPrice entry))) 
+                  (each      (gncEntryGetPrice entry #t opt-netprice))
                   (action    (gncEntryGetAction entry)) 
                   (rval      (gncEntryGetDocValue entry #t #t credit-note?)) 
                   (rdiscval  (gncEntryGetDocDiscountValue entry #t #t credit-note?)) 

commit 78c5203d8c683adfddf7212b7f3b676b644efc6b
Author: hcrohland <christoph at Hobbes.fritz.box>
Date:   Fri Feb 3 08:44:08 2017 +0100

    Enable taxinvoice to show net price
    
    Add gncEntryGetNetPrice
    Create an option in taxinvoice to either use gncEntryGetNetPrice or
    gncEntryGetPrice
    
    So far taxinvoice would show net or gross prices dependent on the internal flag tax_included.
    This is inconsistent for the reader of the invoice since there is no notion of that flag.
    This patch adds the option to always show net prices.
    It does not change the default behaviour even if I would consider it broken.

diff --git a/src/engine/gncEntry.c b/src/engine/gncEntry.c
index 7245829..5539aaa 100644
--- a/src/engine/gncEntry.c
+++ b/src/engine/gncEntry.c
@@ -1071,12 +1071,12 @@ GncOrder * gncEntryGetOrder (const GncEntry *entry)
  * The discount return value is just for entertainment -- you may want
  * to let a consumer know how much they saved.
  */
-void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
-                           const GncTaxTable *tax_table, gboolean tax_included,
-                           gnc_numeric discount, GncAmountType discount_type,
-                           GncDiscountHow discount_how, int SCU,
-                           gnc_numeric *value, gnc_numeric *discount_value,
-                           GList **tax_value)
+static void gncEntryComputeValueInt (gnc_numeric qty, gnc_numeric price,
+				    const GncTaxTable *tax_table, gboolean tax_included,
+				    gnc_numeric discount, GncAmountType discount_type,
+				    GncDiscountHow discount_how, int SCU,
+				    gnc_numeric *value, gnc_numeric *discount_value,
+				    GList **tax_value, gnc_numeric *net_price)
 {
     gnc_numeric aggregate;
     gnc_numeric pretax;
@@ -1085,6 +1085,7 @@ void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
     gnc_numeric percent = gnc_numeric_create (100, 1);
     gnc_numeric tpercent = gnc_numeric_zero ();
     gnc_numeric tvalue = gnc_numeric_zero ();
+    gnc_numeric i_net_price = price;
 
     GList     * entries = gncTaxTableGetEntries (tax_table);
     GList     * node;
@@ -1136,6 +1137,10 @@ void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
                                           gnc_numeric_create (1, 1),
                                           GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD),
                                   GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
+	if (!gnc_numeric_zero_p(qty))
+	{
+	  i_net_price = gnc_numeric_div (pretax, qty, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
+	}
     }
     else
     {
@@ -1260,9 +1265,26 @@ void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
         *tax_value = taxes;
     }
 
+    if (net_price != NULL)
+    {
+      if (SCU) i_net_price = gnc_numeric_convert(i_net_price, SCU, GNC_HOW_RND_ROUND_HALF_UP);
+      *net_price = i_net_price;
+    }
+
     return;
 }
 
+void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
+                           const GncTaxTable *tax_table, gboolean tax_included,
+                           gnc_numeric discount, GncAmountType discount_type,
+                           GncDiscountHow discount_how, int SCU,
+                           gnc_numeric *value, gnc_numeric *discount_value,
+                           GList **tax_value)
+{
+  gncEntryComputeValueInt (qty, price, tax_table, tax_included, discount, discount_type,
+			   discount_how, SCU, value, discount_value, tax_value, NULL);
+}
+
 static int
 get_entry_commodity_denom (const GncEntry *entry)
 {
@@ -1401,6 +1423,28 @@ static gnc_numeric gncEntryGetIntDiscountValue (GncEntry *entry, gboolean round,
         return (is_cust_doc ? entry->i_disc_value : gnc_numeric_zero());
 }
 
+gnc_numeric gncEntryGetInvNetPrice (const GncEntry *entry)
+{
+    gnc_numeric result = gnc_numeric_zero();
+    if (entry)
+    {
+	int denom;
+	
+	/* Determine the commodity denominator */
+	denom = get_entry_commodity_denom (entry);
+      
+	/* Compute the invoice values */
+	gncEntryComputeValueInt (entry->quantity, entry->i_price,
+				 (entry->i_taxable ? entry->i_tax_table : NULL),
+				 entry->i_taxincluded,
+				 entry->i_discount, entry->i_disc_type,
+				 entry->i_disc_how,
+				 denom,
+				 NULL, NULL, NULL, &result);
+    }
+    return result;
+}
+
 gnc_numeric gncEntryGetDocValue (GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn)
 {
     gnc_numeric value = gncEntryGetIntValue (entry, round, is_cust_doc);
diff --git a/src/engine/gncEntry.h b/src/engine/gncEntry.h
index d0d121e..1be0d64 100644
--- a/src/engine/gncEntry.h
+++ b/src/engine/gncEntry.h
@@ -182,6 +182,7 @@ gnc_numeric gncEntryGetDocQuantity (const GncEntry *entry, gboolean is_cn);
  @{ */
 Account * gncEntryGetInvAccount (const GncEntry *entry);
 gnc_numeric gncEntryGetInvPrice (const GncEntry *entry);
+gnc_numeric gncEntryGetInvNetPrice (const GncEntry *entry);
 gnc_numeric gncEntryGetInvDiscount (const GncEntry *entry);
 GncAmountType gncEntryGetInvDiscountType (const GncEntry *entry);
 GncDiscountHow gncEntryGetInvDiscountHow (const GncEntry *entry);
diff --git a/src/report/business-reports/taxinvoice.eguile.scm b/src/report/business-reports/taxinvoice.eguile.scm
index 74aa684..8a985cf 100644
--- a/src/report/business-reports/taxinvoice.eguile.scm
+++ b/src/report/business-reports/taxinvoice.eguile.scm
@@ -311,7 +311,7 @@
             (inv-total (gnc:make-commodity-collector)))
         (for entry in entries do
             (let ((qty       (gncEntryGetDocQuantity entry credit-note?))
-                  (each      (gncEntryGetInvPrice entry)) 
+                  (each      (if opt-netprice (gncEntryGetInvNetPrice entry) (gncEntryGetInvPrice entry))) 
                   (action    (gncEntryGetAction entry)) 
                   (rval      (gncEntryGetDocValue entry #t #t credit-note?)) 
                   (rdiscval  (gncEntryGetDocDiscountValue entry #t #t credit-note?)) 
diff --git a/src/report/business-reports/taxinvoice.scm b/src/report/business-reports/taxinvoice.scm
index 16a925e..59e6cb7 100644
--- a/src/report/business-reports/taxinvoice.scm
+++ b/src/report/business-reports/taxinvoice.scm
@@ -108,6 +108,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"))
@@ -176,6 +177,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" 
@@ -288,6 +290,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 ece859705de339ab483b23895b8f4d76ba0cef2b
Author: sdementen <sdementen at users.noreply.github.com>
Date:   Sat Feb 18 16:38:46 2017 +0100

    add gnc_get_current_session to swig interface

diff --git a/src/app-utils/app-utils.i b/src/app-utils/app-utils.i
index a27c15f..434b830 100644
--- a/src/app-utils/app-utils.i
+++ b/src/app-utils/app-utils.i
@@ -66,6 +66,7 @@ typedef int GNCOptionDBHandle;
 void gnc_prefs_init();
 
 QofBook * gnc_get_current_book (void);
+QofSession * gnc_get_current_session (void);
 const gchar * gnc_get_current_book_tax_name (void);
 const gchar * gnc_get_current_book_tax_type (void);
 Account * gnc_get_current_root_account (void);



Summary of changes:
 src/app-utils/app-utils.i |  1 +
 src/engine/gncEntry.c     | 65 ++++++++++++++++++++++++++++++++++++++++++-----
 src/engine/gncEntry.h     |  1 +
 3 files changed, 61 insertions(+), 6 deletions(-)



More information about the gnucash-changes mailing list