Bug #1694

Bug on paypal amount : net amount vs total amount

Added by Jean-Philippe Dutreve over 2 years ago. Updated over 2 years ago.

Status:Resolved Start:2014-12-17
Priority:Urgent Due date:
Assigned to:Romain Bignon % Done:

100%

Category:Modules Spent time: -
Target version:1.1
Module:paypal Branch:

Description

Since some days, the total amount of each transaction is retrieved instead of the netting amount (= total amount - commissions - travel costs).

This generates a lot of duplicate transactions ...

Associated revisions

Revision 2edc1b0627eb0dde30edc4ba3d9b869f7e2f725e
Added by Romain Bignon over 2 years ago

take care of transaction's net amounts (closes #1694)

The account balance is impacted by the net amount, because Paypal's fee is
deducted at source.

History

Updated by Romain Bignon over 2 years ago

How can we get correctly net amounts?

Updated by Jean-Philippe Dutreve over 2 years ago

I guess that this is an issue ONLY for new website pages (old pages seems OK).

I don't know how to retrieve net amounts.

Currently for newpages:

  • particulier users: amount = transaction['displayAmount']
  • professional users: amount = tr.xpath('./td[@class="price"]/span')[0].text.strip()

Updated by Romain Bignon over 2 years ago

Here is an example of a transaction:

            {
               "currencyCode" : "EUR",
               "dateDay" : "19",
               "displayAmount" : "-€45,00",
               "displayType" : "Paiement",
               "txnIsInPrimaryCurrency" : true,
               "amount" : -4500,
               "hasYearDivider" : false,
               "netAmount" : "€45,00",
               "activityUUID" : "1561651651641",
               "actions" : {
                  "details" : {
                     "action" : "ACTIVITY_DETAILS",
                     "url" : "/cgi-bin/webscr?cmd=_history-details-from-hub&id=123456789W" 
                  }
               },
               "balanceAmount" : "€0,00",
               "grouping" : "COMPLETED",
               "hideTxnAmount" : false,
               "isCredit" : false,
               "hasAdditionalActions" : false,
               "type" : "ACTIVITY_TYPE_PAYMENT_SENT",
               "dateYear" : "2014",
               "paypalFee" : "€0,00",
               "counterparty" : "eBay",
               "dateMonth" : "sept.",
               "activityId" : "6709216036329302W",
               "date" : "vendredi 19 septembre 2014",
               "grossAmount" : "€45,00",
               "status" : "COMPLETED" 
            }

You would like to take the "netAmount" field? I don't understand what changes.

Do you have example to give? Try to use boobank with -a to get the json sent by paypal to copy transactions.

Updated by Jean-Philippe Dutreve over 2 years ago

This is not a transaction that shows the issue because paypalFee 0, so netAmount grossAmount in this case.

I guess that displayAmount is the grossAmount for newpages.

We do need the netAmount, without the fee taken by PayPal.

It would be usefull to have another transaction that shows the issue and validate my hypothese.

Updated by Jean-Philippe Dutreve over 2 years ago

I have tested the solution and it's working !

paypal/newpages.py : class NewPartHistoryPage(Page):

def parse_transaction(...):

old broken version : amount = transaction['displayAmount']

to be replaced by:

new working version : amount = transaction['netAmount']

Updated by Romain Bignon over 2 years ago

On the account I test, there is no transaction with a paypal fee.

Can you show me an example please?

Updated by Jean-Philippe Dutreve over 2 years ago

{u'isCredit': True, u'grossAmount': u'\u20ac130,00', u'dateDay': u'03', u'actions': {u'details': {u'action': u'ACTIVITY_DETAILS', u'url': u'/cgi-bin/webscr?cmd=_history-details-from-hub&id=7Y717384M99193527'}},
u'hasAdditionalActions': False, u'hideTxnAmount': False, u'netAmount': u'\u20ac125,33', u'hasYearDivider': False, u'activityUUID': u'7bd1dfb90c414941ab3f745012c3cef6', u'balanceAmount': u'\u20ac816,11', u'currencyCode':
u'EUR', u'hasFee': True, u'displayType': u'Paiement re\xe7u', u'activityId': u'7Y717384M99193527', u'dateMonth': u'd\xe9c.', u'type': u'ACTIVITY_TYPE_PAYMENT_RECEIVED', u'status': u'COMPLETED', u'displayAmount': u'\u20ac130,00',
u'counterparty': u'', u'dateYear': u'2014', u'txnIsInPrimaryCurrency': True, u'date': u'mercredi 3 d\xe9cembre 2014', u'amount': 13000, u'paypalFee': u'\u20ac4,67', u'grouping': u'COMPLETED'}

The solution I proposed is working. Could you make the change please ?

Updated by Romain Bignon over 2 years ago

netAmount is a positive value, and displayAmount a negative one. I have to change the sign of netAmount?

I don't understand how the change will remove "duplicated transactions", as there are as many transactions with the change.

Updated by Jean-Philippe Dutreve over 2 years ago

In my example, this is NOT the negative sign but the Euro sign. Both values are positives (€130 vs €125,33).

Furthermore, I have tested this fixe on a REAL account (using new pages) and it's working just by changing displayAmount by netAmount.

In Winancial, 2 transactions are equals if the have same date & amount. So, if a transaction change its amount in the bank after first import, then it will NOT be detected as equal at second import, and will NOT be deleted.

As a consequence, they are a lot of duplicates ...

Updated by Romain Bignon over 2 years ago

Ok I understand, and I agree with the change.

By the way, in my example, netAmount doesn't have the same sign than displayAmount. So I guess netAmount is an absolute value? Perhaps I should take care of the sign of displayAmount.

Updated by Jean-Philippe Dutreve over 2 years ago

You're right ! grossAmount & netAmount are absolute values.

So, we have to concat the sign of displayAmount (or use isCredit).

Updated by Romain Bignon over 2 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Updated by Romain Bignon over 2 years ago

  • Assigned to set to Romain Bignon

Also available in: Atom PDF