CRM0601 Create Sales Orders (Single Execution)
General Information
Module | Crm.Crm.Marketing |
---|---|
Code | CRM0601 |
Parent Document | Marketing Activities |
Sub-document | Sales Orders |
Full Name | Create Sales Orders (Single Execution) |
Deterministic | YES |
Status | NEW |
Supports Transitional Documents | NO |
Supports Single Execution | YES |
Replaces | - |
Orphan Rows | Ignore |
Split Function | - |
Version | Introduced: 2023 |
Date of Suspension | - |
Business Logic
This generation is single execution only. If there are unfulfilled quantities from the Marketing Activity there will be no automatically generated documents for the differences. You can still create an execution for the differences by manually starting the generation.
To create a sales order, the customer has to be specified.
The customer is extracted from the Target party, selected in the Marketing Activity (MarketingActivity.TargetParty). The customer has to be up-to-date,
with active customer definition for this party in the enterprise company of the sales order (SalesOrder.EnterpriseCompany) or for all enterprise companies:
(Customer.Party = MarketingActivity.TargetParty &&
(Customer.EnterpriseCompany == SalesOrder.EnterpriseCompany || Customer.EnterpriseCompany == null) &&
Customer.Active == true && (Customer.FromDate <= SalesOrder.DocumentDate || Customer.FromDate == null) &&
(Customer.ThruDate >= SalesOrder.DocumentDate || Customer.ThruDate == null).
If no such customer is found, the generation procedure is stopped and an error is thrown. The error text is:
No valid client is found for '{MarketingActivity.TargetParty.PartyName}' party.
In order to create a sales order, there must be an active customer for '{MarketingActivity.TargetParty.PartyName}' party,
applicable to the current enterprise company."
The fields in the Sales Order’s header are filled as follows:
SalesOrder.Customer = the determined Customer for the MarketingActivity.TargetParty
SalesOrder.DocumentDate = Today
SalesOrder.ShipToPartyContactMechanism =
if (Count(PartyContactMechanisms, where Party == SalesOrder.Customer.Party && IsDefault == true) == 1)
, then ShipToPartyContactMechanism = First(PartyContactMechanisms, where Party == SalesOrder.Customer.Party && IsDefault == true)
, else SalesOrder.ShipToPartyContactMechanism = null
SalesOrder.DocumentCurrency = SalesOrder.EnterpriseCompany.BaseCurrency
SalesOrder.PaymentDueDate = DocumentDate + Customer.DefaultPaymentTermDays
SalesOrder.PaymentDueStartDate = DocumentDate + Customer.DefaultPaymentStartDays
SalesOrder.RequiredDeliveryDate = DocumentDate + Customer.DefaultDeliveryTermDays
SalesOrder.DistributionChannel = Customer.DefaultDistributionChannel
SalesOrder.PaymentAccount = Customer.DefaultPaymentAccount
SalesOrder.PaymentType = Customer.DefaultPaymentType
SalesOrder.PriceList = Customer.DefaultPriceList
SalesOrder.CreditLimitOverride = false
SalesOrder.Deal = null
SalesOrder.SalesPerson = null
SalesOrder.Dealer = null
SalesOrder.Store = null
SalesOrder.ShipToCustomer = null
SalesOrder.DealType = null
SalesOrder.CustomerPurchaseOrderDate = null
SalesOrder.CustomerPurchaseOrderNo = null
SalesOrder.PosLocation = null
SalesOrder.PosOperator = null
SalesOrder.PosTerminal = null
SalesOrder.FiscalSalesNumber = null
SalesOrder.FiscalPrinterPosDevice = null
SalesOrder.EndCustomerParty = null
SalesOrder.DeliveryTermsCode = null
SalesOrder.IntrastatTransactionNatureCode = null
SalesOrder.IntrastatTransportModeCode = null
SalesOrder.IntrastatTransportCountry = null
SalesOrder.ReturnForInvoice = null
SalesOrder.ReturnForSalesOrder = null
SalesOrder.FromDate = null
SalesOrder.ToDate = null
SalesOrder.Notes = null
Note
The attributes which are not specified here are filled in as described in Standard Document Attributes
Fulfillments
Name | MarketingActivityLineToSalesOrderLine |
---|---|
Parent Entity | MarketingActivityLine |
Child Entity | SalesOrderLine |
Parent / Child Relationship | SalesOrderLine.ParentDocument = MarketingActivity; SalesOrderLine.ParentLineNo = MarketingActivityLine.LineNo |
Metrics
Fulfillment Name | Metric Name | Measurement Unit | Parent Value | Child Value | New Record |
---|---|---|---|---|---|
MarketingActivityLineToSalesOrderLine | MStandardQuantityBase | MarketingActivityLine.Product.BaseMeasurementCategory.BaseUnit | CONVERT(MarketingActivityLine.OrderQuantity, MarketingActivityLine.Product.BaseMeasurementCategory.BaseUnit) | SalesOrderLine.StandardQuantityBase | YES |
The new Sales Order Line is created as follows:
SalesOrderLine.LineNo = MarketingActivity.LineNo
SalesOrderLine.Product = MarketingActivity.Product
SalesOrderLine.ProductDescription = SalesOrderLine.Product.Name
SalesOrderLine.GuaranteePeriodDays = SalesOrderLine.Product.GuaranteePeriodDays
SalesOrderLine.ProductCode = null
SalesOrderLine.ProductPrice = loaded by the 'Determine product price'* method
SalesOrderLine.UnitPrice = loaded by the 'Calculate Unit Price' method
SalesOrderLine.StandardUnitPrice = loaded by the 'Get Standard Unit Price' method
SalesOrderLine.RequestedQuantity = null
SalesOrderLine.Quantity = CONVERT( REMAINING(MarketingActivityLine.MStandardQuantityBase), MarketingActivityLine.OrderQuantityUnit)
SalesOrderLine.QuantityUnit = MarketingActivityLine.OrderQuantityUnit
SalesOrderLine.QuantityBase = REMAINING(MarketingActivityLine.MStandardQuantityBase)
SalesOrderLine.StandardQuantityBase = REMAINING(MarketingActivityLine.MStandardQuantityBase)
SalesOrderLine.Level1Discount = loaded by the 'Determine line discount'* method
SalesOrderLine.Level1DiscountPercent =
if (SalesOrderLine.Level1Discount != null)
, then SalesOrderLine.Level1DiscountPercent = SalesOrderLine.Level1Discount.DiscountPercent
, else SalesOrderLine.Level1DiscountPercent = null
SalesOrderLine.Level2Discount = loaded by the 'Determine line discount'* method
SalesOrderLine.Level2DiscountPercent =
if (SalesOrderLine.Level2Discount != null)
, then SalesOrderLine.Level2DiscountPercent = SalesOrderLine.Level2Discount.DiscountPercent
, else SalesOrderLine.Level2DiscountPercent = null
SalesOrderLine.Level3Discount = loaded by the 'Determine line discount'* method
SalesOrderLine.Level3DiscountPercent =
if (SalesOrderLine.Level3Discount != null)
, then SalesOrderLine.Level3DiscountPercent = SalesOrderLine.Level3Discount.DiscountPercent
, else SalesOrderLine.Level3DiscountPercent = null
SalesOrderLine.LineStandardDiscountPercent = loaded by the 'Determine Line Standard Discount Percent' method
SalesOrderLine.LineCustomDiscountPercent = 0.00%
SalesOrderLine.LineAmount = loaded by the 'Determine line amount in sales orders'* method
SalesOrderLine.LineEndCustomerParty = null
SalesOrderLine.RequiredDeliveryDate = SalesOrder.RequiredDeliveryDate
PersistLot = false
SalesOrderLine.Notes = MarketingActivityLine.Notes
SalesOrderLine.ParentDocument = MarketingActivity
SalesOrderLine.ParentLineNo = MarketingActivityLine.LineNo
SalesOrderLine.Lot = null
SalesOrderLine.SerialNumber = null
SalesOrderLine.ProductVariant = null
SalesOrderLine.LineStore = null
SalesOrderLine.StoreBin = null
SalesOrderLine.LineDealType = null
SalesOrderLine.BonusProgram = null
SalesOrderLine.PromotionalPackage = null
SalesOrderLine.IntrastatApplyDate = null
SalesOrderLine.DeliveryTermsCode = null
SalesOrderLine.IntrastatTransactionNatureCode = null
SalesOrderLine.IntrastatTransportModeCode = null
SalesOrderLine.IntrastatTransportCountry = null
SalesOrderLine.ReturnForInvoiceLine = null
SalesOrderLine.ReturnForSalesOrderLine = null
SalesOrderLine.HistoricalDataJson = null
SalesOrderLine.HistoricalUnitCost = null
SalesOrderLine.LineFromDate = null
SalesOrderLine.LineToDate = null