Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webapp import amount always 0 #4277

Closed
3 of 8 tasks
osr-revamper opened this issue Apr 4, 2022 · 12 comments
Closed
3 of 8 tasks

Webapp import amount always 0 #4277

osr-revamper opened this issue Apr 4, 2022 · 12 comments
Assignees
Labels

Comments

@osr-revamper
Copy link

MMEX version:

  • 1.5.x
  • 1.6.x

Operating System:

  • Windows
  • Mac OSX
  • Linux

Description of the bug

When trying to import new Webapp transactions in my MMEX Desktop, the "Amount" of all transactions is always 0.

Tested with master, 1.0.3 and 1.0.2

Reproduction

Is the bug reproducible?

  • Always
  • Randomly
  • Happened only once

Reproduction steps:

  1. Create new transactions in WebApp with Amount field completed with random imports.
  2. Open Desktop MMEX
  3. In the webapp import tool verify taht the amounts are always 0.

Expected result: The same amount in the webapp import tool than on the web server.

Actual result: All the amounts are always 0.

Additional information

Tested with PHP 7.3, 7.4 and 8.0.
mmex_desktop_sync
mmex_webapp_pending

@vomikan vomikan added the imp/exp label Apr 4, 2022
@whalley
Copy link
Member

whalley commented Apr 4, 2022

I can't reproduce this. Perhaps it is related to currency format/settings.

CleanShot 2022-04-05 at 00 21 43

CleanShot 2022-04-05 at 00 22 04

@osr-revamper
Copy link
Author

These are my settings:

  • Desktop in Spanish locale.
  • Accounts in EUR.

mmex_1
mmex_2
mmex_3
mmex_4
mmex_5

@whalley
Copy link
Member

whalley commented Apr 5, 2022

Can you please enter a few new transactions into the WebApp the go to the WebApp install directory:

The should be a file in there called MMEX_New_Transaction.db

Now open the DB by typing:
sqlite3 MMEX_New_Transaction.db

You should be prompted with something like:

SQLite version 3.31.1 2020-01-27 19:55:54
Enter ".help" for usage hints.
sqlite> 

Just enter the command:
select * from New_Transaction;

and let me know the output.

@osr-revamper
Copy link
Author

Here you are:

SQLite version 3.31.1 2020-01-27 19:55:54
Enter ".help" for usage hints.
sqlite> select * from New_Transaction;
2|2022-04-04|ING |None|F|Withdrawal|None|None|None|12.36|Testing
3|2022-04-06|ING |None||Withdrawal|None|None|None|23.45|
4|2022-04-06|Caja |None||Withdrawal|None|None|None|56.89|pruebas
5|2022-04-06|Caja |None|D|Transfer|None|None|None|23|eee
6|2022-04-06|BBVA |None|R|Deposit|None|None|None|12.67|

Thanks whalley!

@whalley
Copy link
Member

whalley commented Apr 6, 2022

@osr-revamper That looks fine and as expected.

If you could leave this setup and send me your URL and GUID for the WebAp via email to mark@ipx.co.uk then I will try from my end. You can of course change the GUID after this for security as needed

@whalley whalley self-assigned this Apr 6, 2022
@whalley
Copy link
Member

whalley commented Apr 6, 2022

@osr-revamper Thanks for sharing your server detail... So I can see why the issue is arising...

My WebApp returns data like....

"0": {
    "ID": "2",
    "Date": "2022-04-05",
    "Account": "Cash (UK)",
    "ToAccount": "None",
    "Status": "",
    "Type": "Withdrawal",
    "Payee": "1Passwd",
    "Category": "Adjustments",
    "SubCategory": "",
    "Amount": "12.34",
    "Notes": "",
    "Attachments": ""
}

Yours returns:

"0": {
    "ID": 2,
    "Date": "2022-04-04",
    "Account": "ING 7505",
    "ToAccount": "None",
    "Status": "F",
    "Type": "Withdrawal",
    "Payee": "None",
    "Category": "None",
    "SubCategory": "None",
    "Amount": 12.359999999999999,
    "Notes": "Testing",
    "Attachments": ""
}

Note the difference in the presentation of the Amount field. The MMEX application is always expecting a STRING for each field but your WebApp installation is returning a numeric value.

Can you confirm you have the latest WebApp Version 1.1.0 / Master code installed?

At least we have narrowed this down.....

@whalley
Copy link
Member

whalley commented Apr 6, 2022

@osr-revamper What version of PHP do you have on the server? Think it may be a PHP json_encode difference.

@osr-revamper
Copy link
Author

My PHP version is 8.1.

@osr-revamper
Copy link
Author

You are right whalley. From PHP 7.1 till 8.0 is working now!! But not in PHP 8.1.

Many thanks for your help.

Best regards.

@whalley
Copy link
Member

whalley commented Apr 6, 2022

@osr-revamper Can you please try the following for me.

Edit the functions.php file, to add the following line:

$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);

after line 461, e.g.

    // Select all transaction order by date
    public static function transaction_select_all_order_by_date (String $s_direction = 'DESC')
        {
            $const_dbpath = costant::database_path();
            $db = new PDO("sqlite:${const_dbpath}");
            $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
            
            $results = $db -> query("SELECT * FROM New_Transaction ORDER BY Date $s_direction, id $s_direction;");
            $resultarray = array();
            if($results !== false)
                {$resultarray = $results->fetchall(PDO::FETCH_ASSOC);}
            $db = null;
            return $resultarray;
        }

Then test with PHP 8.1 again

I think (hope) this should cure the problem.

@osr-revamper
Copy link
Author

With these changes in functions.php it works also in PHP 8.1!!

@whalley
Copy link
Member

whalley commented Apr 7, 2022

Great, I'll move the issue over to the WebApp repo and make the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants