@@ -157,37 +157,41 @@ def _format_corporate_action_subdivision(act: dict, api_context) -> bool:
157157 return True
158158
159159
160- def _format_credit_card_description (act : dict ) -> str | None :
160+ def _format_credit_card_description (act : dict ) -> bool :
161161 """Format description for credit card activities.
162162
163163 Args:
164- act: Activity dictionary.
164+ act: Activity dictionary to modify in place .
165165
166166 Returns:
167- Formatted description string, or None if not a credit card activity.
167+ True if this was a credit card activity and was handled, False otherwise .
168168 """
169169 if act ["type" ] == "CREDIT_CARD" and act ["subType" ] == "PURCHASE" :
170170 merchant = act ["spendMerchant" ]
171171 # Posted purchase transactions have status = settled
172172 status = "(Pending) " if act ["status" ] == "authorized" else ""
173- return f"{ status } Credit card purchase: { merchant } "
173+ act ["description" ] = f"{ status } Credit card purchase: { merchant } "
174+ return True
174175
175176 if act ["type" ] == "CREDIT_CARD" and act ["subType" ] == "HOLD" :
176177 merchant = act ["spendMerchant" ]
177178 # Posted return transactions have subType = REFUND and status = settled
178179 status = "(Pending) " if act ["status" ] == "authorized" else ""
179- return f"{ status } Credit card refund: { merchant } "
180+ act ["description" ] = f"{ status } Credit card refund: { merchant } "
181+ return True
180182
181183 if act ["type" ] == "CREDIT_CARD" and act ["subType" ] == "REFUND" :
182184 merchant = act ["spendMerchant" ]
183- return f"Credit card refund: { merchant } "
185+ act ["description" ] = f"Credit card refund: { merchant } "
186+ return True
184187
185188 if (act ["type" ] == "CREDIT_CARD" and act ["subType" ] == "PAYMENT" ) or act [
186189 "type"
187190 ] == "CREDIT_CARD_PAYMENT" :
188- return "Credit card payment"
191+ act ["description" ] = "Credit card payment"
192+ return True
189193
190- return None
194+ return False
191195
192196
193197def format_activity_description (act : dict , api_context ) -> None :
@@ -333,8 +337,8 @@ def format_activity_description(act: dict, api_context) -> None:
333337 type_ = act ["type" ].capitalize ()
334338 act ["description" ] = f"{ type_ } "
335339
336- elif credit_card_desc := _format_credit_card_description (act ):
337- act [ "description" ] = credit_card_desc
340+ elif _format_credit_card_description (act ):
341+ pass # Handled by helper function
338342
339343 elif act ["type" ] == "REIMBURSEMENT" and act ["subType" ] == "CASHBACK" :
340344 program = (
0 commit comments