mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-05 03:12:34 -06:00
added front - react+ts
ocr improved
This commit is contained in:
@@ -32,6 +32,7 @@ type ClientI interface {
|
||||
Auth() error
|
||||
Logout() error
|
||||
FetchCatalog() ([]catalog.Product, error)
|
||||
FetchMeasureUnits() ([]catalog.MeasureUnit, error)
|
||||
FetchRecipes(dateFrom, dateTo time.Time) ([]recipes.Recipe, error)
|
||||
FetchInvoices(from, to time.Time) ([]invoices.Invoice, error)
|
||||
FetchStoreOperations(presetID string, from, to time.Time) ([]StoreReportItemXML, error)
|
||||
@@ -295,6 +296,29 @@ func (c *Client) FetchCatalog() ([]catalog.Product, error) {
|
||||
parentID = &pid
|
||||
}
|
||||
}
|
||||
|
||||
// Обработка MainUnit
|
||||
var mainUnitID *uuid.UUID
|
||||
if p.MainUnit != nil {
|
||||
if uid, err := uuid.Parse(*p.MainUnit); err == nil {
|
||||
mainUnitID = &uid
|
||||
}
|
||||
}
|
||||
|
||||
// Маппинг фасовок
|
||||
var containers []catalog.ProductContainer
|
||||
for _, contDto := range p.Containers {
|
||||
cID, err := uuid.Parse(contDto.ID)
|
||||
if err == nil {
|
||||
containers = append(containers, catalog.ProductContainer{
|
||||
ID: cID,
|
||||
ProductID: id,
|
||||
Name: contDto.Name,
|
||||
Count: decimal.NewFromFloat(contDto.Count),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
products = append(products, catalog.Product{
|
||||
ID: id,
|
||||
ParentID: parentID,
|
||||
@@ -304,6 +328,8 @@ func (c *Client) FetchCatalog() ([]catalog.Product, error) {
|
||||
Type: p.Type,
|
||||
UnitWeight: decimal.NewFromFloat(p.UnitWeight),
|
||||
UnitCapacity: decimal.NewFromFloat(p.UnitCapacity),
|
||||
MainUnitID: mainUnitID,
|
||||
Containers: containers,
|
||||
IsDeleted: p.Deleted,
|
||||
})
|
||||
}
|
||||
@@ -311,6 +337,38 @@ func (c *Client) FetchCatalog() ([]catalog.Product, error) {
|
||||
return products, nil
|
||||
}
|
||||
|
||||
// FetchMeasureUnits загружает справочник единиц измерения
|
||||
func (c *Client) FetchMeasureUnits() ([]catalog.MeasureUnit, error) {
|
||||
// rootType=MeasureUnit согласно документации iiko
|
||||
resp, err := c.doRequest("GET", "/resto/api/v2/entities/list", map[string]string{
|
||||
"rootType": "MeasureUnit",
|
||||
"includeDeleted": "false",
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get measure units error: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var dtos []GenericEntityDTO
|
||||
if err := json.NewDecoder(resp.Body).Decode(&dtos); err != nil {
|
||||
return nil, fmt.Errorf("json decode error: %w", err)
|
||||
}
|
||||
|
||||
var result []catalog.MeasureUnit
|
||||
for _, d := range dtos {
|
||||
id, err := uuid.Parse(d.ID)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
result = append(result, catalog.MeasureUnit{
|
||||
ID: id,
|
||||
Name: d.Name,
|
||||
Code: d.Code,
|
||||
})
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *Client) FetchRecipes(dateFrom, dateTo time.Time) ([]recipes.Recipe, error) {
|
||||
params := map[string]string{
|
||||
"dateFrom": dateFrom.Format("2006-01-02"),
|
||||
|
||||
@@ -7,15 +7,32 @@ import (
|
||||
// --- 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"`
|
||||
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"`
|
||||
}
|
||||
|
||||
// ContainerDTO - фасовка из iiko
|
||||
type ContainerDTO struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"` // Название фасовки (напр. "Коробка")
|
||||
Count float64 `json:"count"` // Сколько базовых единиц в фасовке
|
||||
}
|
||||
|
||||
type GroupDTO struct {
|
||||
|
||||
Reference in New Issue
Block a user