problem with csv export in master

Thomas Baumgart thb at net-bembel.de
Tue Aug 8 06:39:51 BST 2023


On Dienstag, 8. August 2023 00:53:11 CEST Jack via KMyMoney-devel wrote:

> While trying to debug the problem recently reported on Discord about  
> the 5.1.3 csv exporter truncating stock prices to 2 decimal places, I  
> noticed that the master branch csv export always seem to export the  
> same account, which is NOT the one I selected.  In playing with that  
> further, if I pick an investment account in the account dropdown, and  
> then change the separator from tab to comma, I get the popup that the  
> account is invalid because it doesn't have any items. In trying to  
> figure out why that happens, I put a qDebug at the beginning of  
> CsvExportDlg::checkData which prints out the selected account.   When I  
> select the account (any account) with the dropdown, the correct account  
> name is printed.   However, if I make or change the separator  
> selection, a DIFFERENT account name is selected.  So - it turns out I  
> can export the selected account only if I choose the separator first,  
> and then the account.
> 
> Further, looking at CsvExportDlg::CsvExportDlg, I find the last three  
> connect commads are:
> 
>     connect(ui->m_accountComboBox,  
> qOverload<int>(&QComboBox::currentIndexChanged), this, [this](int idx) {
>          checkData(ui->m_accountComboBox->itemText(idx));
>      });
>      connect(ui->m_separatorComboBox,  
> QOverload<int>::of(&QComboBox::currentIndexChanged), this, [&](int  
> index) {
>          m_separator = m_fieldDelimiterCharList[index];
>      } );
>      connect(ui->m_separatorComboBox,  
> qOverload<int>(&QComboBox::currentIndexChanged), this, [this](int idx) {
>          checkData(ui->m_accountComboBox->itemText(idx));
>      });
> 
> Commenting out the third out seems to fix the problem of the wrong  
> account.  This might make sense as it looks like that call is  
> connecting a change of the separator combobox to to calling checkData  
> with an incorrect account name (using the index of the separator  
> combobox, not of the account combobox.  However, I'm not sure how (or  
> even if) calling checkData with the "wrong" account name can actually  
> change which account gets exported, although it is perhaps by selecting  
> the splits to be exported based on the wrong account.
> 
> This post  
> (https://stackoverflow.com/questions/16794695/connecting-overloaded-signals-and-slots-in-qt-5)  
> related to the connecting of overloaded functions states that with  
> C++11 you need QOverload<>::of(...) but with C++14 you need  
> qOverload<>(...).  This makes it look like our code has a mixture of  
> both types of calls, and I wonder what subtle bugs this may have  
> introduced.

This should better read "... but from C++14 on you can use qOverload<>(...)".
I noticed the mixed versions myself, but they don't hurt.

> I'll wait for some feedback before I actually try to fix this, while I  
> continue to track down why the number of decimal places is truncated to  
> 2 for prices and is too large for prices (which seems to be the same in  
> 5.1 and master.)

I noticed the same yesterday when trying to figure out the decimal places
problem. I (mostly) rewrote the export dialog to fix all the problems. Once
I had this working, I noticed another problem with the csv exporter (at
least with investments): it seems to not add multiple fees/interest splits
thus giving false numbers in the export.

I did not have the time to finish the changes on the export dialog yesterday
but will commit it to the repo soon.

Since you already analyzed the old code you can now take a look at how
things are/can be done with the actual code base.

The decimal places code has another problem because prices are always written
with a precision of 6 digits. I leave it to you to change that to get the
security from the account and take the price precision defined for it.

-- 

Regards

Thomas Baumgart

-------------------------------------------------------------
My friend couldn't afford to pay his water bill.
So I sent him a 'get well soon' card.
-------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 868 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kmymoney-devel/attachments/20230808/cea18749/attachment.sig>


More information about the KMyMoney-devel mailing list