This commit is contained in:
diPhantxm
2024-12-27 23:12:33 +03:00
parent 7f71ed6545
commit 3c17a365a3
2 changed files with 111 additions and 97 deletions

View File

@@ -13,8 +13,11 @@ type Finance struct {
} }
type ReportOnSoldProductsParams struct { type ReportOnSoldProductsParams struct {
// Time period in the `YYYY-MM` format // Month
Date string `json:"date"` Month int32 `json:"month"`
// Year
Year int32 `json:"year"`
} }
type ReportOnSoldProductsResponse struct { type ReportOnSoldProductsResponse struct {
@@ -34,7 +37,7 @@ type ReportonSoldProductsResult struct {
type ReportOnSoldProductsResultHeader struct { type ReportOnSoldProductsResultHeader struct {
// Report ID // Report ID
Id string `json:"num"` Id string `json:"number"`
// Report generation date // Report generation date
DocDate string `json:"doc_date"` DocDate string `json:"doc_date"`
@@ -43,10 +46,10 @@ type ReportOnSoldProductsResultHeader struct {
ContractDate string `json:"contract_date"` ContractDate string `json:"contract_date"`
// Offer agreement number // Offer agreement number
ContractNum string `json:"contract_num"` ContractNum string `json:"contract_number"`
// Currency of your prices // Currency of your prices
CurrencyCode string `json:"currency_code"` CurrencySysName string `json:"currency_sys_name"`
// Amount to accrue // Amount to accrue
DocAmount float64 `json:"doc_amount"` DocAmount float64 `json:"doc_amount"`
@@ -64,13 +67,13 @@ type ReportOnSoldProductsResultHeader struct {
PayerName string `json:"payer_name"` PayerName string `json:"payer_name"`
// Recipient's TIN // Recipient's TIN
RecipientINN string `json:"rcv_inn"` RecipientINN string `json:"receiver_inn"`
// Recipient's Tax Registration Reason Code (KPP) // Recipient's Tax Registration Reason Code (KPP)
RecipientKPP string `json:"rcv_kpp"` RecipientKPP string `json:"receiver_kpp"`
// Recipient's name // Recipient's name
RecipientName string `json:"rcv_name"` RecipientName string `json:"receiver_name"`
// Period start in the report // Period start in the report
StartDate string `json:"start_date"` StartDate string `json:"start_date"`
@@ -81,13 +84,28 @@ type ReportOnSoldProductsResultHeader struct {
type ReportOnSoldProductsResultRow struct { type ReportOnSoldProductsResultRow struct {
// Row number // Row number
RowNumber int32 `json:"row_number"` RowNumber int32 `json:"rowNumber"`
// Product ID // Product Information
ProductId int64 `json:"product_id"` Item ReturnOnSoldProduct `json:"item"`
// Commission including the quantity of products, discounts and extra charges.
// Ozon compensates it for the returned products
ReturnCommission ReturnCommission `json:"return_commission"`
// Percentage of sales commission by category
CommissionRatio float64 `json:"commission_ratio"`
// Delivery fee
DeliveryCommission ReturnCommission `json:"delivery_commission"`
// Seller's discounted price
SellerPricePerInstance float64 `json:"seller_price_per_instance"`
}
type ReturnOnSoldProduct struct {
// Product name // Product name
ProductName string `json:"product_name"` ProductName string `json:"name"`
// Product barcode // Product barcode
Barcode string `json:"barcode"` Barcode string `json:"barcode"`
@@ -95,58 +113,39 @@ type ReportOnSoldProductsResultRow struct {
// Product identifier in the seller's system // Product identifier in the seller's system
OfferId string `json:"offer_id"` OfferId string `json:"offer_id"`
// Sales commission by category SKU int64 `json:"sku"`
CommissionPercent float64 `json:"commission_percent"` }
// Seller's price with their discount type ReturnCommission struct {
Price float64 `json:"price"` // Amount
Amount float64 `json:"amount"`
// Selling price: the price at which the customer purchased the product. For sold products // Points for discounts
PriceSale float64 `json:"price_sale"` Bonus float64 `json:"bonus"`
// Sold for amount.
//
// Sold products cost considering the quantity and regional coefficients. Calculation is made by the sale_amount price
SaleAmount float64 `json:"sale_amount"`
// Commission for sold products, including discounts and extra charges // Commission for sold products, including discounts and extra charges
SaleCommission float64 `json:"sale_commission"` Commission float64 `json:"commission"`
// Extra charge at the expense of Ozon. // Additional payment at the expense of Ozon
// Compensation float64 `json:"compensation"`
// Amount that Ozon will compensate the seller if the Ozon discount is greater than or equal to the sales commission
SaleDiscount float64 `json:"sale_discount"`
// Total accrual for the products sold. // Price per item
// PricePerInstance float64 `json:"price_per_instance"`
// Amount after deduction of sales commission, application of discounts and extra charges
SalePriceSeller float64 `json:"sale_price_seller"`
// Quantity of products sold at the price_sale price // Product quantity
SaleQuantity int32 `json:"sale_qty"` Quantity int32 `json:"quantity"`
// Price at which the customer purchased the product. For returned products // Ozon referral fee
ReturnSale float64 `json:"return_sale"` StandardFee float64 `json:"standard_fee"`
// Cost of returned products, taking into account the quantity and regional coefficients. // Payouts on partner loyalty mechanics: green prices
// Calculation is carried out at the return_sale price BankCoinvestment float64 `json:"bank_coinvestment"`
ReturnAmount float64 `json:"return_amount"`
// Commission including the quantity of products, discounts and extra charges. // Payouts on partner loyalty mechanics: stars
// Ozon compensates it for the returned products Stars float64 `json:"stars"`
ReturnCommission float64 `json:"return_commission"`
// Extra charge at the expense of Ozon. // Total accrual
// Total float64 `json:"total"`
// Amount of the discount at the expense of Ozon on returned products.
// Ozon will compensate it to the seller if the Ozon discount is greater than or equal to the sales commission
ReturnDiscount float64 `json:"return_discount"`
// Amount charged to the seller for returned products after deducing sales commissions, applying discounts and extra charges
ReturnPriceSeller float64 `json:"return_price_seller"`
// Quantity of returned products
ReturnQuantity int32 `json:"return_qty"`
} }
// Returns information on products sold and returned within a month. Canceled or non-purchased products are not included. // Returns information on products sold and returned within a month. Canceled or non-purchased products are not included.

View File

@@ -23,52 +23,67 @@ func TestReportOnSoldProducts(t *testing.T) {
http.StatusOK, http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"}, map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
&ReportOnSoldProductsParams{ &ReportOnSoldProductsParams{
Date: "2022-09", Month: 9,
Year: 2022,
}, },
`{ `{
"result": { "result": {
"header": { "header": {
"doc_date": "2022-09-22", "contract_date": "string",
"num": "string", "contract_number": "string",
"start_date": "2022-09-02", "currency_sys_name": "string",
"stop_date": "2022-09-22", "doc_amount": 0,
"contract_date": "2022-09-02", "doc_date": "string",
"contract_num": "string", "number": "string",
"payer_name": "string", "payer_inn": "string",
"payer_inn": "string", "payer_kpp": "string",
"payer_kpp": "string", "payer_name": "string",
"rcv_name": "string", "receiver_inn": "string",
"rcv_inn": "string", "receiver_kpp": "string",
"rcv_kpp": "string", "receiver_name": "string",
"doc_amount": 1, "start_date": "string",
"vat_amount": 1, "stop_date": "string",
"currency_code": "string" "vat_amount": 0
}, },
"rows": [ "rows": [
{ {
"row_number": 0, "commission_ratio": 0,
"product_id": 0, "delivery_commission": {
"product_name": "string", "amount": 0,
"offer_id": "string", "bonus": 0,
"barcode": "string", "commission": 0,
"price": 0, "compensation": 0,
"commission_percent": 0, "price_per_instance": 0,
"price_sale": 0, "quantity": 0,
"sale_qty": 0, "standard_fee": 0,
"sale_amount": 0, "bank_coinvestment": 0,
"sale_discount": 0, "stars": 0,
"sale_commission": 0, "total": 0
"sale_price_seller": 0, },
"return_sale": 0, "item": {
"return_qty": 0, "barcode": "string",
"return_amount": 0, "name": "string",
"return_discount": 0, "offer_id": "string",
"return_commission": 0, "sku": 0
"return_price_seller": 0 },
} "return_commission": {
] "amount": 0,
} "bonus": 0,
}`, "commission": 0,
"compensation": 0,
"price_per_instance": 0,
"quantity": 0,
"standard_fee": 0,
"bank_coinvestment": 0,
"stars": 0,
"total": 0
},
"rowNumber": 0,
"seller_price_per_instance": 0
}
]
}
}`,
"", "",
}, },
// Test No Client-Id or Api-Key // Test No Client-Id or Api-Key