public SalesOrderSnapshot CreateNewSalesOrderSnapshot(Guid salesOrderId) { using (TrackerEntitiesContainer tec = GetNewTrackerObjectContext()) { GetSalesOrderDetails_Result result = tec.GetSalesOrderDetails(salesOrderId).FirstOrDefault(); if (result == null) { return(null); } SalesOrderSnapshot snapshot = this.CreateSalesOrderSnapshot(result, salesOrderId); var historyEvents = tec.GetSalesOrderHistory(salesOrderId).OrderBy(he => he.eventDate); bool isFirstPrepayment = true; foreach (GetSalesOrderHistory_Result hResult in historyEvents) { SalesOrderEvent soe = this.CreateSalesOrderEvent(hResult, snapshot, isFirstPrepayment); snapshot.SalesOrderEvents.Add(soe); if (soe.EventName == EventName.FirstPrepayment && isFirstPrepayment) { isFirstPrepayment = false; } } return(snapshot); } }
private SalesOrderEvent CreateSalesOrderEvent(GetSalesOrderHistory_Result hResult, SalesOrderSnapshot salesOrder, bool isFirstPrepayment) { var result = new SalesOrderEvent() { Date = hResult.eventDate, Number = hResult.documentNumber, Value = hResult.documentValue, ContractNumber = salesOrder.Number }; result.SetEventType(hResult.eventType.Value, salesOrder.SalesTypeName, isFirstPrepayment); return(result); }
private Event ToSOTEvent(SalesOrderEvent salesOrderEvent, SalesOrderSnapshot salesOrder) { Event result = null; switch (salesOrderEvent.EventName) { case EventName.DocumentIssued: result = new DocumentIssuedEvent(salesOrderEvent.EventName, salesOrderEvent.ContractNumber, salesOrderEvent.Date.Value) { Login = salesOrder.Contractor.Login, Password = salesOrder.Contractor.Password, RelatedDocumentNumber = salesOrderEvent.Number }; break; case EventName.DocumentSettled: case EventName.FirstPrepayment: case EventName.NextPrepayment: case EventName.RelatedSalesDocumentIssued: result = new RelatedDocumentEvent(salesOrderEvent.EventName, salesOrderEvent.ContractNumber, salesOrderEvent.Date.Value, salesOrderEvent.Number, salesOrderEvent.Value.Value); break; case EventName.MarkedAsPlanned: result = new MarkedAsPlannedEvent(salesOrderEvent.EventName, salesOrderEvent.ContractNumber, salesOrderEvent.Date.Value, salesOrder.ProductionOrderNumber); break; case EventName.MarkedAsReady: case EventName.MarkedAsReadyToInstallation: result = new Event(salesOrderEvent.EventName, salesOrderEvent.ContractNumber, salesOrderEvent.Date.Value); break; } if (result != null) { result.InitDescription(); salesOrderEvent.Description = result.Description; } return(result); }