# Managerul de magazin comandă marfă

## Data mapping

The suppliers for a product are distinct for each facility. There is a party for each Facility. Suppliers are stored in mantle.product.ProductPrice, using the following fields:

- **productPriceId**: supplierId+"\_"+productId+"\_"+facilityPartyId
- **productId**: productId
- **vendorPartyId**: supplierId
- **customerPartyId**: facilityPartyId
- **priceTypeEnumId**: "PptCurrent"
- **pricePurposeEnumId**: "PppPurchase"
- **price**: price
- **priceUomId**: "RON"
- **preferredOrderEnumId**: "SpoMain" or "SpoAlternate"
- **otherPartyItemId**: supplierProductId
- **otherPartyItemName**: supplierProductName

Product Pareto category is stored as:

```
mantle.product.category.ProductCategoryMember
```

- **productCategoryId**: facilityPartyId+paretoCategory (eg.: L2A)
- **productId**: productId

```
mantle.product.category.ProductCategory
```

- **productCategoryId**: facilityPartyId+paretoCategory (eg.: L2A)
- **productCategoryTypeEnumId**: PctPareto
- **categoryName**: "Colibri Pareto A"
- **ownerPartyId**: L2

Products that should be kept in stock and replenished when sold are stored as:

```
mantle.product.Product
```

- **requireInventory**: Y or null

```
mantle.facility.ProductFacility:
```

- **productId**: productId
- **facilityId**: facilityId
- **minimumStock**: minimumStock

Product ordering requirements are stored as:

```
mantle.request.requirement.Requirement
```

- **requirementTypeEnumId**: RqTpInventory
- **statusId**: statusId
- **facilityId**: facilityId ?: ec.user.getPreference('FacilityActive') ?: ec.user.getPreference('FacilityGeneralDefault')
- **productId**: productId
- **quantity**: quantity
- **description**: supplier.organizationName

## Screen outline

### Necesar

- search widgets
- table 
    - cod
    - denumire
    - UM
    - pareto
    - ultimul preț achiziție fără TVA
    - preț vânzare
    - furnizori
    - stocAchCuTVA (hidden)
    - DIO(zile epuizare stoc) (hidden)
    - stocAchCuTVA \* DIO (hidden)
    - stocMinim
    - stoc L1
    - stoc L2
    - comanda recomandată L2
    - comenzi furnizor L2
    - adauga
- refresh button

### Aproba

- search widgets
- Comanda
- Delete
- table 
    - Cod
    - Denumire
    - UM
    - ULPfTVA
    - preț vânzare
    - Furnizori
    - Necesar
- Comanda popup 
    - furnizor
    - trimite pe

### Comenzi

- search widgets
- Delete
- table 
    - Cod
    - Denumire
    - UM
    - Furnizor
    - Comandat

## Screen data mapping

### Necesar

<table border="1" id="bkmrk-table-products-where"><tbody><tr><td>**Table**</td><td>**Products** WHERE Product.ACTIV\_FIELD = true AND Product.HIDE\_WHEN\_ORDERING\_FIELD = false  
**mantle.product.ProductPrices** WHERE requireInventory = Y/null AND customerPartyId = this gestiune partyId(L2)  
AND priceTypeEnumId = PptCurrent AND pricePurposeEnumId = PppPurchase</td></tr><tr><td>cod</td><td>Product.BARCODE\_FIELD</td></tr><tr><td>denumire</td><td>Product.NAME\_FIELD</td></tr><tr><td>UM</td><td>Product.UOM\_FIELD</td></tr><tr><td>Pareto

</td><td>mantle.product.category.ProductCategoryMember.productCategoryId</td></tr><tr><td>ultimul preț achiziție fără TVA</td><td>Product.LAST\_BUYING\_PRICE\_FIELD</td></tr><tr><td>preț vânzare</td><td>Product.PRICE\_FIELD</td></tr><tr><td>furnizori

</td><td>**Organization.organizationName** from ProductPrice.vendorPartyId WHERE preferredOrderEnumId = SpoMain

</td></tr><tr><td>stocAchCuTVA</td><td>product.stocLX \* lastBuyingPriceWithVAT</td></tr><tr><td>DIO</td><td>stocAchCuTVA / dailyCogs

dailyCogs = (Product.getTotalSalesPeUltimulAn - Product.getTotalProfitPeUltimulAn) / 250(zile lucratoare in an)

</td></tr><tr><td>stocMinim</td><td>PF.minimumStock

ProductFacility PF where PF.facilityId = gest.id AND PF.productId = product.id

</td></tr><tr><td>For each gestiune</td><td> </td></tr><tr><td>stoc gest.getImportName</td><td>p.stoc(gest)</td></tr><tr><td> </td><td> </td></tr><tr><td>comanda recomandată L2</td><td>PF.minimumStock-p.stoc(gest) ?. p.recommendedOrder(gest)</td></tr><tr><td>comenzi furnizor L2</td><td>SUM(R.quantity) mantle.request.requirement.Requirements R WHERE R.productId = product.id

</td></tr><tr><td>adauga</td><td>new Requirement with statusId = RqmtStCreated</td></tr></tbody></table>

### Aproba

<table border="1" id="bkmrk-table-requirements-r"><tbody><tr><td>**Table**</td><td>**Requirements R** WHERE R.statusId = RqmtStCreated AND R.facilityId = L2  
**JOIN Product P  
JOIN ProductPrice PP**

</td></tr><tr><td>Cod</td><td>P.BARCODE\_FIELD</td></tr><tr><td>Denumire</td><td>P.NAME\_FIELD</td></tr><tr><td>UM</td><td>P.UOM\_FIELD</td></tr><tr><td>ULPfTVA</td><td>P.LAST\_BUYING\_PRICE\_FIELD</td></tr><tr><td>preț vânzare</td><td>P.PRICE\_FIELD</td></tr><tr><td>Furnizori</td><td>**Organization.organizationNames** from PP.vendorPartyId  
ORDER BY PP.preferredOrderEnumId, PP.price

</td></tr><tr><td>Necesar</td><td>R.quantity</td></tr></tbody></table>

<table border="1" id="bkmrk-comanda-popup-select"><tbody><tr><td>**Comanda popup**</td><td>**Selected rows R**

</td></tr><tr><td>furnizor(**S**)</td><td>Auto select most common supplier from selected rows</td></tr><tr><td>trimite pe</td><td>Update on Supplier change  
Printeaza, ${PartyContactMech PCM WHERE PCM.contactMechPurposeId = 'PhoneShippingOrigin'},  
IF supplier is internal organization THEN Transfera

</td></tr></tbody></table>

### Comenzi

<table border="1" id="bkmrk-table-requirements-r-1"><tbody><tr><td>**Table**</td><td>**Requirements R** WHERE R.statusId = RqmtStOrdered AND R.facilityId = L2  
**JOIN Product P**

</td></tr><tr><td>Cod</td><td>P.BARCODE\_FIELD</td></tr><tr><td>Denumire</td><td>P.NAME\_FIELD</td></tr><tr><td>UM</td><td>P.UOM\_FIELD</td></tr><tr><td>Furnizor</td><td>R.description</td></tr><tr><td>Comandat</td><td>R.quantity</td></tr></tbody></table>