gnucash master: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Wed May 4 21:51:15 EDT 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/a5cae6c5 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fcc3b27f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/674b49bd (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3dd179c6 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fccd0742 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e6eb0f32 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3f6962cf (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f292ed66 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/56fa5949 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7e4fcc7a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d62c6d96 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4d6dc384 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/396c59e3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5e9d0858 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7f316b8b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e381e706 (commit)
	from  https://github.com/Gnucash/gnucash/commit/ee7ed89b (commit)



commit a5cae6c5eb1b22a281f2eb39d15e4f6d5dbc3361
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu May 5 09:46:49 2022 +0800

    Don't export undefined functions

diff --git a/libgnucash/app-utils/app-utils.scm b/libgnucash/app-utils/app-utils.scm
index be5c5d9db..cb77eb7a6 100644
--- a/libgnucash/app-utils/app-utils.scm
+++ b/libgnucash/app-utils/app-utils.scm
@@ -30,9 +30,5 @@
                    (gnucash app-utils date-utilities)
                    (gnucash app-utils options)
                    (gnucash app-utils c-interface))
-;; gw-engine-spec.scm
-(re-export HOOK-SAVE-OPTIONS)
 
-(export gnc:get-debit-string)
-(export gnc:get-credit-string)
-(export gnc:config-file-format-version)
+(re-export HOOK-SAVE-OPTIONS)

commit fcc3b27f9255125150543e51505d76362aece0bc
Merge: ee7ed89b6 674b49bd8
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu May 5 09:46:44 2022 +0800

    Merge branch 'maint'


commit 674b49bd8dea735aa160adc4ff483977e019c165
Merge: f292ed66a 3dd179c61
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu May 5 08:23:31 2022 +0800

    Merge branch 'maint-stock-assistant' into maint #1328
    
    - add support for warnings in stock transaction assistant
    
    - warn if new transaction date is earlier than latest stock account
    transaction date
    
    - reorder pages - input date prior to input stock activity type,
    because the latter depends on the former.


commit 3dd179c611c110e7b91842f83f737f26bd6d0942
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed May 4 09:24:39 2022 +0800

    [assistant-stock-transaction] use std::optional

diff --git a/gnucash/gnome/assistant-stock-transaction.cpp b/gnucash/gnome/assistant-stock-transaction.cpp
index 220309079..75de287ee 100644
--- a/gnucash/gnome/assistant-stock-transaction.cpp
+++ b/gnucash/gnome/assistant-stock-transaction.cpp
@@ -28,6 +28,7 @@
 #include <string>
 #include <numeric>
 #include <algorithm>
+#include <optional>
 
 extern "C" {
 #include "Transaction.h"
@@ -428,7 +429,7 @@ typedef struct
     GtkWidget * window;
     GtkWidget * assistant;
 
-    const TxnTypeVec * txn_types;
+    std::optional<TxnTypeVec> txn_types;
     Account   * acct;
     gnc_commodity * currency;
 
@@ -436,7 +437,7 @@ typedef struct
     GtkWidget * transaction_type_page;
     GtkWidget * transaction_type_combo;
     GtkWidget * transaction_type_explanation;
-    const TxnTypeInfo * txn_type;
+    std::optional<TxnTypeInfo> txn_type;
 
     // transaction details page
     GtkWidget * transaction_details_page;
@@ -506,7 +507,10 @@ refresh_page_transaction_type (GtkWidget *widget, gpointer user_data)
     if (type_idx < 0)           // combo isn't initialized yet.
         return;
 
-    info->txn_type = &(info->txn_types->at (type_idx));
+    if (!info->txn_types)
+        return;
+
+    info->txn_type = info->txn_types->at (type_idx);
 
     gtk_label_set_text (GTK_LABEL (info->transaction_type_explanation),
                         _(info->txn_type->explanation));
@@ -823,9 +827,9 @@ stock_assistant_prepare (GtkAssistant  *assistant, GtkWidget *page,
         time64 date;
         date = gnc_date_edit_get_date_end (GNC_DATE_EDIT (info->date_edit));
         balance = xaccAccountGetBalanceAsOfDate (info->acct, date);
-        info->txn_types = gnc_numeric_zero_p (balance) ? &starting_types
-            : gnc_numeric_positive_p (balance) ? &long_types
-            : &short_types;
+        info->txn_types = gnc_numeric_zero_p (balance) ? starting_types
+            : gnc_numeric_positive_p (balance) ? long_types
+            : short_types;
         gtk_combo_box_text_remove_all (GTK_COMBO_BOX_TEXT (info->transaction_type_combo));
         for (auto& it : *(info->txn_types))
             gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (info->transaction_type_combo),

commit fccd07424d56c39a9f61e8965fff5343fc1cd2f1
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed May 4 09:18:36 2022 +0800

    [assistant-stock-transaction] reorder of Pages - date before type.
    
    Because the date may be in the past, and the stock balance at that
    date will dictate the available stock txn types available for
    creation.
    
    The available stock txn types is thus dependent on the desired date,
    and must only be initialized when preparing the txn_type page.

diff --git a/gnucash/gnome/assistant-stock-transaction.cpp b/gnucash/gnome/assistant-stock-transaction.cpp
index d9cecf7f8..220309079 100644
--- a/gnucash/gnome/assistant-stock-transaction.cpp
+++ b/gnucash/gnome/assistant-stock-transaction.cpp
@@ -58,8 +58,8 @@ static const char* ASSISTANT_STOCK_TRANSACTION_CM_CLASS = "assistant-stock-trans
 enum assistant_pages
 {
     PAGE_INTRO = 0,
+    PAGE_TRANSACTION_DETAILS,
     PAGE_TRANSACTION_TYPE,
-    PAGE_TRANSATION_DETAILS,
     PAGE_STOCK_AMOUNT,
     PAGE_STOCK_VALUE,
     PAGE_CASH,
@@ -817,8 +817,15 @@ stock_assistant_prepare (GtkAssistant  *assistant, GtkWidget *page,
 
     switch (currentpage)
     {
-    case PAGE_TRANSACTION_TYPE:
+    case PAGE_TRANSACTION_TYPE:;
         // initialize transaction types.
+        gnc_numeric balance;
+        time64 date;
+        date = gnc_date_edit_get_date_end (GNC_DATE_EDIT (info->date_edit));
+        balance = xaccAccountGetBalanceAsOfDate (info->acct, date);
+        info->txn_types = gnc_numeric_zero_p (balance) ? &starting_types
+            : gnc_numeric_positive_p (balance) ? &long_types
+            : &short_types;
         gtk_combo_box_text_remove_all (GTK_COMBO_BOX_TEXT (info->transaction_type_combo));
         for (auto& it : *(info->txn_types))
             gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (info->transaction_type_combo),
@@ -1143,11 +1150,6 @@ stock_assistant_create (StockTransactionInfo *info)
     // Set the name for this assistant so it can be easily manipulated with css
     gtk_widget_set_name (GTK_WIDGET(info->window), "gnc-id-assistant-stock-transaction");
 
-    auto balance = xaccAccountGetBalance (info->acct);
-    info->txn_types = gnc_numeric_zero_p (balance) ? &starting_types
-        : gnc_numeric_positive_p (balance) ? &long_types
-        : &short_types;
-
     info->currency = gnc_account_get_currency_or_parent (info->acct);
 
     /* Transaction Page Widgets */
diff --git a/gnucash/gtkbuilder/assistant-stock-transaction.glade b/gnucash/gtkbuilder/assistant-stock-transaction.glade
index 857f0d1b9..f011d2dcf 100644
--- a/gnucash/gtkbuilder/assistant-stock-transaction.glade
+++ b/gnucash/gtkbuilder/assistant-stock-transaction.glade
@@ -29,18 +29,18 @@
       </packing>
     </child>
     <child>
-      <object class="GtkBox" id="transaction_type_page">
+      <object class="GtkBox" id="transaction_details_page">
         <property name="visible">True</property>
         <property name="can-focus">False</property>
         <property name="margin-start">12</property>
         <property name="border-width">6</property>
         <property name="orientation">vertical</property>
         <child>
-          <object class="GtkLabel" id="transaction_type_page_label">
+          <object class="GtkLabel" id="transaction_details_label">
             <property name="visible">True</property>
             <property name="can-focus">False</property>
             <property name="margin-bottom">6</property>
-            <property name="label" translatable="yes">Select the type of stock activity that you wish to record. The available types depend on whether the current stock balance is positive, nil, or negative (i.e. when shorting stock). The type will determine the component splits.</property>
+            <property name="label" translatable="yes">Select the date and description for your records.</property>
             <property name="wrap">True</property>
           </object>
           <packing>
@@ -51,16 +51,16 @@
         </child>
         <child>
           <!-- n-columns=2 n-rows=2 -->
-          <object class="GtkGrid" id="transaction_type_table">
+          <object class="GtkGrid" id="transaction_details_table">
             <property name="visible">True</property>
             <property name="can-focus">False</property>
             <property name="row-spacing">3</property>
             <property name="column-spacing">6</property>
             <child>
-              <object class="GtkLabel" id="transaction_type_combo_label">
+              <object class="GtkLabel" id="transaction_date_label">
                 <property name="visible">True</property>
                 <property name="can-focus">False</property>
-                <property name="label" translatable="yes">Type</property>
+                <property name="label" translatable="yes">Date</property>
               </object>
               <packing>
                 <property name="left-attach">0</property>
@@ -68,26 +68,20 @@
               </packing>
             </child>
             <child>
-              <object class="GtkComboBoxText" id="transaction_type_page_combobox">
+              <object class="GtkLabel" id="transaction_description_label">
                 <property name="visible">True</property>
                 <property name="can-focus">False</property>
-                <items>
-                  <item>a1</item>
-                  <item>b2</item>
-                  <item>c3</item>
-                </items>
+                <property name="label" translatable="yes">Description</property>
               </object>
               <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">0</property>
+                <property name="left-attach">0</property>
+                <property name="top-attach">1</property>
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="transaction_type_page_explanation">
+              <object class="GtkEntry" id="transaction_description_entry">
                 <property name="visible">True</property>
-                <property name="can-focus">False</property>
-                <property name="label">label</property>
-                <property name="wrap">True</property>
+                <property name="can-focus">True</property>
               </object>
               <packing>
                 <property name="left-attach">1</property>
@@ -106,23 +100,23 @@
         </child>
       </object>
       <packing>
-        <property name="title" translatable="yes">Transaction Type</property>
+        <property name="title" translatable="yes">Transaction Details</property>
         <property name="complete">True</property>
       </packing>
     </child>
     <child>
-      <object class="GtkBox" id="transaction_details_page">
+      <object class="GtkBox" id="transaction_type_page">
         <property name="visible">True</property>
         <property name="can-focus">False</property>
         <property name="margin-start">12</property>
         <property name="border-width">6</property>
         <property name="orientation">vertical</property>
         <child>
-          <object class="GtkLabel" id="transaction_details_label">
+          <object class="GtkLabel" id="transaction_type_page_label">
             <property name="visible">True</property>
             <property name="can-focus">False</property>
             <property name="margin-bottom">6</property>
-            <property name="label" translatable="yes">Select the date and description for your records.</property>
+            <property name="label" translatable="yes">Select the type of stock activity that you wish to record. The available types depend on whether the current stock balance is positive, nil, or negative (i.e. when shorting stock). The type will determine the component splits.</property>
             <property name="wrap">True</property>
           </object>
           <packing>
@@ -133,16 +127,16 @@
         </child>
         <child>
           <!-- n-columns=2 n-rows=2 -->
-          <object class="GtkGrid" id="transaction_details_table">
+          <object class="GtkGrid" id="transaction_type_table">
             <property name="visible">True</property>
             <property name="can-focus">False</property>
             <property name="row-spacing">3</property>
             <property name="column-spacing">6</property>
             <child>
-              <object class="GtkLabel" id="transaction_date_label">
+              <object class="GtkLabel" id="transaction_type_combo_label">
                 <property name="visible">True</property>
                 <property name="can-focus">False</property>
-                <property name="label" translatable="yes">Date</property>
+                <property name="label" translatable="yes">Type</property>
               </object>
               <packing>
                 <property name="left-attach">0</property>
@@ -150,20 +144,26 @@
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="transaction_description_label">
+              <object class="GtkComboBoxText" id="transaction_type_page_combobox">
                 <property name="visible">True</property>
                 <property name="can-focus">False</property>
-                <property name="label" translatable="yes">Description</property>
+                <items>
+                  <item>a1</item>
+                  <item>b2</item>
+                  <item>c3</item>
+                </items>
               </object>
               <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">1</property>
+                <property name="left-attach">1</property>
+                <property name="top-attach">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkEntry" id="transaction_description_entry">
+              <object class="GtkLabel" id="transaction_type_page_explanation">
                 <property name="visible">True</property>
-                <property name="can-focus">True</property>
+                <property name="can-focus">False</property>
+                <property name="label">label</property>
+                <property name="wrap">True</property>
               </object>
               <packing>
                 <property name="left-attach">1</property>
@@ -182,7 +182,7 @@
         </child>
       </object>
       <packing>
-        <property name="title" translatable="yes">Transaction Details</property>
+        <property name="title" translatable="yes">Transaction Type</property>
         <property name="complete">True</property>
       </packing>
     </child>

commit e6eb0f328cb1a0293ee23782dee63541a23043bb
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed May 4 20:02:17 2022 +0800

    [assistant-stock-transaction] warn if TxnDate < latest Stock Txn

diff --git a/gnucash/gnome/assistant-stock-transaction.cpp b/gnucash/gnome/assistant-stock-transaction.cpp
index 31bb62dce..d9cecf7f8 100644
--- a/gnucash/gnome/assistant-stock-transaction.cpp
+++ b/gnucash/gnome/assistant-stock-transaction.cpp
@@ -694,6 +694,31 @@ refresh_page_finish (StockTransactionInfo *info)
     gnc_numeric credit = gnc_numeric_zero ();
     StringVec errors, warnings;
 
+    // check the stock transaction date. If there are existing stock
+    // transactions dated after the date specified, it is very likely
+    // the later stock transactions will be invalidated. warn the user
+    // to review them.
+    auto new_date = gnc_date_edit_get_date_end (GNC_DATE_EDIT (info->date_edit));
+    auto last_split = static_cast<const Split*> (g_list_last (xaccAccountGetSplitList (info->acct))->data);
+    auto last_split_date = xaccTransGetDate (xaccSplitGetParent (last_split));
+    if (new_date <= last_split_date)
+    {
+        auto last_split_date_str = qof_print_date (last_split_date);
+        auto new_date_str = qof_print_date (new_date);
+        // Translators: the first %s is the new transaction date;
+        // the second %s is the current stock account's latest
+        // transaction date.
+        auto warn_txt =  g_strdup_printf (_("You will enter a transaction \
+with date %s which is earlier than the latest transaction in this account, \
+dated %s. Doing so may affect the cost basis, and therefore capital gains, \
+of transactions dated after the new entry. Please review all transactions \
+to ensure proper recording."), new_date_str, last_split_date_str);
+        warnings.push_back (warn_txt);
+        g_free (warn_txt);
+        g_free (new_date_str);
+        g_free (last_split_date_str);
+    }
+
     if (info->txn_type->stock_amount != FieldMask::DISABLED)
     {
         auto stock_amount = gnc_amount_edit_get_amount

commit 3f6962cfcaad9a292852b0d170759e6ac29a2881
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon May 2 22:48:16 2022 +0800

    [assistant-stock-transaction] refactor to allow warnings
    
    Adds support for warnings, which can still allow creating a stock
    transaction.

diff --git a/gnucash/gnome/assistant-stock-transaction.cpp b/gnucash/gnome/assistant-stock-transaction.cpp
index 8b6b7b919..31bb62dce 100644
--- a/gnucash/gnome/assistant-stock-transaction.cpp
+++ b/gnucash/gnome/assistant-stock-transaction.cpp
@@ -692,7 +692,7 @@ refresh_page_finish (StockTransactionInfo *info)
 
     gnc_numeric debit = gnc_numeric_zero ();
     gnc_numeric credit = gnc_numeric_zero ();
-    StringVec errors;
+    StringVec errors, warnings;
 
     if (info->txn_type->stock_amount != FieldMask::DISABLED)
     {
@@ -763,23 +763,24 @@ refresh_page_finish (StockTransactionInfo *info)
         g_free (debit_str);
     }
 
-    if (errors.empty())
+    // generate final summary message. Collates a header, the errors
+    // and warnings. Then allow completion if errors is empty.
+    auto header = errors.empty() ?
+        N_("No errors found. Click Apply to create transaction.") :
+        N_("The following errors must be fixed:");
+    auto summary = std::string { _(header) };
+    auto summary_add = [&summary](auto a) { summary += "\n• "; summary += a; };
+    std::for_each (errors.begin(), errors.end(), summary_add);
+    if (!warnings.empty())
     {
-        auto success_msg = N_("No errors found. Click Apply to create transaction.");
-        gtk_assistant_set_page_complete (GTK_ASSISTANT (info->window),
-                                         info->finish_page, true);
-        gtk_label_set_text (GTK_LABEL (info->finish_summary), _(success_msg));
-    }
-    else
-    {
-        auto header_str = N_("The following errors must be fixed:");
-        auto header = std::string { _(header_str) };
-        auto fold = [](auto a, auto b) { return std::move(a) + '\n' + std::move(b); };
-        auto errmsg { std::accumulate (errors.begin(), errors.end(), header, fold) };
-        gtk_assistant_set_page_complete (GTK_ASSISTANT (info->window),
-                                         info->finish_page, false);
-        gtk_label_set_text (GTK_LABEL (info->finish_summary), errmsg.c_str());
+        auto warnings_header = N_ ("The following warnings exist:");
+        summary += "\n\n";
+        summary += _(warnings_header);
+        std::for_each (warnings.begin(), warnings.end(), summary_add);
     }
+    gtk_label_set_text (GTK_LABEL (info->finish_summary), summary.c_str());
+    gtk_assistant_set_page_complete (GTK_ASSISTANT (info->window),
+                                     info->finish_page, errors.empty());
 }
 
 void
diff --git a/gnucash/gtkbuilder/assistant-stock-transaction.glade b/gnucash/gtkbuilder/assistant-stock-transaction.glade
index 60f1defbf..857f0d1b9 100644
--- a/gnucash/gtkbuilder/assistant-stock-transaction.glade
+++ b/gnucash/gtkbuilder/assistant-stock-transaction.glade
@@ -896,6 +896,7 @@
           <object class="GtkScrolledWindow" id="finish_scrolled">
             <property name="visible">True</property>
             <property name="can-focus">True</property>
+            <property name="vscrollbar-policy">never</property>
             <child>
               <object class="GtkTreeView" id="transaction_view">
                 <property name="visible">True</property>
@@ -919,6 +920,7 @@
             <property name="visible">True</property>
             <property name="can-focus">False</property>
             <property name="label">summary of errors</property>
+            <property name="wrap">True</property>
           </object>
           <packing>
             <property name="expand">False</property>

commit f292ed66ab693700ac2439a9d7be0838f1a7ea81
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue May 3 00:16:51 2022 +0800

    [assistant-stock-transaction.glade] don't translate placeholder text

diff --git a/gnucash/gtkbuilder/assistant-stock-transaction.glade b/gnucash/gtkbuilder/assistant-stock-transaction.glade
index f8af8ecbc..60f1defbf 100644
--- a/gnucash/gtkbuilder/assistant-stock-transaction.glade
+++ b/gnucash/gtkbuilder/assistant-stock-transaction.glade
@@ -72,9 +72,9 @@
                 <property name="visible">True</property>
                 <property name="can-focus">False</property>
                 <items>
-                  <item translatable="yes">a1</item>
-                  <item translatable="yes">b2</item>
-                  <item translatable="yes">c3</item>
+                  <item>a1</item>
+                  <item>b2</item>
+                  <item>c3</item>
                 </items>
               </object>
               <packing>
@@ -86,7 +86,7 @@
               <object class="GtkLabel" id="transaction_type_page_explanation">
                 <property name="visible">True</property>
                 <property name="can-focus">False</property>
-                <property name="label" translatable="yes">label</property>
+                <property name="label">label</property>
                 <property name="wrap">True</property>
               </object>
               <packing>
@@ -333,7 +333,7 @@
                 <property name="visible">True</property>
                 <property name="can-focus">False</property>
                 <property name="halign">end</property>
-                <property name="label" translatable="yes">(autocalculated price)</property>
+                <property name="label">(autocalculated price)</property>
                 <property name="use-underline">True</property>
                 <property name="justify">center</property>
               </object>
@@ -918,7 +918,7 @@
           <object class="GtkLabel" id="finish_summary">
             <property name="visible">True</property>
             <property name="can-focus">False</property>
-            <property name="label" translatable="yes">summary of errors</property>
+            <property name="label">summary of errors</property>
           </object>
           <packing>
             <property name="expand">False</property>

commit 56fa5949f9ef47a248c924b4d3b313dcf82e8754
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon May 2 09:10:21 2022 +0800

    use (string-concatenate ...) instead of (apply string-append ...)
    
    similarly to a48e656ee, string-concatenate is less vulnerable to stack
    overflow. this was confirmed by wingo some time back.

diff --git a/gnucash/report/html-text.scm b/gnucash/report/html-text.scm
index 729ff491e..8ae63946f 100644
--- a/gnucash/report/html-text.scm
+++ b/gnucash/report/html-text.scm
@@ -170,8 +170,8 @@
            ((string? rendered-elt)
             rendered-elt)
            ((list? rendered-elt)
-            (apply string-append
-                   (gnc:html-document-tree-collapse rendered-elt)))
+            (string-concatenate
+             (gnc:html-document-tree-collapse rendered-elt)))
            (#t 
             (format #f "hold on there podner. form=~s\n" rendered-elt)
             ""))))

commit 7e4fcc7afbcde367ba37a5170fb25532053b7b23
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Apr 29 16:51:48 2022 -0700

    https://bugs.gnucash.org/show_bug.cgi?id=798491
    
    Prefer the entry date to the value date if present in the import.
    The invalid date part of the bug was fixed in 7b1c050.

diff --git a/gnucash/import-export/aqb/gnc-ab-utils.c b/gnucash/import-export/aqb/gnc-ab-utils.c
index 9707746b9..e8809eed2 100644
--- a/gnucash/import-export/aqb/gnc-ab-utils.c
+++ b/gnucash/import-export/aqb/gnc-ab-utils.c
@@ -580,8 +580,8 @@ gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc)
     QofBook *book;
     Transaction *gnc_trans;
     const gchar *fitid;
-    const GNC_GWEN_DATE *valuta_date;
-    time64 current_time;
+    const GNC_GWEN_DATE *value_date, *post_date;
+    time64 current_time, post_time;
     const char *custref;
     gchar *description;
     Split *split;
@@ -595,22 +595,28 @@ gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc)
     xaccTransBeginEdit(gnc_trans);
 
     /* Date / Time */
-    valuta_date = AB_Transaction_GetValutaDate(ab_trans);
-    if (!valuta_date)
-    {
-        const GNC_GWEN_DATE *normal_date = AB_Transaction_GetDate(ab_trans);
-        if (normal_date)
-            valuta_date = normal_date;
-    }
-    if (valuta_date)
-    {
-        time64 secs = gnc_gwen_date_to_time64(valuta_date);
-        xaccTransSetDatePostedSecsNormalized(gnc_trans, secs);
-    }
+    /* SWIFT import formats (in particular MT940) provide for two
+     * dates, the entry date and the value date (valuta is value in
+     * German). The value date is the effective date for financial
+     * calculation purposes and is mandatory, the entry date is the
+     * date that the financial institution posted the
+     * transaction. Since the entry date is normally closer to the
+     * date that the customer's book should recognize the transaction
+     * we prefer that date if present.
+     */
+    post_date = AB_Transaction_GetDate(ab_trans);
+    value_date = AB_Transaction_GetValutaDate(ab_trans);
+    if (post_date)
+         post_time = gnc_gwen_date_to_time64(post_date);
+    else if (value_date)
+         post_time = gnc_gwen_date_to_time64(value_date);
     else
     {
-        g_warning("transaction_cb: Oops, date 'valuta_date' was NULL");
+        g_warning("transaction_cb: Import had no transaction date");
+        post_time = gnc_time (NULL);
     }
+    xaccTransSetDatePostedSecsNormalized(gnc_trans, post_time);
+
     xaccTransSetDateEnteredSecs(gnc_trans, gnc_time (NULL));
 
     /* Currency.  We take simply the default currency of the gnucash account */

commit d62c6d96e31ea5bdfa7c8f159b67cbfefef3cf43
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Apr 29 15:50:41 2022 -0700

    [import matcher] Only append description if there's something to append to.
    
    Otherwise just set the new string.

diff --git a/gnucash/import-export/import-backend.c b/gnucash/import-export/import-backend.c
index 60a79077e..8b796ab94 100644
--- a/gnucash/import-export/import-backend.c
+++ b/gnucash/import-export/import-backend.c
@@ -841,25 +841,21 @@ void split_find_match (GNCImportTransInfo * trans_info,
 
 /* append the imported transaction description to the matched transaction description */
 static void
-desc_append (Transaction* selected_match_trans, Transaction* imp_trans)
+desc_append (Transaction* selected_match_trans, gchar *new_desc)
 {
-    gchar* tmp = g_strconcat( xaccTransGetDescription (selected_match_trans),
-                              "|",
-                              xaccTransGetDescription (imp_trans),
-                              NULL);
+    const gchar* curr_desc = xaccTransGetDescription (selected_match_trans);
+    gchar* tmp = g_strconcat(curr_desc, "|", new_desc, NULL);
     xaccTransSetDescription (selected_match_trans, tmp);
     g_free (tmp);
 }
 
 /* append the imported transaction notes to the matched transaction notes */
 static void
-notes_append (Transaction* selected_match_trans, Transaction* imp_trans)
+notes_append (Transaction* selected_match_trans, gchar* new_notes)
 {
-    gchar* tmp = g_strconcat (xaccTransGetNotes (selected_match_trans),
-                              "|",
-                              xaccTransGetNotes (imp_trans),
-                              NULL);
-    xaccTransSetNotes (selected_match_trans, tmp);
+    const gchar* curr_notes = xaccTransGetNotes (selected_match_trans);
+    gchar* tmp = g_strconcat (curr_notes, "|", new_notes, NULL);
+    xaccTransSetNotes (selected_match_trans, tmp );
     g_free (tmp);
 }
 
@@ -887,7 +883,7 @@ update_desc_and_notes (const GNCImportTransInfo* trans_info)
         note_imported =
             raw_str ? g_utf8_normalize (raw_str, -1, G_NORMALIZE_ALL) : NULL;
         raw_str = xaccTransGetNotes (selected_match->trans);
-        note_matched = 
+        note_matched =
            raw_str ? g_utf8_normalize (raw_str, -1, G_NORMALIZE_ALL) : NULL;
 
         // Append if desc_imported not already in desc_matched
@@ -895,14 +891,24 @@ update_desc_and_notes (const GNCImportTransInfo* trans_info)
             (!desc_matched ||
              g_utf8_strlen (desc_imported, -1) > g_utf8_strlen (desc_matched, -1) ||
              !strstr (desc_matched, desc_imported)))
-            desc_append (selected_match->trans, imp_trans);
+        {
+            if (desc_matched && *desc_matched)
+                desc_append (selected_match->trans, desc_imported);
+            else
+                xaccTransSetDescription (selected_match->trans, desc_imported);
+        }
 
         // Append if note_imported not already in note_matched
         if (note_imported &&
             (!note_matched ||
              g_utf8_strlen (note_imported, -1) > g_utf8_strlen (note_matched, -1) ||
              !strstr (note_matched, note_imported)))
-            notes_append (selected_match->trans, imp_trans);
+        {
+            if (note_matched && *note_matched)
+                notes_append (selected_match->trans, note_imported);
+            else
+                xaccTransSetNotes (selected_match->trans, note_imported);
+        }
 
         g_free(desc_imported);
         g_free(desc_matched);

commit 4d6dc384ee0f49d8c35e17c116c98647298d9529
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Apr 29 15:41:45 2022 -0700

    [import matcher] NULL protect g_utf8_normalize
    
    It crashes if fed a NULL string.
    May fix https://bugs.gnucash.org/show_bug.cgi?id=798483.

diff --git a/gnucash/import-export/import-backend.c b/gnucash/import-export/import-backend.c
index a993c3229..60a79077e 100644
--- a/gnucash/import-export/import-backend.c
+++ b/gnucash/import-export/import-backend.c
@@ -875,23 +875,33 @@ update_desc_and_notes (const GNCImportTransInfo* trans_info)
 
     if (trans_info->append_text)
     {
-        gchar* desc_imported = g_utf8_normalize (xaccTransGetDescription (
-            imp_trans), -1, G_NORMALIZE_ALL);
-        gchar* desc_matched = g_utf8_normalize (xaccTransGetDescription (
-            selected_match->trans), -1, G_NORMALIZE_ALL);
-        gchar* note_imported = g_utf8_normalize (xaccTransGetNotes (
-                imp_trans), -1, G_NORMALIZE_ALL);
-        gchar* note_matched = g_utf8_normalize (xaccTransGetNotes (
-            selected_match->trans), -1, G_NORMALIZE_ALL);
+        gchar *desc_imported, *desc_matched, *note_imported, *note_matched;
+        const gchar* raw_str = xaccTransGetDescription (imp_trans);
+
+        desc_imported =
+            raw_str ? g_utf8_normalize (raw_str, -1, G_NORMALIZE_ALL) : NULL;
+        raw_str = xaccTransGetDescription (selected_match->trans);
+        desc_matched =
+            raw_str ? g_utf8_normalize (raw_str, -1, G_NORMALIZE_ALL) : NULL;
+        raw_str = xaccTransGetNotes (imp_trans);
+        note_imported =
+            raw_str ? g_utf8_normalize (raw_str, -1, G_NORMALIZE_ALL) : NULL;
+        raw_str = xaccTransGetNotes (selected_match->trans);
+        note_matched = 
+           raw_str ? g_utf8_normalize (raw_str, -1, G_NORMALIZE_ALL) : NULL;
 
         // Append if desc_imported not already in desc_matched
-        if (g_utf8_strlen (desc_imported, -1) > g_utf8_strlen (desc_matched, -1) ||
-            !strstr (desc_matched, desc_imported))
+        if (desc_imported &&
+            (!desc_matched ||
+             g_utf8_strlen (desc_imported, -1) > g_utf8_strlen (desc_matched, -1) ||
+             !strstr (desc_matched, desc_imported)))
             desc_append (selected_match->trans, imp_trans);
 
         // Append if note_imported not already in note_matched
-        if (g_utf8_strlen (note_imported, -1) > g_utf8_strlen (note_matched, -1) ||
-            !strstr (note_matched, note_imported))
+        if (note_imported &&
+            (!note_matched ||
+             g_utf8_strlen (note_imported, -1) > g_utf8_strlen (note_matched, -1) ||
+             !strstr (note_matched, note_imported)))
             notes_append (selected_match->trans, imp_trans);
 
         g_free(desc_imported);

commit 396c59e3d7912ad5bd57a5f458ce8c5281076766
Author: Szia Tomi <sziatomi01 at gmail.com>
Date:   Fri Apr 29 03:08:25 2022 +0200

    Translation update  by Szia Tomi <sziatomi01 at gmail.com> using Weblate
    
    po/hu.po: 55.9% (3018 of 5390 strings; 1397 fuzzy)
    529 failing checks (9.8%)
    Translation: GnuCash/Program (Hungarian)
    Translate-URL: https://hosted.weblate.org/projects/gnucash/gnucash/hu/
    
    Co-authored-by: Szia Tomi <sziatomi01 at gmail.com>

diff --git a/po/hu.po b/po/hu.po
index 5b28210b1..24aa3e6c3 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -5,14 +5,15 @@
 # SULYOK Péter <peti at sulyok.hu>, 2003-2006.
 # Kornel Tako <takokornel at gmail.com>, 2007.
 # Kárász Attila <cult.edie at gmail.com>, 2022.
+# Szia Tomi <sziatomi01 at gmail.com>, 2022.
 msgid ""
 msgstr ""
 "Project-Id-Version: GnuCash 4.9-pre1\n"
 "Report-Msgid-Bugs-To: https://bugs.gnucash.org/enter_bug."
 "cgi?product=GnuCash&component=Translations\n"
 "POT-Creation-Date: 2022-03-09 18:00-0800\n"
-"PO-Revision-Date: 2022-04-20 12:13+0000\n"
-"Last-Translator: Kárász Attila <cult.edie at gmail.com>\n"
+"PO-Revision-Date: 2022-04-29 01:08+0000\n"
+"Last-Translator: Szia Tomi <sziatomi01 at gmail.com>\n"
 "Language-Team: Hungarian <https://hosted.weblate.org/projects/gnucash/"
 "gnucash/hu/>\n"
 "Language: hu\n"
@@ -20,7 +21,7 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=1; plural=0;\n"
-"X-Generator: Weblate 4.12-dev\n"
+"X-Generator: Weblate 4.12.1-dev\n"
 
 # #-#-#-#-#  epiphany.HEAD.hu.po-new.po (Epiphany CVS)  #-#-#-#-#
 # src/trans.h:283
@@ -3429,8 +3430,8 @@ msgid_plural ""
 "There are no Scheduled Transactions to be entered at this time. (%d "
 "transactions automatically created)"
 msgstr[0] ""
-"Nincs létrehozandó ütemezett tranzakció. (%d tranzakció automatikusan "
-"létrehozva)"
+"Jelenleg nincs ütemezett tranzakció amelyet meg kell adni. (%d tranzakció "
+"automatikusan létrejött)"
 
 #: gnucash/gnome/dialog-sx-since-last-run.c:998
 #: gnucash/gnome-search/dialog-search.c:1104

commit 5e9d0858d3dffe785adafba6391c07899653a928
Author: Cow <javier.fserrador at gmail.com>
Date:   Fri Apr 29 03:08:24 2022 +0200

    Translation update  by Cow <javier.fserrador at gmail.com> using Weblate
    
    po/es.po: 100.0% (5390 of 5390 strings; 0 fuzzy)
    0 failing checks (0.0%)
    Translation: GnuCash/Program (Spanish)
    Translate-URL: https://hosted.weblate.org/projects/gnucash/gnucash/es/
    
    Co-authored-by: Cow <javier.fserrador at gmail.com>

diff --git a/po/es.po b/po/es.po
index fd3bc3c77..7c86b6d51 100644
--- a/po/es.po
+++ b/po/es.po
@@ -80,7 +80,7 @@ msgstr ""
 "Report-Msgid-Bugs-To: https://bugs.gnucash.org/enter_bug."
 "cgi?product=GnuCash&component=Translations\n"
 "POT-Creation-Date: 2022-03-09 18:00-0800\n"
-"PO-Revision-Date: 2022-04-15 13:12+0000\n"
+"PO-Revision-Date: 2022-04-27 19:08+0000\n"
 "Last-Translator: Cow <javier.fserrador at gmail.com>\n"
 "Language-Team: Spanish <https://hosted.weblate.org/projects/gnucash/gnucash/"
 "es/>\n"
@@ -89,7 +89,7 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 4.12-dev\n"
+"X-Generator: Weblate 4.12.1-dev\n"
 "X-Bugs: Report translation errors to the Language-Team address.\n"
 "X-Poedit-SourceCharset: UTF-8\n"
 "X-Poedit-KeywordsList: <b>;</b>;<span weight=\"bold\" size=\"larger\""
@@ -559,9 +559,8 @@ msgid ""
 "The full path is displayed in the status bar."
 msgstr ""
 "Si desea conocer cuales directorios donde están almacenados los archivos "
-"GnuCash recientes, pase el cursor sobre una de los asientos en el menú de "
-"historial\n"
-"(Archivo[->Listado más recientes utilizados]).\n"
+"GnuCash recientes, pase el cursor sobre una de los asientos\n"
+"en el menú de historial (Archivo[->Listado más recientes utilizados]).\n"
 "La ruta completa es representada dentro de la barra de estado."
 
 #: doc/tip_of_the_day.list.c:24
@@ -5176,7 +5175,7 @@ msgstr "_Borrar titular..."
 
 #: gnucash/gnome/gnc-plugin-page-owner-tree.c:178
 msgid "Delete selected owner"
-msgstr "Borrar el titular seleccionado"
+msgstr "Borra el titular seleccionado"
 
 #: gnucash/gnome/gnc-plugin-page-owner-tree.c:197
 msgid "Create a new bill"
@@ -5275,7 +5274,7 @@ msgid ""
 "Are you sure you want to do this?"
 msgstr ""
 "Este titular %s será eliminado.\n"
-"¿Seguro que desea hacer ésto?"
+"¿Seguro que desea hacer esto?"
 
 #: gnucash/gnome/gnc-plugin-page-register2.c:194
 #: gnucash/gnome/gnc-plugin-page-register.c:292
@@ -5591,12 +5590,12 @@ msgid ""
 "Show a second line with \"Action\", \"Notes\", and \"Linked Document\" for "
 "each transaction."
 msgstr ""
-"Muestra una línea adicional con \"Operación\", \"Notas\" y \"Documento "
-"Asociado\" para cada transacción."
+"Muestra una línea adicional con «Operación», «Notas» y «Documento Asociado» "
+"para cada transacción."
 
 #: gnucash/gnome/gnc-plugin-page-register2.c:430
 msgid "Show _Extra Dates"
-msgstr "Mostrar fechas _extra"
+msgstr "Mostrar fechas _adicionales"
 
 #: gnucash/gnome/gnc-plugin-page-register2.c:431
 msgid "Show entered and reconciled dates"
@@ -22925,7 +22924,7 @@ msgstr "999'00"
 #: gnucash/register/ledger-core/gncEntryLedgerLayout.c:154
 msgctxt "sample for 'Billable'"
 msgid "BI"
-msgstr "Ca"
+msgstr "FA"
 
 #: gnucash/register/ledger-core/gncEntryLedgerLayout.c:158
 msgctxt "sample"
@@ -23204,7 +23203,7 @@ msgstr "22/02/2000"
 #: gnucash/register/ledger-core/split-register-layout.c:671
 msgctxt "sample"
 msgid "99999"
-msgstr "99.999"
+msgstr "12345"
 
 #: gnucash/register/ledger-core/split-register-layout.c:679
 msgctxt "sample"
@@ -30558,7 +30557,7 @@ msgstr "g"
 #: libgnucash/app-utils/gnc-ui-util.c:879
 msgctxt "Reconciled flag 'void'"
 msgid "v"
-msgstr "a"
+msgstr "p"
 
 #: libgnucash/app-utils/gnc-ui-util.c:919
 msgctxt "Document Link flag for 'web'"
@@ -30568,7 +30567,7 @@ msgstr "w"
 #: libgnucash/app-utils/gnc-ui-util.c:921
 msgctxt "Document Link flag for 'file'"
 msgid "f"
-msgstr "f"
+msgstr "a"
 
 #: libgnucash/app-utils/gnc-ui-util.c:950
 msgid "Opening Balances"
@@ -30723,7 +30722,7 @@ msgstr ""
 #: libgnucash/engine/gnc-commodity.h:112
 msgctxt "Commodity Type"
 msgid "All non-currency"
-msgstr "Todas excepto moneda"
+msgstr "Todo no monetario"
 
 #: libgnucash/engine/gnc-commodity.h:113
 msgctxt "Commodity Type"

commit 7f316b8bdd1e511eef7d654a0169031c12a9b651
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Apr 24 16:20:07 2022 +0800

    [balsheet-pnl] test "lvl <= depth-limit" outside add-indented-row
    
    this will be the first step trying to fix bug 798502. the bug likely
    resides in the (if) conditional in (add-account-row).

diff --git a/gnucash/report/reports/standard/balsheet-pnl.scm b/gnucash/report/reports/standard/balsheet-pnl.scm
index 085b60a32..95672a900 100644
--- a/gnucash/report/reports/standard/balsheet-pnl.scm
+++ b/gnucash/report/reports/standard/balsheet-pnl.scm
@@ -382,28 +382,30 @@ also show overall period profit & loss."))
   (define (make-narrow-cell)
     (gnc:make-html-table-cell/min-width 1))
 
+  (define (show-depth? lvl)
+    (or (not depth-limit) (<= lvl depth-limit)))
+
   (define (add-indented-row indent label label-markup row-markup amount-indent rest)
-    (when (or (not depth-limit) (<= indent depth-limit))
-      (let* ((account-cell (if label-markup
-                               (gnc:make-html-table-cell/size/markup
-                                1 (if disable-account-indent? 1 (- maxindent indent))
-                                label-markup label)
-                               (gnc:make-html-table-cell/size
-                                1 (if disable-account-indent? 1 (- maxindent indent))
-                                label)))
-             (row (append
-                   (if disable-account-indent?
-                       '()
-                       (make-list-thunk indent make-narrow-cell))
-                   (list account-cell)
-                   (gnc:html-make-empty-cells
-                    (if amount-indenting? (1- amount-indent) 0))
-                   (if reverse-cols? (reverse rest) rest)
-                   (gnc:html-make-empty-cells
-                    (if amount-indenting? (- maxindent amount-indent) 0)))))
-        (if row-markup
-            (gnc:html-table-append-row/markup! table row-markup row)
-            (gnc:html-table-append-row! table row)))))
+    (let* ((account-cell (if label-markup
+                             (gnc:make-html-table-cell/size/markup
+                              1 (if disable-account-indent? 1 (- maxindent indent))
+                              label-markup label)
+                             (gnc:make-html-table-cell/size
+                              1 (if disable-account-indent? 1 (- maxindent indent))
+                              label)))
+           (row (append
+                 (if disable-account-indent?
+                     '()
+                     (make-list-thunk indent make-narrow-cell))
+                 (list account-cell)
+                 (gnc:html-make-empty-cells
+                  (if amount-indenting? (1- amount-indent) 0))
+                 (if reverse-cols? (reverse rest) rest)
+                 (gnc:html-make-empty-cells
+                  (if amount-indenting? (- maxindent amount-indent) 0)))))
+      (if row-markup
+          (gnc:html-table-append-row/markup! table row-markup row)
+          (gnc:html-table-append-row! table row))))
 
   (define (monetary+ . monetaries)
     ;; usage: (monetary+ monetary...)
@@ -518,8 +520,9 @@ also show overall period profit & loss."))
              ((_ . tail) (lp1 tail))))))))
 
   (define* (add-recursive-subtotal lvl lvl-acct #:key account-style-normal?)
-    (if (or show-zb-accts?
-            (is-not-zero? (account-and-descendants lvl-acct)))
+    (if (and (or show-zb-accts?
+                 (is-not-zero? (account-and-descendants lvl-acct)))
+             (show-depth? lvl))
         (add-indented-row lvl
                           (render-account lvl-acct (not account-style-normal?))
                           (if account-style-normal?
@@ -545,9 +548,10 @@ also show overall period profit & loss."))
   (define* (add-account-row lvl-curr curr #:key
                             (override-show-zb-accts? #f)
                             (account-indent 0))
-    (if (or show-zb-accts?
-            override-show-zb-accts?
-            (is-not-zero? (list curr)))
+    (if (and (or show-zb-accts?
+                 override-show-zb-accts?
+                 (is-not-zero? (list curr)))
+             (show-depth? lvl-curr))
         (add-indented-row lvl-curr
                           (render-account curr #f)
                           "text-cell"

commit e381e7063805091c03b610c5fbf2fe882ba31cc8
Author: Alex Aycinena <alex.aycinena at gmail.com>
Date:   Fri Apr 22 19:26:09 2022 -0700

    reverse commit d48937c. See discussion in Bug #79769.

diff --git a/libgnucash/tax/us/txf.scm b/libgnucash/tax/us/txf.scm
index c1a3a7f44..f07784915 100644
--- a/libgnucash/tax/us/txf.scm
+++ b/libgnucash/tax/us/txf.scm
@@ -174,7 +174,6 @@
     (cons 'N292 #(not-impl "Sched C" "Spouse" 0 #t "" ((1980 ""))))
     (cons 'N319 #(not-impl "Sched C" "Principal business/prof" 2 #t "" ((1980 "A"))))
     (cons 'N293 #(none "Sched C" "Gross receipts or sales" 1 #t "" ((2012 "1") (2011 "1b") (1989 "1") (1980 "1a"))))
-    (cons 'N296 #(none "Sched C" "Returns and allowances" 1 #t "" ((1989 "2") (1980 "1b"))))
     (cons 'N303 #(none "Sched C" "Other business income" 1 #t "" ((1989 "6") (1987 "4") (1981 "4b") (1980 "4"))))
 
     (cons 'N497 #(not-impl "Sched C-EZ" "Schedule C-EZ" 1 #t ""))



Summary of changes:
 gnucash/gnome/assistant-stock-transaction.cpp      | 84 +++++++++++++++-------
 .../gtkbuilder/assistant-stock-transaction.glade   | 70 +++++++++---------
 gnucash/import-export/aqb/gnc-ab-utils.c           | 36 ++++++----
 gnucash/import-export/import-backend.c             | 66 ++++++++++-------
 gnucash/report/html-text.scm                       |  4 +-
 gnucash/report/reports/standard/balsheet-pnl.scm   | 56 ++++++++-------
 libgnucash/app-utils/app-utils.scm                 |  6 +-
 libgnucash/tax/us/txf.scm                          |  1 -
 po/es.po                                           | 29 ++++----
 po/hu.po                                           | 11 +--
 10 files changed, 209 insertions(+), 154 deletions(-)



More information about the gnucash-changes mailing list