gnucash maint: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Sat May 21 09:40:33 EDT 2016


Updated	 via  https://github.com/Gnucash/gnucash/commit/efbe26bc (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5ef9b812 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fa22986c (commit)
	from  https://github.com/Gnucash/gnucash/commit/f7dfd65b (commit)



commit efbe26bc2619f318148bf9ff3edd69af5b2b9818
Author: Geert Janssens <janssens-geert at telenet.be>
Date:   Sat May 21 15:39:07 2016 +0200

    Bug 736352 - Expense Voucher adds tax automatically
    
    Expense vouchers don't use tax tables, so prevent autocomplete
    from setting one anyway.

diff --git a/src/business/business-ledger/gncEntryLedgerControl.c b/src/business/business-ledger/gncEntryLedgerControl.c
index ed8768b..96110a5 100644
--- a/src/business/business-ledger/gncEntryLedgerControl.c
+++ b/src/business/business-ledger/gncEntryLedgerControl.c
@@ -499,15 +499,10 @@ gnc_entry_ledger_auto_completion (GncEntryLedger *ledger,
         return FALSE;
 
     /* Ok, we are sure we want to trigger auto-completion. Now find an
-     * entry to copy the values from.  FIXME: Currently we only use
-     * the entries from the current invoice/bill, but it would be
-     * better to draw this from a larger set of entries. */
+     * entry to copy the values from. */
     auto_entry =
         /* Use this for book-wide auto-completion of the invoice entries */
         find_entry_in_book_by_desc(ledger, desc);
-    /* #else */
-    /*     gnc_find_entry_in_reg_by_desc(ledger, desc); */
-    /* #endif */
 
     if (auto_entry == NULL)
         return FALSE;
@@ -596,26 +591,39 @@ gnc_entry_ledger_auto_completion (GncEntryLedger *ledger,
             taxincluded = gncEntryGetInvTaxIncluded (auto_entry);
             taxtable = gncEntryGetInvTaxTable (auto_entry);
             break;
-        default:
+        case GNCENTRY_BILL_ENTRY:
+        case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
             taxable = gncEntryGetBillTaxable (auto_entry);
             taxincluded = gncEntryGetBillTaxIncluded (auto_entry);
             taxtable = gncEntryGetBillTaxTable (auto_entry);
             break;
+        default:
+            break;
         }
 
-        /* Taxable? cell */
-        cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_TAXABLE_CELL);
-        gnc_checkbox_cell_set_flag ((CheckboxCell *) cell, taxable);
-        gnc_basic_cell_set_changed (cell, TRUE);
-
-        /* taxincluded? cell */
-        cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_TAXINCLUDED_CELL);
-        gnc_checkbox_cell_set_flag ((CheckboxCell *) cell, taxincluded);
-        gnc_basic_cell_set_changed (cell, TRUE);
-
-        /* Taxable? cell */
-        cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_TAXTABLE_CELL);
-        set_value_combo_cell(cell, gncTaxTableGetName (taxtable));
+        switch (ledger->type)
+        {
+        case GNCENTRY_INVOICE_ENTRY:
+        case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
+        case GNCENTRY_BILL_ENTRY:
+        case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
+            /* Taxable? cell */
+            cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_TAXABLE_CELL);
+            gnc_checkbox_cell_set_flag ((CheckboxCell *) cell, taxable);
+            gnc_basic_cell_set_changed (cell, TRUE);
+
+            /* taxincluded? cell */
+            cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_TAXINCLUDED_CELL);
+            gnc_checkbox_cell_set_flag ((CheckboxCell *) cell, taxincluded);
+            gnc_basic_cell_set_changed (cell, TRUE);
+
+            /* Taxable? cell */
+            cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_TAXTABLE_CELL);
+            set_value_combo_cell(cell, gncTaxTableGetName (taxtable));
+            break;
+        default:
+            break;
+        }
     }
 
 

commit 5ef9b8121eb4e1e4247d0f851d983620bb8b0a4b
Author: Geert Janssens <janssens-geert at telenet.be>
Date:   Sat May 21 15:04:19 2016 +0200

    Bug 766200 - Three-up printing does not position the third check properly
    
    Handle drawing translations properly
    - take empty checks into account on first page both when printing
      one check only (bug 693342) and when printing multiple
      checks
    - fix page level translations, should only be called once
    - draw debug grid once for each page instead of for each check
    
    To be mentioned in release notes:
    A few bugs in the calculation of check positions while printing checks have been corrected. If you manually edited the check formats to compensate for these positioning errors in previous versions of gnucash, you may have to undo these changes. Please check this before printing your next check.

diff --git a/src/gnome/dialog-print-check.c b/src/gnome/dialog-print-check.c
index 9d3913a..6d6a7c4 100644
--- a/src/gnome/dialog-print-check.c
+++ b/src/gnome/dialog-print-check.c
@@ -2238,33 +2238,19 @@ draw_check_format(GtkPrintContext *context, gint position,
                   check_format_t *format, gpointer user_data)
 {
     PrintCheckDialog *pcd = (PrintCheckDialog *) user_data;
-    cairo_t *cr;
     gdouble x, y, r, multip;
+    cairo_t *cr = gtk_print_context_get_cairo_context(context);
 
-    cr = gtk_print_context_get_cairo_context(context);
-    cairo_translate(cr, format->trans_x, format->trans_y);
-    g_debug("Page translated by %f,%f", format->trans_x, format->trans_y);
-    cairo_rotate(cr, format->rotation * DEGREES_TO_RADIANS);
-    g_debug("Page rotated by %f degrees", format->rotation);
-
-    /* The grid is useful when determining check layouts */
-    if (format->show_grid)
-    {
-        draw_grid(context,
-                  gtk_print_context_get_width(context),
-                  gtk_print_context_get_height(context),
-                  pcd->default_font);
-    }
-
-    /* Translate all subsequent check items if requested.
-     * For check position 0, no translation is needed. */
+    /* Translate all subsequent check items if required. */
     if ((position > 0) && (position < pcd->position_max))
     {
         /* Standard positioning is used.
          * Note that the first check on the page (position 0) doesn't
          * need to be moved (hence the test for position > 0 above. */
-        cairo_translate(cr, 0, position * format->height);
-        g_debug("Position %d translated by %f (pre-defined)", position, position * format->height);
+        cairo_translate(cr, 0, format->height); /* Translation is relative to previous
+                                                   check translation, not to page border ! */
+        g_debug("Position %d translated by %f relative to previous check (pre-defined)", position, format->height);
+        g_debug("                      by %f relative to page (pre-defined)", position * format->height);
     }
     else if (position == pcd->position_max)
     {
@@ -2392,6 +2378,7 @@ draw_page(GtkPrintOperation *operation,
 {
     PrintCheckDialog *pcd = (PrintCheckDialog *) user_data;
     check_format_t *format;
+    cairo_t *cr = gtk_print_context_get_cairo_context(context);
 
     format = pcd->selected_format;
     if (format)
@@ -2401,6 +2388,7 @@ draw_page(GtkPrintOperation *operation,
         guint   check_count = g_list_length(pcd->splits);
         gint    check_number;
         gint    position = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->position_combobox));
+        gint    last_blank_check_pos;
         gint    checks_per_page;
         GList   *next_split;
 
@@ -2432,6 +2420,28 @@ draw_page(GtkPrintOperation *operation,
                 position = 0;
         }
 
+        /* Do page level translations/rotations */
+        cairo_translate(cr, format->trans_x, format->trans_y);
+        g_debug("Page translated by %f,%f", format->trans_x, format->trans_y);
+        cairo_rotate(cr, format->rotation * DEGREES_TO_RADIANS);
+        g_debug("Page rotated by %f degrees", format->rotation);
+
+        /* The grid is useful when determining check layouts */
+        if (format->show_grid)
+        {
+            draw_grid(context,
+                      gtk_print_context_get_width(context),
+                      gtk_print_context_get_height(context),
+                      pcd->default_font);
+        }
+
+        last_blank_check_pos = position - 1;
+        /* Optionally skip blank check positions if */
+        if ((page_nr == 0)                         /* on first page AND */
+                && (last_blank_check_pos > 0)      /* there's more than one blank check */
+                && (position < pcd->position_max)) /* but don't skip for custom positioning */
+            cairo_translate(cr, 0, format->height * last_blank_check_pos);
+
         for (check_number = first_check; check_number <= last_check;
                 check_number++, position++)
         {

commit fa22986c9bcee4729dac8db4e754d8d581df604d
Author: Geert Janssens <janssens-geert at telenet.be>
Date:   Sat May 21 14:23:20 2016 +0200

    Check printing: make logic easier to follow
    
    - rework formula to calculate number of pages so it's easier to understand by a human
    - add comments to clarify relations between position, position_max, first_page_count and so on

diff --git a/src/gnome/dialog-print-check.c b/src/gnome/dialog-print-check.c
index 1ec4c3e..9d3913a 100644
--- a/src/gnome/dialog-print-check.c
+++ b/src/gnome/dialog-print-check.c
@@ -2460,15 +2460,31 @@ begin_print(GtkPrintOperation *operation,
 {
     PrintCheckDialog *pcd = (PrintCheckDialog *) user_data;
     guint check_count = g_list_length(pcd->splits);
-    gint first_page_count;
     gint pages;
     gint position = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->position_combobox));
 
-    if (pcd->selected_format && pcd->position_max > 1 && position < pcd->position_max)
+    if (pcd->selected_format /* User selected a format other than custom */
+            && pcd->position_max > 1 /* The format has more than one check per page
+                                        (position_max is equivalent to custom
+                                        positioning, and there need to be at least two
+                                        other check defined positions (0 and 1), so
+                                        custom positioning should be at least
+                                        at position 2, i.e. >1) */
+            && position < pcd->position_max) /* User chose a check position other
+                                                then custom (which is always at
+                                                position_max in the list) */
     {
+        gint first_page_count, remaining_count;
+
         first_page_count = gtk_spin_button_get_value_as_int(pcd->first_page_count);
-        pages = ((check_count - first_page_count) + pcd->position_max - 1) /
-                pcd->position_max + 1;
+        remaining_count = check_count - first_page_count;
+        pages = 1                  /* First page, will have first_page_count checks */
+                + remaining_count / pcd->position_max;
+                                   /* Subsequent pages with all positions filled */
+        if ((remaining_count % pcd->position_max) > 0)
+            pages++;  /* Last page, not all positions are filled. Needs to be added
+                         separately because integer division rounds towards 0 and
+                         would omit the last checks if they didn't fill a full page */
     }
     else
         pages = check_count;



Summary of changes:
 .../business-ledger/gncEntryLedgerControl.c        | 48 ++++++++------
 src/gnome/dialog-print-check.c                     | 74 +++++++++++++++-------
 2 files changed, 78 insertions(+), 44 deletions(-)



More information about the gnucash-changes mailing list