From d51ac1b226e406661c5ecf9c143dc8bf0807fab2 Mon Sep 17 00:00:00 2001 From: Chemtov Athlan Date: Thu, 28 Mar 2019 00:51:14 +0100 Subject: [PATCH] Use effective date for credit card with deferred payment. If the DTUSER is different from the DTPOSTED in an transaction then we have a deferred payment. Use the effective date in ledger for such case. Closes: #69 --- ledgerautosync/converter.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ledgerautosync/converter.py b/ledgerautosync/converter.py index 5e4d54b..cd4c5f2 100644 --- a/ledgerautosync/converter.py +++ b/ledgerautosync/converter.py @@ -413,8 +413,18 @@ def convert(self, txn): posting = Posting(self.name, Amount(txn.amount, self.currency), metadata=posting_metadata) + effective_date = None + logged_date = txn.date + + # When the user date is different from the date then we + # need to add an effective transaction. + if txn.user_date is not None: + if txn.user_date != txn.date: + effective_date = txn.date + logged_date = txn.user_date return Transaction( - date=txn.date, + date=logged_date, + aux_date=effective_date, payee=self.format_payee(txn), postings=[ posting,