update scalable_sync.py to refine activity recording by conditionally including asset-based fields and improving payload construction
This commit is contained in:
+15
-8
@@ -329,22 +329,29 @@ class WealthfolioMCP:
|
||||
return False
|
||||
|
||||
def record_activities(self, activities):
|
||||
activity_payloads = [
|
||||
{
|
||||
activity_payloads = []
|
||||
|
||||
for activity in activities:
|
||||
payload = {
|
||||
"account": activity.account_id,
|
||||
"activityDate": activity.date,
|
||||
"symbol": activity.symbol,
|
||||
"activityType": activity.activity_type,
|
||||
"quantity": activity.quantity,
|
||||
"unitPrice": activity.unit_price,
|
||||
"amount": activity.amount,
|
||||
"currency": activity.currency,
|
||||
"fee": activity.fee,
|
||||
"tax": activity.tax,
|
||||
"currency": activity.currency,
|
||||
"notes": f"scalable:{activity.external_id}",
|
||||
}
|
||||
for activity in activities
|
||||
]
|
||||
|
||||
# Nur asset-basierte Aktivitäten brauchen Symbol, Menge und Preis.
|
||||
if activity.activity_type in {"BUY", "SELL", "DIVIDEND", "SPLIT"}:
|
||||
payload["symbol"] = activity.symbol
|
||||
payload["quantity"] = activity.quantity
|
||||
payload["unitPrice"] = activity.unit_price
|
||||
|
||||
activity_payloads.append(
|
||||
{key: value for key, value in payload.items() if value is not None}
|
||||
)
|
||||
|
||||
draft_result = asyncio.run(
|
||||
self._connect_and_call(
|
||||
|
||||
Reference in New Issue
Block a user