File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -378,7 +378,11 @@ def get_queryset(self):
378378
379379 for asset in linked_assets :
380380 # Check if sources is missing, null, or empty array
381- sources = asset .moneybird_data .get ('sources' ) if asset .moneybird_data else None
381+ sources = (
382+ asset .moneybird_data .get ("sources" )
383+ if asset .moneybird_data
384+ else None
385+ )
382386 if not sources or len (sources ) == 0 :
383387 asset_ids_with_missing_sources .append (asset .id )
384388
Original file line number Diff line number Diff line change @@ -34,10 +34,20 @@ def process_webhook_payload(payload: MoneybirdResource) -> None:
3434 entity_type = payload ["entity_type" ]
3535 entity_id = payload ["entity_id" ]
3636 entity_data = payload ["entity" ]
37+
38+ # Try to get exact entity type match first
3739 resource_type = get_moneybird_resource_type_for_entity (entity_type )
3840
41+ # If not found and entity_type starts with company_assets_, route to asset resource type
42+ if resource_type is None and entity_type .startswith ("company_assets_" ):
43+ resource_type = get_moneybird_resource_type_for_entity ("company_assets_asset" )
44+ if resource_type :
45+ logging .info (f"Routing { entity_type } webhook to AssetResourceType" )
46+
3947 if resource_type is None :
40- logging .warning ("Received webhook with unregistered entity type" )
48+ logging .warning (
49+ f"Received webhook with unregistered entity type: { entity_type } (event: { event .value } )"
50+ )
4151 return
4252
4353 return resource_type .process_webhook_event (entity_id , entity_data , event )
Original file line number Diff line number Diff line change @@ -29,10 +29,12 @@ def create_webhook():
2929 return
3030
3131 # Convert enum values to strings if needed
32- events = [event .value if hasattr (event , ' value' ) else event for event in events ]
32+ events = [event .value if hasattr (event , " value" ) else event for event in events ]
3333
3434 administration = get_moneybird_administration ()
35- response = administration .post ("webhooks" , data = {"url" : url , "enabled_events" : events })
35+ response = administration .post (
36+ "webhooks" , data = {"url" : url , "enabled_events" : events }
37+ )
3638 logging .info (f"Registered webhook with id { response ['id' ]} " )
3739 return response
3840
You can’t perform that action at this time.
0 commit comments