From 7d337c92d1e46892516ff91560aea14a15bad771 Mon Sep 17 00:00:00 2001 From: Yingtong Li Date: Tue, 2 Mar 2021 10:24:09 +1100 Subject: [PATCH] Fix bug with too many reimbursement claims at once --- sstreasury/views.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sstreasury/views.py b/sstreasury/views.py index 95b87ee..caf715a 100644 --- a/sstreasury/views.py +++ b/sstreasury/views.py @@ -689,13 +689,22 @@ def claim_processing(request): num_records = 0 for _, payee_claims in itertools.groupby(claims, key=lambda c: '{}/{}{}/{}'.format(c.payee_name.strip(), c.payee_bsb.strip()[:3], c.payee_bsb.strip()[-3:], c.payee_account.strip())): payee_claims = list(payee_claims) + + reference = 'RE{}'.format(' '.join(str(c.id) for c in payee_claims)) + if len(reference) > 18: + # Avoid cutting a reference number in half + if reference[14] == ' ': + reference = reference[:14] + ' etc' + else: + reference = ' '.join(reference[:14].split()[:-1]) + ' etc' + aba.write_detail( aba_file, dest_bsb=payee_claims[0].payee_bsb, dest_account=payee_claims[0].payee_account, cents=sum(c.get_total() for c in payee_claims)*100, dest_name=payee_claims[0].payee_name[:32], - reference='RE{}'.format(' '.join(str(c.id) for c in payee_claims)), + reference=reference, src_bsb=settings.ABA_SRC_BSB, src_account=settings.ABA_SRC_ACC, src_name=settings.ABA_USER_NAME