From dc9dc05afa9f82672ca30fe531469eba2ab9112c Mon Sep 17 00:00:00 2001 From: ruuushhh <66899387+ruuushhh@users.noreply.github.com> Date: Wed, 31 Jul 2024 13:17:21 +0530 Subject: [PATCH] Fix: Purpose Char Limit (#159) Co-authored-by: GitHub Actions --- apps/business_central/exports/base_model.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/business_central/exports/base_model.py b/apps/business_central/exports/base_model.py index 6fa082a..dd552a9 100644 --- a/apps/business_central/exports/base_model.py +++ b/apps/business_central/exports/base_model.py @@ -129,12 +129,18 @@ def get_vendor_or_employee_id(employee_field_mapping: str, mapping: EmployeeMapp def get_expense_purpose(lineitem: Expense, category: str, advance_setting: AdvancedSetting) -> str: memo_structure = advance_setting.expense_memo_structure + lineitem_purpose = '' + + if lineitem.purpose and len(lineitem.purpose) > 40: + lineitem_purpose = lineitem.purpose[:37] + '...' + else: + lineitem_purpose = lineitem.purpose details = { 'employee_email': lineitem.employee_email, 'merchant': '{0}'.format(lineitem.vendor) if lineitem.vendor else '', 'category': '{0}'.format(category) if lineitem.category else '', - 'purpose': '{0}'.format(lineitem.purpose) if lineitem.purpose else '', + 'purpose': '{0}'.format(lineitem_purpose), 'report_number': '{0}'.format(lineitem.claim_number), 'spent_on': '{0}'.format(lineitem.spent_at.date()) if lineitem.spent_at else '', }