package rms import ( "encoding/xml" ) // --- JSON DTOs (V2 API) --- type ProductDTO struct { ID string `json:"id"` ParentID *string `json:"parent"` // Может быть null Name string `json:"name"` Num string `json:"num"` // Артикул Code string `json:"code"` // Код быстрого набора Type string `json:"type"` // GOODS, DISH, PREPARED, etc. UnitWeight float64 `json:"unitWeight"` UnitCapacity float64 `json:"unitCapacity"` MainUnit *string `json:"mainUnit"` Containers []ContainerDTO `json:"containers"` Deleted bool `json:"deleted"` } // GenericEntityDTO используется для простых справочников (MeasureUnit и др.) type GenericEntityDTO struct { ID string `json:"id"` Name string `json:"name"` Code string `json:"code"` Deleted bool `json:"deleted"` } // AccountDTO используется для парсинга складов (INVENTORY_ASSETS) type AccountDTO struct { ID string `json:"id"` Name string `json:"name"` Type string `json:"type"` // Нас интересует "INVENTORY_ASSETS" ParentCorporateID *string `json:"parentCorporateId"` Deleted bool `json:"deleted"` } // ContainerDTO - фасовка из iiko type ContainerDTO struct { ID string `json:"id"` Name string `json:"name"` // Название фасовки (напр. "Коробка") Count float64 `json:"count"` // Сколько базовых единиц в фасовке } type GroupDTO struct { ID string `json:"id"` ParentID *string `json:"parent"` Name string `json:"name"` Num string `json:"num"` Code string `json:"code"` Description string `json:"description"` Deleted bool `json:"deleted"` } type AssemblyChartsResponse struct { AssemblyCharts []AssemblyChartDTO `json:"assemblyCharts"` // preparedCharts и другие поля пока опускаем, если не нужны для базового импорта } type AssemblyChartDTO struct { ID string `json:"id"` AssembledProductID string `json:"assembledProductId"` DateFrom string `json:"dateFrom"` // Format: "2018-01-29" (yyyy-MM-dd) DateTo *string `json:"dateTo"` // Nullable Items []AssemblyItemDTO `json:"items"` } type AssemblyItemDTO struct { ID string `json:"id"` // Добавили поле ID строки техкарты ProductID string `json:"productId"` AmountIn float64 `json:"amountIn"` AmountOut float64 `json:"amountOut"` } // ProductFullDTO используется для получения (list?ids=...) и обновления (update) товара целиком. type ProductFullDTO struct { ID string `json:"id"` Deleted bool `json:"deleted"` Name string `json:"name"` Description string `json:"description"` Num string `json:"num"` Code string `json:"code"` Parent *string `json:"parent"` // null или UUID Modifiers []interface{} `json:"modifiers"` // Оставляем interface{}, чтобы не мапить сложную структуру, если не меняем её TaxCategory *string `json:"taxCategory"` Category *string `json:"category"` AccountingCategory *string `json:"accountingCategory"` Color map[string]int `json:"color"` FontColor map[string]int `json:"fontColor"` FrontImageID *string `json:"frontImageId"` Position *int `json:"position"` ModifierSchemaID *string `json:"modifierSchemaId"` MainUnit string `json:"mainUnit"` // Обязательное поле ExcludedSections []string `json:"excludedSections"` // Set DefaultSalePrice float64 `json:"defaultSalePrice"` PlaceType *string `json:"placeType"` DefaultIncInMenu bool `json:"defaultIncludedInMenu"` Type string `json:"type"` // GOODS, DISH... UnitWeight float64 `json:"unitWeight"` UnitCapacity float64 `json:"unitCapacity"` StoreBalanceLevels []StoreBalanceLevel `json:"storeBalanceLevels"` UseBalanceForSell bool `json:"useBalanceForSell"` Containers []ContainerFullDTO `json:"containers"` ProductScaleID *string `json:"productScaleId"` Barcodes []interface{} `json:"barcodes"` ColdLossPercent float64 `json:"coldLossPercent"` HotLossPercent float64 `json:"hotLossPercent"` OuterCode *string `json:"outerEconomicActivityNomenclatureCode"` AllergenGroups *string `json:"allergenGroups"` EstPurchasePrice float64 `json:"estimatedPurchasePrice"` CanSetOpenPrice bool `json:"canSetOpenPrice"` NotInStoreMovement bool `json:"notInStoreMovement"` } type StoreBalanceLevel struct { StoreID string `json:"storeId"` MinBalanceLevel *float64 `json:"minBalanceLevel"` MaxBalanceLevel *float64 `json:"maxBalanceLevel"` } type ContainerFullDTO struct { ID *string `json:"id,omitempty"` // При создании новой фасовки ID пустой/null Num string `json:"num"` // Порядковый номер? Обычно строка. Name string `json:"name"` Count float64 `json:"count"` MinContainerWeight float64 `json:"minContainerWeight"` MaxContainerWeight float64 `json:"maxContainerWeight"` ContainerWeight float64 `json:"containerWeight"` FullContainerWeight float64 `json:"fullContainerWeight"` BackwardRecalculation bool `json:"backwardRecalculation"` Deleted bool `json:"deleted"` UseInFront bool `json:"useInFront"` } // --- XML DTOs (Legacy API) --- type IncomingInvoiceListXML struct { XMLName xml.Name `xml:"incomingInvoiceDtoes"` Documents []IncomingInvoiceXML `xml:"document"` } type IncomingInvoiceXML struct { ID string `xml:"id"` DocumentNumber string `xml:"documentNumber"` DateIncoming string `xml:"dateIncoming"` // Format: yyyy-MM-ddTHH:mm:ss Status string `xml:"status"` // PROCESSED, NEW, DELETED Supplier string `xml:"supplier"` // GUID DefaultStore string `xml:"defaultStore"` // GUID Items []InvoiceItemXML `xml:"items>item"` } type InvoiceItemXML struct { Product string `xml:"product"` // GUID Amount float64 `xml:"amount"` // Количество в основных единицах Price float64 `xml:"price"` // Цена за единицу Sum float64 `xml:"sum"` // Сумма без скидки (обычно) VatSum float64 `xml:"vatSum"` // Сумма НДС } // --- XML DTOs (Store Reports) --- type StoreReportResponse struct { XMLName xml.Name `xml:"storeReportItemDtoes"` Items []StoreReportItemXML `xml:"storeReportItemDto"` } type StoreReportItemXML struct { // Основные идентификаторы ProductID string `xml:"product"` // GUID товара ProductGroup string `xml:"productGroup"` // GUID группы Store string `xml:"primaryStore"` // GUID склада DocumentID string `xml:"documentId"` // GUID документа DocumentNum string `xml:"documentNum"` // Номер документа (строка) // Типы (ENUMs) DocumentType string `xml:"documentType"` // Например: INCOMING_INVOICE TransactionType string `xml:"type"` // Например: INVOICE, WRITEOFF // Финансы и количество Amount float64 `xml:"amount"` // Количество Sum float64 `xml:"sum"` // Сумма с НДС SumWithoutNds float64 `xml:"sumWithoutNds"` // Сумма без НДС Cost float64 `xml:"cost"` // Себестоимость // Флаги и даты (используем строки для дат, так как парсинг делаем в сервисе) Incoming bool `xml:"incoming"` Date string `xml:"date"` OperationalDate string `xml:"operationalDate"` } // --- XML DTOs (Import API) --- // IncomingInvoiceImportXML описывает структуру для POST запроса импорта type IncomingInvoiceImportXML struct { XMLName xml.Name `xml:"document"` ID string `xml:"id,omitempty"` // GUID, если редактируем DocumentNumber string `xml:"documentNumber,omitempty"` DateIncoming string `xml:"dateIncoming,omitempty"` // Format: dd.MM.yyyy Invoice string `xml:"invoice,omitempty"` // Номер счет-фактуры DefaultStore string `xml:"defaultStore"` // GUID склада (обязательно) Supplier string `xml:"supplier"` // GUID поставщика (обязательно) Comment string `xml:"comment,omitempty"` Status string `xml:"status,omitempty"` // NEW, PROCESSED ItemsWrapper struct { Items []IncomingInvoiceImportItemXML `xml:"item"` } `xml:"items"` } type IncomingInvoiceImportItemXML struct { ProductID string `xml:"product"` // GUID товара Amount float64 `xml:"amount"` // Кол-во (в фасовках, если указан containerId) Price float64 `xml:"price"` // Цена за единицу (за фасовку, если указан containerId) Sum float64 `xml:"sum,omitempty"` // Сумма Store string `xml:"store"` // GUID склада ContainerId string `xml:"containerId,omitempty"` // ID фасовки AmountUnit string `xml:"amountUnit,omitempty"` // GUID единицы измерения (можно опустить, если фасовка) Num int `xml:"num,omitempty"` } // DocumentValidationResult описывает ответ сервера при импорте type DocumentValidationResult struct { XMLName xml.Name `xml:"documentValidationResult"` Valid bool `xml:"valid"` Warning bool `xml:"warning"` DocumentNumber string `xml:"documentNumber"` OtherSuggestedNumber string `xml:"otherSuggestedNumber"` ErrorMessage string `xml:"errorMessage"` AdditionalInfo string `xml:"additionalInfo"` } // --- Вспомогательные DTO для ответов (REST) --- // UpdateEntityResponse - ответ на /save или /update type UpdateEntityResponse struct { Result string `json:"result"` // "SUCCESS" or "ERROR" Response *ProductFullDTO `json:"response"` Errors []ErrorDTO `json:"errors"` } type ErrorDTO struct { Code string `json:"code"` Value string `json:"value"` }