Перевел на multi-tenant

Добавил поставщиков
Накладные успешно создаются из фронта
This commit is contained in:
2025-12-18 03:56:21 +03:00
parent 47ec8094e5
commit 542beafe0e
38 changed files with 1942 additions and 977 deletions

View File

@@ -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
}