Skip to content

Commit 928336f

Browse files
committed
Add support for auto-booking transferwise cashback
Transferwise re-invented interest and call it cashback (it's the same as interest..), and we already knew how to classify these transactions. So instead of leaving them as pending, automatically book them against a predefined account.
1 parent b4b88f3 commit 928336f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

postgresqleu/transferwise/management/commands/transferwise_fetch_transactions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ def handle_method(self, method, startdate):
170170
entry)
171171
else:
172172
create_accounting_entry(accrows)
173+
elif trans.transtype == 'BALANCE_CASHBACK' and pm.config('accounting_cashback'):
174+
accrows = [
175+
(pm.config('bankaccount'), trans.paymentref, trans.amount, None),
176+
(pm.config('accounting_cashback'), trans.paymentref, -trans.amount, None),
177+
]
178+
create_accounting_entry(accrows)
173179
else:
174180
# Else register a pending bank transaction. This may immediately match an invoice
175181
# if it was an invoice payment, in which case the entire process will complete.

postgresqleu/util/payment/transferwise.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ class BackendTransferwiseForm(BaseManagedBankPaymentForm):
4444
help_text="Send monthly PDF statements by email")
4545
accounting_payout = forms.ChoiceField(required=False, choices=[(None, '---')] + get_account_choices(),
4646
label="Payout account")
47+
accounting_cashback = forms.ChoiceField(required=False, choices=[(None, '---')] + get_account_choices(),
48+
label="Cashback account",
49+
help_text="Accounting account that any cashback payments are booked against")
4750
webhookurl = forms.CharField(label="Webhook URL", widget=StaticTextWidget)
4851

4952
exclude_fields_from_validation = ('generatekey', )
5053
config_readonly = ['webhookurl', ]
5154
managed_fields = ['apikey', 'canrefund', 'notification_receiver', 'autopayout', 'autopayouttrigger',
52-
'autopayoutlimit', 'autopayoutname', 'autopayoutiban', 'accounting_payout',
55+
'autopayoutlimit', 'autopayoutname', 'autopayoutiban', 'accounting_payout', 'accounting_cashback',
5356
'send_statements', 'public_key', 'private_key', 'generatekey', ]
5457
managed_fieldsets = [
5558
{
@@ -70,6 +73,14 @@ class BackendTransferwiseForm(BaseManagedBankPaymentForm):
7073
},
7174
]
7275

76+
@property
77+
def config_fieldsets(self):
78+
fss = super().config_fieldsets
79+
for fs in fss:
80+
if fs['id'] == 'accounting':
81+
fs['fields'].append('accounting_cashback')
82+
return fss
83+
7384
def fix_fields(self):
7485
super().fix_fields()
7586
self.fields['generatekey'].callback = self.generate_keypair

0 commit comments

Comments
 (0)