Skip to content

Commit ab1f97b

Browse files
committed
Fix
1 parent 140616d commit ab1f97b

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

landolfio/inventory/models/asset.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,9 @@ def save(self, *args, **kwargs):
246246
def get_asset_ledger_account_id(self):
247247
"""Get the appropriate ledger account ID based on margin status."""
248248
if self.is_margin_asset:
249-
return getattr(settings, "MONEYBIRD_MARGIN_ASSETS_LEDGER_ACCOUNT_ID", None)
249+
return str(settings.MONEYBIRD_MARGIN_ASSETS_LEDGER_ACCOUNT_ID)
250250
else:
251-
return getattr(
252-
settings, "MONEYBIRD_NOT_MARGIN_ASSETS_LEDGER_ACCOUNT_ID", None
253-
)
251+
return str(settings.MONEYBIRD_NOT_MARGIN_ASSETS_LEDGER_ACCOUNT_ID)
254252

255253
def refresh_from_moneybird(self):
256254
"""Refresh asset data from Moneybird API if moneybird_asset_id is set."""
@@ -304,9 +302,7 @@ def _refresh_from_moneybird(self, moneybird_data=None):
304302
self.current_value = moneybird_data["current_value"]
305303

306304
if "ledger_account_id" in moneybird_data:
307-
margin_account = getattr(
308-
settings, "MONEYBIRD_MARGIN_ASSETS_LEDGER_ACCOUNT_ID", None
309-
)
305+
margin_account = settings.MONEYBIRD_MARGIN_ASSETS_LEDGER_ACCOUNT_ID
310306
if margin_account:
311307
self.is_margin_asset = str(moneybird_data["ledger_account_id"]) == str(
312308
margin_account
@@ -423,7 +419,7 @@ def update_on_moneybird(self):
423419
moneybird_data = mb.update_asset(
424420
asset_id=self.moneybird_asset_id,
425421
name=asset_name,
426-
ledger_account_id=int(ledger_account_id) if ledger_account_id else None,
422+
ledger_account_id=ledger_account_id if ledger_account_id else None,
427423
purchase_date=start_date_str,
428424
purchase_value=float(self.purchase_value_asset)
429425
if self.purchase_value_asset

0 commit comments

Comments
 (0)