mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-04 19:02:33 -06:00
start rmser
This commit is contained in:
146
internal/infrastructure/rms/dto.go
Normal file
146
internal/infrastructure/rms/dto.go
Normal file
@@ -0,0 +1,146 @@
|
||||
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"`
|
||||
Deleted bool `json:"deleted"`
|
||||
}
|
||||
|
||||
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"`
|
||||
}
|
||||
|
||||
// --- 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"` // Кол-во в базовых единицах
|
||||
Price float64 `xml:"price"` // Цена за единицу
|
||||
Sum float64 `xml:"sum,omitempty"`
|
||||
Store string `xml:"store"` // GUID склада
|
||||
// Поля ниже можно опустить, если iiko должна сама подтянуть их из карточки товара
|
||||
// или если мы работаем в базовых единицах.
|
||||
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"`
|
||||
}
|
||||
Reference in New Issue
Block a user