From 3005cc1ae91f98dd70209ad8c379da2fea7873ae Mon Sep 17 00:00:00 2001 From: Tobias Kunze Date: Sat, 13 Jan 2018 13:52:59 +0100 Subject: [PATCH] Don't duplicate transactions on import --- byro_shackspace/utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/byro_shackspace/utils.py b/byro_shackspace/utils.py index 9bba0a4..b1f9f39 100644 --- a/byro_shackspace/utils.py +++ b/byro_shackspace/utils.py @@ -30,16 +30,15 @@ def process_bank_csv(sender, signal, **kwargs): if key.startswith('VWZ'): reference += line[key] + ' ' - RealTransaction.objects.create( + RealTransaction.objects.get_or_create( channel=TransactionChannel.BANK, - booking_datetime=booking_timestamp, value_datetime=datetime.strptime(line.get('Buchungstag'), '%d.%m.%Y'), amount=Decimal(line.get('Betrag').replace('.', '').replace(',', '.')), purpose=reference, originator=line.get('Auftraggeber/Empfänger', ''), importer='shack_bank_csv_importer', - source=source, data=line, + defaults={'source': source, 'booking_datetime': booking_timestamp}, ) return True