55from typing import Any , cast
66
77from suz_sdk .api .reports import (
8+ AggregationUnit ,
89 ReceiptFilter ,
910 ReportsApi ,
1011 ReportStatusResponse ,
@@ -79,7 +80,7 @@ async def send_dropout(
7980 self ,
8081 product_group : str ,
8182 sntins : list [str ],
82- dropout_reason : str | None = None ,
83+ dropout_reason : str ,
8384 attributes : dict [str , Any ] | None = None ,
8485 ) -> SendDropoutResponse :
8586 """Send a KM dropout report (POST /api/v3/dropout)."""
@@ -90,9 +91,8 @@ async def send_dropout(
9091 body_dict : dict [str , Any ] = {
9192 "productGroup" : product_group ,
9293 "sntins" : sntins ,
94+ "dropoutReason" : dropout_reason ,
9395 }
94- if dropout_reason is not None :
95- body_dict ["dropoutReason" ] = dropout_reason
9696 if attributes is not None :
9797 body_dict ["attributes" ] = attributes
9898
@@ -120,8 +120,8 @@ async def send_dropout(
120120 async def send_aggregation (
121121 self ,
122122 product_group : str ,
123- sntins : list [ str ] ,
124- aggregation_type : str | None = None ,
123+ participant_id : str ,
124+ aggregation_units : list [ AggregationUnit ] ,
125125 attributes : dict [str , Any ] | None = None ,
126126 ) -> SendAggregationResponse :
127127 """Send a KM aggregation report (POST /api/v3/aggregation)."""
@@ -131,10 +131,18 @@ async def send_aggregation(
131131
132132 body_dict : dict [str , Any ] = {
133133 "productGroup" : product_group ,
134- "sntins" : sntins ,
134+ "participantId" : participant_id ,
135+ "aggregationUnits" : [
136+ {
137+ "aggregatedItemsCount" : u .aggregated_items_count ,
138+ "aggregationType" : "AGGREGATION" ,
139+ "aggregationUnitCapacity" : u .aggregation_unit_capacity ,
140+ "sntins" : u .sntins ,
141+ "unitSerialNumber" : u .unit_serial_number ,
142+ }
143+ for u in aggregation_units
144+ ],
135145 }
136- if aggregation_type is not None :
137- body_dict ["aggregationType" ] = aggregation_type
138146 if attributes is not None :
139147 body_dict ["attributes" ] = attributes
140148
@@ -162,20 +170,36 @@ async def send_aggregation(
162170 async def send_surplus (
163171 self ,
164172 product_group : str ,
165- sntins : list [str ],
166- attributes : dict [str , Any ] | None = None ,
173+ document_date : str ,
174+ participant_inn : str ,
175+ primary_document_custom_name : str ,
176+ primary_document_date : str ,
177+ primary_document_number : str ,
178+ codes : list [str ],
179+ document_type : str = "SURPLUS_POSTING" ,
180+ document_version : str = "1.0" ,
181+ participant_kpp : str | None = None ,
182+ participant_fias : str | None = None ,
167183 ) -> SendSurplusResponse :
168- """Send a KM surplus report (POST /api/v3/surplus)."""
184+ """Send a surplus posting notification (POST /api/v3/surplus, §4.4.12 )."""
169185 from suz_sdk .transport .async_httpx_transport import AsyncHttpxTransport
170186
171187 transport : AsyncHttpxTransport = self ._transport # type: ignore[assignment]
172188
173189 body_dict : dict [str , Any ] = {
174- "productGroup" : product_group ,
175- "sntins" : sntins ,
190+ "documentType" : document_type ,
191+ "documentVersion" : document_version ,
192+ "documentDate" : document_date ,
193+ "participantInn" : participant_inn ,
194+ "primaryDocumentCustomName" : primary_document_custom_name ,
195+ "primaryDocumentDate" : primary_document_date ,
196+ "primaryDocumentNumber" : primary_document_number ,
197+ "codes" : codes ,
176198 }
177- if attributes is not None :
178- body_dict ["attributes" ] = attributes
199+ if participant_kpp is not None :
200+ body_dict ["participantKpp" ] = participant_kpp
201+ if participant_fias is not None :
202+ body_dict ["participantFias" ] = participant_fias
179203
180204 raw_body = json .dumps (body_dict , ensure_ascii = False ).encode ()
181205
@@ -190,7 +214,7 @@ async def send_surplus(
190214 req = Request (
191215 method = "POST" ,
192216 path = "/api/v3/surplus" ,
193- params = {"omsId" : self ._oms_id },
217+ params = {"omsId" : self ._oms_id , "productGroup" : product_group },
194218 headers = headers ,
195219 raw_body = raw_body ,
196220 )
0 commit comments