| Quintiq file version 2.0 | 
| #parent: #root | 
| Method Update ( | 
|   Product_MP owner, | 
|   StockingPoint_MP stockingpoint, | 
|   Date startdate, | 
|   Date enddate, | 
|   Real quantity, | 
|   Real price, | 
|   String priorityname, | 
|   Real demanduncertaintypercentage, | 
|   String salessegmentname, | 
|   String currencyname, | 
|   String unitofmeasurename, | 
|   Boolean isexcludedfromfulfillmentkpi, | 
|   Boolean isfromdb | 
| ) | 
| { | 
|   Description: 'Update sales demand' | 
|   TextBody: | 
|   [* | 
|     //Don't change these if the owner being passed in is null | 
|     if( not isnull( owner ) ) | 
|     { | 
|       this.ProductID( owner.ID() ); | 
|       this.StockingPointID( guard( stockingpoint.ID(), '' ) ); | 
|      | 
|         //There may be cases when sales demand is not linked to a PISP | 
|       oldpisp := this.ProductInStockingPoint_MP(); | 
|       needsync := isnull( oldpisp ) | 
|                   or oldpisp.Product_MP() <> owner | 
|                   or oldpisp.StockingPoint_MP() <> stockingpoint; | 
|      | 
|       if( needsync ) | 
|       { | 
|         owner.SalesDemand( relmove, this ); | 
|      | 
|         // Get new pisp and remove old pisp | 
|         owner.AddToStockingPoint( stockingpoint ); | 
|      | 
|         //This is needed to get the pispip when synchronizing sdip | 
|         Transaction::Transaction().Propagate( relation( ProductInStockingPoint_MP, SalesDemand ) ); | 
|       } | 
|     } | 
|      | 
|     // If quantity had been updated, reset the optimizer fulfillment of SDIP | 
|     resetoptimizerfulfillment := this.SalesDemandInPeriod( relsize ) > 0 | 
|                                  and sum( this, SalesDemandInPeriod, sdip, sdip.Quantity() ) <> quantity; | 
|      | 
|     this.StartDate( startdate ); | 
|      | 
|     if ( enddate.IsInfinite() ) | 
|     { | 
|       // Customer order don't had an end date, need to set it to start date | 
|       enddate := startdate; | 
|     } | 
|      | 
|     this.EndDate( enddate ); | 
|     this.Quantity( quantity ); | 
|     this.ExpectedQuantity( quantity ); | 
|     this.Price( price ); | 
|     this.PriorityName( ifexpr( not isexcludedfromfulfillmentkpi, priorityname, '' ) ); | 
|     this.DemandUncertaintyPercentage( demanduncertaintypercentage ); | 
|     this.SalesSegmentName( salessegmentname ); | 
|     this.CurrencyID( currencyname ); | 
|     this.UnitOfMeasureName( unitofmeasurename ); | 
|     this.IsExcludedFromFulfillmentKPIUser( isexcludedfromfulfillmentkpi ); | 
|     this.IsManuallyConfigured( not isfromdb ); | 
|      | 
|     // Sychronize sales demand in period | 
|     if( not isfromdb ) | 
|     { | 
|       this.SynchronizeSalesDemandInPeriod( resetoptimizerfulfillment ); | 
|     } | 
|      | 
|     // Create decision log | 
|     description := Translations::MP_SalesDemand_Commit_Description( this ); | 
|     this.Product_MP().MacroPlan().CreateDecisionLog( description, true ); | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Extensible' } | 
| } |