mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-04 19:02:33 -06:00
Перевел на multi-tenant
Добавил поставщиков Накладные успешно создаются из фронта
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"rmser/internal/domain/catalog"
|
||||
"rmser/internal/domain/invoices"
|
||||
"rmser/internal/domain/recipes"
|
||||
"rmser/internal/domain/suppliers"
|
||||
"rmser/pkg/logger"
|
||||
)
|
||||
|
||||
@@ -33,6 +34,7 @@ type ClientI interface {
|
||||
Logout() error
|
||||
FetchCatalog() ([]catalog.Product, error)
|
||||
FetchStores() ([]catalog.Store, error)
|
||||
FetchSuppliers() ([]suppliers.Supplier, error)
|
||||
FetchMeasureUnits() ([]catalog.MeasureUnit, error)
|
||||
FetchRecipes(dateFrom, dateTo time.Time) ([]recipes.Recipe, error)
|
||||
FetchInvoices(from, to time.Time) ([]invoices.Invoice, error)
|
||||
@@ -755,3 +757,39 @@ func (c *Client) UpdateProduct(product ProductFullDTO) (*ProductFullDTO, error)
|
||||
|
||||
return result.Response, nil
|
||||
}
|
||||
|
||||
// FetchSuppliers загружает список поставщиков через XML API
|
||||
func (c *Client) FetchSuppliers() ([]suppliers.Supplier, error) {
|
||||
// Endpoint /resto/api/suppliers
|
||||
resp, err := c.doRequest("GET", "/resto/api/suppliers", nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get suppliers error: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var xmlData SuppliersListXML
|
||||
if err := xml.NewDecoder(resp.Body).Decode(&xmlData); err != nil {
|
||||
return nil, fmt.Errorf("xml decode suppliers error: %w", err)
|
||||
}
|
||||
|
||||
var result []suppliers.Supplier
|
||||
for _, emp := range xmlData.Employees {
|
||||
id, err := uuid.Parse(emp.ID)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
isDeleted := emp.Deleted == "true"
|
||||
|
||||
result = append(result, suppliers.Supplier{
|
||||
ID: id,
|
||||
Name: emp.Name,
|
||||
Code: emp.Code,
|
||||
INN: emp.TaxpayerIdNumber,
|
||||
IsDeleted: isDeleted,
|
||||
// RMSServerID проставляется в сервисе перед сохранением
|
||||
})
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user