mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-05 03:12:34 -06:00
Добавил черновики накладных и OCR через Яндекс. LLM для расшифровки универсальный
This commit is contained in:
@@ -32,6 +32,7 @@ type ClientI interface {
|
||||
Auth() error
|
||||
Logout() error
|
||||
FetchCatalog() ([]catalog.Product, error)
|
||||
FetchStores() ([]catalog.Store, error)
|
||||
FetchMeasureUnits() ([]catalog.MeasureUnit, error)
|
||||
FetchRecipes(dateFrom, dateTo time.Time) ([]recipes.Recipe, error)
|
||||
FetchInvoices(from, to time.Time) ([]invoices.Invoice, error)
|
||||
@@ -337,6 +338,52 @@ func (c *Client) FetchCatalog() ([]catalog.Product, error) {
|
||||
return products, nil
|
||||
}
|
||||
|
||||
// FetchStores загружает список складов (Account -> INVENTORY_ASSETS)
|
||||
func (c *Client) FetchStores() ([]catalog.Store, error) {
|
||||
resp, err := c.doRequest("GET", "/resto/api/v2/entities/list", map[string]string{
|
||||
"rootType": "Account",
|
||||
"includeDeleted": "false",
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get stores error: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var dtos []AccountDTO
|
||||
if err := json.NewDecoder(resp.Body).Decode(&dtos); err != nil {
|
||||
return nil, fmt.Errorf("json decode stores error: %w", err)
|
||||
}
|
||||
|
||||
var stores []catalog.Store
|
||||
for _, d := range dtos {
|
||||
// Фильтруем только склады
|
||||
if d.Type != "INVENTORY_ASSETS" {
|
||||
continue
|
||||
}
|
||||
|
||||
id, err := uuid.Parse(d.ID)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
var parentCorpID uuid.UUID
|
||||
if d.ParentCorporateID != nil {
|
||||
if parsed, err := uuid.Parse(*d.ParentCorporateID); err == nil {
|
||||
parentCorpID = parsed
|
||||
}
|
||||
}
|
||||
|
||||
stores = append(stores, catalog.Store{
|
||||
ID: id,
|
||||
Name: d.Name,
|
||||
ParentCorporateID: parentCorpID,
|
||||
IsDeleted: d.Deleted,
|
||||
})
|
||||
}
|
||||
|
||||
return stores, nil
|
||||
}
|
||||
|
||||
// FetchMeasureUnits загружает справочник единиц измерения
|
||||
func (c *Client) FetchMeasureUnits() ([]catalog.MeasureUnit, error) {
|
||||
// rootType=MeasureUnit согласно документации iiko
|
||||
|
||||
@@ -28,6 +28,15 @@ type GenericEntityDTO struct {
|
||||
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"`
|
||||
|
||||
Reference in New Issue
Block a user