mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-04 19:02:33 -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"),
|
||||
|
||||
Reference in New Issue
Block a user