Skip to content

Commit e4e3c4b

Browse files
authored
Merge pull request #162 from reubano/feature/amazon-cancelled
Fix issue when cancelled orders appear without any total.
2 parents 0dcc5b3 + dc80367 commit e4e3c4b

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

csv2ofx/mappings/amazon.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,15 @@ def filter_pending(row):
4848
return row['date'] != 'pending'
4949

5050

51+
def filter_cancelled(row):
52+
"""
53+
Cancelled orders have no total.
54+
"""
55+
return bool(row['total'])
56+
57+
5158
def filter(row):
52-
return filter_pending(row) and filter_payment(row)
59+
return filter_pending(row) and filter_payment(row) and filter_cancelled(row)
5360

5461

5562
mapping = {

data/test/amazon.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ order id,order url,items,to,date,total,shipping,shipping_refund,gift,tax,refund,
44
114-5269613-6941034,https://www.amazon.com/...,"TOPGREENER Smart Wi-Fi In-Wall Tamper Resistant Dual USB Charger Outlet, Energy Monitoring, Compatible with Amazon Alexa and Google Assistant, Outlet; ",John Doe,2022-10-11,34.12,0,0,0,1.93,0,"Visa ending in 9876: October 12, 2022: $34.12; "
55
D01-1234567-8901234,https://www.amazon.com/...,,,pending,,,,,,,
66
D01-5678901-2345678,https://www.amazon.com/...,,,pending,,,,,,,
7+
111-1747627-cancelled,https://www.amazon.com/gp/your-account/order-details/...,,,2025-04-11,,,,,,,
78
order id,order url,items,to,date,total,shipping,shipping_refund,gift,tax,refund,payments

0 commit comments

Comments
 (0)