PRD0401 Create receipt Store orders

Basic Information

Module Production.ShopFloor
Code PRD0401
Parent Document Output Order
Sub-document Store Order
Full Name Create receipt Store orders
Status NEW
Deterministic YES
Supports Transitional Documents YES
Replaces GenerateStore_OrderReceipt
Orphan Rows None
Split Function OutputOrderLine.Store
Introduced In Version
Date of Suspension -

Business Logic

This Generation is used to create Store Orders for products from the current Output Order.

Different lines in the Output Order may have different Stores and for each value must be created a separate Store Order. The Store Order’s header is created based on the Output Orders’s header as follows:

StoreOrder.Store = Store

StoreOrder.MovementType = Receipt

StoreOrder.Status = "P"

StoreOrder.DueDate = WorkOrder.DueDate

StoreOrder.PlannedReleaseDate = WorkOrder.ReleaseDate

StoreOrder.PlannedCompletionDate = WorkOrder.DueDate

StoreOrder.DocumentCurrency = 

if Store.Currency.HasValue

​            then Store.Currency

​            else EnterpriseCompany.BaseCurrency
Note

The attributes which are not specified here are filled in as described in Standard Document Attributes

Fulfillments

Name OutputOrderLineToStoreOrderLine
Parent Entity OutputOrderLine
Child Entity StoreOrderLine
Parent / Child Relationship StoreOrderLine.ParentDocument = OutputOrder;StoreOrderLine.ParentLineNo = OutputOrderLine.LineNo

Metrics

Fulfillment Name Metric Name Measurement Unit Parent Value Child Value New Record
OutputOrderLineToStoreOrderLine MStandardQuantityBase OutputOrderLine.Product.BaseMeasurementUnit OutputOrderLine.ProducedStandardQuantityBase StoreOrderLine.StandardQuantityBase YES
OutputOrderLineToStoreOrderLine MQuantity OutputOrderLine.ProducedQuantityUnit OutputOrderLine.ProducedQuantity StoreOrderLine.Quantity NO
OutputOrderLineToStoreOrderLine MQuantityBase OutputOrderLine.Product.BaseMeasurementUnit OutputOrderLine.ProducedQuantityBase StoreOrderLine.QuantityBase NO
OutputOrderLineToStoreOrderLine MLineCost OutputOrderDistributedMaterialConsumption.issueCurrency = If ConsumptionOrderLine.Store.Currency.HasValue then issueCurrency = OutputOrderLine.Store.Currency else if ConsumptionOrderLine.ConsumptionOrder.Store.Currency.HasValue then issueCurrency = ConsumptionOrderLine.ConsumptionOrder.Store.Currency else ConsumptionOrderLine.ConsumptionOrder.EnterpriseCompany.BaseCurrency OutputOrderLine.SUM(OutputOrderDistributedMaterialConsumptions.Cost[OutputOrderLine = Current.OutputOrderLine) if issueCurrency != StoreOrder.DocumentCurrency, then try to CONVERT(OutputOrderDistributedMaterialConsumption.Cost) through ConsumptionOrder.CurrencyDirectory StoreOrderLine.LineCost YES

**If during the Calculation of the MLineCost metric is determined that the issueCurrency of the OutputOrderDistributedMaterialConsumption is different from the StoreOrder.DocumentCurrency, then the system tries to convert the OutputOrderDistributedMaterialConsumption. Cost to the StoreOrder.DocumentCurrency using the ConsumptionOrder.CurrencyDirectory. If ConsumptionOrder.CurrencyDirectory does not have a value, then the calculations stops with an error:

"The field 'Currency Directory' in table 'Gen_Documents' does not contain a value. Please set a value and try again."*

The lines of the new document are created based on the data of the Output Order Lines (sorted by LineOrder), of the Distributed Material Consumption (for more information, see topic Calculating Cost For Produced Products) and of the Fulfilled Part of quantities by Store Orders that has already been created (for more information, see topic Discrepancy System and Metrics).

For every Output Order Line are performed the following validations:

1. If for any of the OutputOrderLine countains a product that **is not stocked** (Product.ProductType.IsStocked = False), throw an error:
    "Output order line with line order '{LineOrd}' contains product which is not stocked. Such products cannot be part of store documents."
​    \2. If for any of the OutputOrderLine there is no value in the field Store (Store == NULL), throw an error:

  "The field 'Store' in o\*utput order line with\* line order '{LineOrd}' does not contain a value. Please set a value and try again."

For every Output Order Line is checked whether it has to be executed with a store documents aka if we have to create a Store Order Line for it or not, according to the following conditions:

  1. If the product in the line is not stocked (Product.ProductType.IsStocked = False) - return "false";
  2. If the line is not finished (Finished = False) and OutputOrder.WorkOrder != NULL - check whether the Work Order Line Operation filled in the line is the last Operation for this Item (checked by the LineOrder of the Operation in the Work Order document) - If the Operation is not last - return "false";
  3. else - return "true".

The new StoreOrderLine is created as follows:

StoreOrderLine.LineNo = OutputOrderLine.LineOrd

StoreOrderLine.ParentLineId = OutputOrderLineId

StoreOrderLine.Product = OutputOrderLine.Product

StoreOrderLine.StoreBin = 

if OutputOrderLine.StoreBin.HasValue

​            **then** OutputOrder.StoreBin

​            **else** **if** ProductDefaultStoreBins[Product=StoreOrderLine.Product].Count() = 1

​                **then** ProductDefaultStoreBin.[Product=StoreOrderLine.Product].DefaultBin

​                 **else** OutputOrderLine.Store.DefaultStoreBin

StoreOrderLine.SerialNumber = OutputOrderLine.SerialNumber

StoreOrderLine.Quantity = OutputOrderLine.REMAINING(MProducedQuantity)

StoreOrderLine.QuantityUnit = OutputOrderLine.ProducedQuantityUnit

StoreOrderLine.QuantityBase = OutputOrderLine.REMAINING(MProducedQuantityBase)

StoreOrderLine.StandardQuantityBase = OutputOrderLine.REMAINING(MProducedStandardQuantityBase)

StoreOrderLine.Lot = OtputOrderLine.Lot

StoreOrderLine.GuaranteePeriodDays = OutputOrderLine.Product.GuaranteePeriodDays

StoreOrderLine.Notes = OtputOrderLine.Notes

StoreOrderLine.ParentDocument = OutputOrder

StoreOrderLine.ParentLineNo = OutputOrderLine.LineNo

StoreOrderLine.TransactionTimeStamp = 

if OutputOrderLine.TransactionTimeStamp.HasValue

​            then StoreOrderLine.TransactionTimeStamp = OutputOrder.TransactionTimeStamp

else if (StoreOrder.DocumentType.TransitionalDocument == true)

​                then if (OutputOrder.CreationTime != StoreOrder.DocumentDate)

​                         then StoreOrderLine.**TransactionTimeStamp** = OutputOrder.CreationTime

​                    else StoreOrderLine.TransactionTimeStamp = StoreOrder.DocumentDate..AddHours(23).AddMinutes(58)

​     else StoreOrderLine.TransactionTimeStamp = NULL

>[!Note]
> WARNING: Any of the Shipment Orders created according to the description above is saved then and only when there is at least one line in it.