protected static FR_L5AWSSC_GoCSCfCO_1105_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5AWSSC_GoCSCfCO_1105 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5AWSSC_GoCSCfCO_1105_Array(); // Get active shopping cart status for tenant var statusActive = CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_Status.Query.Search(Connection, Transaction, new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_Status.Query() { GlobalPropertyMatchingID = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(DLCore_DBCommons.APODemand.EShoppingCartStatus.Active), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); CL5_APOWebShop_ShoppingCart.Atomic.Retrieval.P_L5AWSAR_GSCfCO_1805 getParameter = new CL5_APOWebShop_ShoppingCart.Atomic.Retrieval.P_L5AWSAR_GSCfCO_1805(); getParameter.OfficeID = Parameter.OfficeID; getParameter.ShoppingCartStatusID = statusActive.ORD_PRC_ShoppingCart_StatusID; // Find ProductGroupMatchingID for BusinessParticipant_RefID var account = new CL1_USR.ORM_USR_Account(); account.Load(Connection, Transaction, securityTicket.AccountID); //getParameter.ProductGroupMatchingID = EnumUtils.GetEnumDescription(EProductGroup.HauseList); // Retrieve shopping cart var shoppingCartProducts = CL5_APOWebShop_ShoppingCart.Atomic.Retrieval.cls_Get_ShoppingChart_for_CurrentOffice.Invoke(Connection, Transaction, getParameter, securityTicket).Result; if (shoppingCartProducts.Length == 0) { // Create shopping cart. CL5_APOWebShop_ShoppingCart.Complex.Manipulation.P_L5AWSAR_CSC_1809 createParameter = new CL5_APOWebShop_ShoppingCart.Complex.Manipulation.P_L5AWSAR_CSC_1809(); createParameter.OfficeID = Parameter.OfficeID; Guid shoppingCartID = CL5_APOWebShop_ShoppingCart.Complex.Manipulation.cls_Create_ShoppingChart_for_CurrentOffice.Invoke(Connection, Transaction, createParameter, securityTicket).Result; // Again retrieve shopping cart shoppingCartProducts = CL5_APOWebShop_ShoppingCart.Atomic.Retrieval.cls_Get_ShoppingChart_for_CurrentOffice.Invoke(Connection, Transaction, getParameter, securityTicket).Result; } List <L5AWSSC_GoCSCfCO_1105> shoppingCarts = new List <L5AWSSC_GoCSCfCO_1105>(); foreach (var item in shoppingCartProducts) { L5AWSSC_GoCSCfCO_1105 shoppingCart = new L5AWSSC_GoCSCfCO_1105(); shoppingCart.ORD_PRC_ShoppingCartID = item.ORD_PRC_ShoppingCartID; shoppingCart.CMN_STR_Office_RefID = item.CMN_STR_Office_RefID; shoppingCart.ORD_PRC_Office_ShoppingCartID = item.ORD_PRC_Office_ShoppingCartID; shoppingCart.IsProcurementOrderCreated = item.IsProcurementOrderCreated; shoppingCart.Office_InternalName = item.Office_InternalName; shoppingCart.ShoppingCartStatus = item.ShoppingCartStatus; shoppingCart.Products = item.Products; shoppingCarts.Add(shoppingCart); } returnValue.Result = shoppingCarts.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_L5BL_GPDfB_1119 Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5BL_GPDfB_1119(); returnValue.Result = new L5BL_GPDfB_1119(); //Put your code here returnValue.Result.PaymentTypes = CL2_AccountingPayment.Atomic.Retrieval.cls_Get_AllPaymentTypes_For_TenandID.Invoke(Connection, Transaction, securityTicket).Result; returnValue.Result.PaymentDeadlines = CL2_AccountingPayment.Atomic.Retrieval.cls_Get_AllPaymentDeadlines_For_TenandID.Invoke(Connection, Transaction, securityTicket).Result; var account = new CL1_USR.ORM_USR_Account(); account.Load(Connection, Transaction, securityTicket.AccountID); var incrNumberParam = new P_L2NR_GINfUA_1113() { GlobalStaticMatchingID = EnumUtils.GetEnumDescription(ENumberRangeUsageAreaType.BillNumber) }; var billNumber = cls_Get_IncreasingNumber_for_UsageArea.Invoke(Connection, Transaction, incrNumberParam, securityTicket).Result.Current_IncreasingNumber; returnValue.Result.BillNumber = billNumber; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5CO_EBH_1108 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); #region Preloading data var BillParam = Parameter.Bill_Parameter.BillHeaderData; var billHeader = CL1_BIL.ORM_BIL_BillHeader.Query.Search(Connection, Transaction, new CL1_BIL.ORM_BIL_BillHeader.Query() { BIL_BillHeaderID = BillParam.BIL_BillHeaderID }).SingleOrDefault(); var ucd = CL1_CMN.ORM_CMN_UniversalContactDetail.Query.Search(Connection, Transaction, new CL1_CMN.ORM_CMN_UniversalContactDetail.Query() { CMN_UniversalContactDetailID = BillParam.CMN_UniversalContactDetailID }).SingleOrDefault(); var account = new CL1_USR.ORM_USR_Account(); account.Load(Connection, Transaction, securityTicket.AccountID); var customer = CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, new CL1_CMN_BPT_CTM.ORM_CMN_BPT_CTM_Customer.Query() { CMN_BPT_CTM_CustomerID = BillParam.BillingReceiverCustomer.CMN_BPT_CTM_CustomerID }).SingleOrDefault(); #endregion if (BillParam.BillingAddressID != Guid.Empty) { List <L3ACAAD_GCAfT_1612> customerAddresses = cls_Get_CustomerAddresses_for_CustomerID.Invoke(Connection, Transaction, new P_L3ACAAD_GCAfCID_1612 { CustomerID = BillParam.BillingReceiverCustomer.CMN_BPT_CTM_CustomerID }, securityTicket).Result.ToList(); L3ACAAD_GCAfT_1612 customerAddress = customerAddresses.Where(x => x.AddressID == BillParam.BillingAddressID).SingleOrDefault(); ucd.CMN_UniversalContactDetailID = BillParam.CMN_UniversalContactDetailID; ucd.Country_639_1_ISOCode = customerAddress.Country_639_1_ISOCode; ucd.Country_Name = customerAddress.Country_Name; ucd.Street_Name = customerAddress.Street_Name; ucd.Street_Number = customerAddress.Street_Number; ucd.Town = customerAddress.Town; ucd.ZIP = customerAddress.ZIP; ucd.Tenant_RefID = account.Tenant_RefID; ucd.CompanyName_Line1 = BillParam.BillingReceiverCustomer.DisplayName; ucd.First_Name = BillParam.BillingReceiverCustomer.FirstName; ucd.Last_Name = BillParam.BillingReceiverCustomer.LastName; ucd.IsCompany = BillParam.BillingReceiverCustomer.IsCompany; ucd.Save(Connection, Transaction); } billHeader.CreatedBy_BusinessParticipant_RefID = account.BusinessParticipant_RefID; billHeader.BillRecipient_BuisnessParticipant_RefID = customer.Ext_BusinessParticipant_RefID; billHeader.Tenant_RefID = account.Tenant_RefID; billHeader.BillingAddress_UCD_RefID = ucd.CMN_UniversalContactDetailID; billHeader.DateOnBill = BillParam.BillingDate; billHeader.BillComment = BillParam.Comment; billHeader.BillHeader_PaymentCondition_RefID = Parameter.Bill_Parameter.BillHeaderData.PaymentTargetID; billHeader.Save(Connection, Transaction); #region Method of Payment var methodOfPayment = CL1_BIL.ORM_BIL_BillHeader_MethodOfPayment.Query.Search(Connection, Transaction, new CL1_BIL.ORM_BIL_BillHeader_MethodOfPayment.Query { BIL_BillHeader_RefID = billHeader.BIL_BillHeaderID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (methodOfPayment == null) { methodOfPayment = new CL1_BIL.ORM_BIL_BillHeader_MethodOfPayment { BIL_BillHeader_MethodOfPaymentID = Guid.NewGuid(), ACC_PAY_Type_RefID = Parameter.Bill_Parameter.BillHeaderData.PaymentTypeID, BIL_BillHeader_RefID = billHeader.BIL_BillHeaderID, IsPreferredMethodOfPayment = true, SequenceNumber = 0, Tenant_RefID = securityTicket.TenantID }; } methodOfPayment.ACC_PAY_Type_RefID = Parameter.Bill_Parameter.BillHeaderData.PaymentTypeID; methodOfPayment.Save(Connection, Transaction); #endregion returnValue.Result = billHeader.BIL_BillHeaderID; return(returnValue); #endregion UserCode }
protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Bool(); // Get shopping cart status - Ordered var statusOrdered = CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_Status.Query.Search(Connection, Transaction, new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_Status.Query() { GlobalPropertyMatchingID = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(DLCore_DBCommons.APODemand.EShoppingCartStatus.Ordered), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); var tenant = securityTicket.TenantID; #region Find All Shopping Carts in Approved state for TenantID //var approvedShoppingCarts = var scParam = new CL5_APOWebShop_ShoppingCart.Atomic.Retrieval.P_L5AWSSC_GASC_1413() { Status_GlobalPropertyMatchingID_List = new string[] { DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(DLCore_DBCommons.APODemand.EShoppingCartStatus.Approved) } }; var approvedShoppingCarts = CL5_APOWebShop_ShoppingCart.Atomic.Retrieval.cls_Get_All_ShoppingCarts.Invoke(Connection, Transaction, scParam, securityTicket).Result; if (approvedShoppingCarts == null || approvedShoppingCarts.Count() == 0) { returnValue.Result = false; return(returnValue); } #endregion #region Procurement Order // Get procurement order status var procurementOrderStatus = CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Status.Query.Search(Connection, Transaction, new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Status.Query() { GlobalPropertyMatchingID = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(DLCore_DBCommons.APODemand.EProcurementStatus.Active), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); var account = new CL1_USR.ORM_USR_Account(); account.Load(Connection, Transaction, securityTicket.AccountID); // Find last added procurement order header var lastProcurementOrderHeader = CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Header.Query.Search(Connection, Transaction, new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Header.Query { Tenant_RefID = securityTicket.TenantID }).OrderByDescending(x => Convert.ToInt64(x.ProcurementOrder_Number)).FirstOrDefault(); // Find last procurement order number long procurementOrderNumber = 0; if (lastProcurementOrderHeader != null) { procurementOrderNumber = Convert.ToInt64(lastProcurementOrderHeader.ProcurementOrder_Number); } // Create procurement order header var procurementOrderHeader = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Header(); procurementOrderHeader.Tenant_RefID = securityTicket.TenantID; procurementOrderHeader.CreatedBy_BusinessParticipant_RefID = account.BusinessParticipant_RefID; procurementOrderHeader.Current_ProcurementOrderStatus_RefID = procurementOrderStatus.ORD_PRC_ProcurementOrder_StatusID; procurementOrderHeader.ProcurementOrder_Supplier_RefID = Guid.Empty; procurementOrderHeader.ProcurementOrder_Date = DateTime.Now; //procurementOrderHeader.TotalValue_BeforeTax = 0; procurementOrderHeader.ProcurementOrder_Number = (++procurementOrderNumber).ToString(); procurementOrderHeader.Save(Connection, Transaction); // Create procurement order status history var procurementOrderStatusHistory = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_StatusHistory(); procurementOrderStatusHistory.Tenant_RefID = securityTicket.TenantID; procurementOrderStatusHistory.ProcurementOrder_Header_RefID = procurementOrderHeader.ORD_PRC_ProcurementOrder_HeaderID; procurementOrderStatusHistory.ProcurementOrder_Status_RefID = procurementOrderStatus.ORD_PRC_ProcurementOrder_StatusID; procurementOrderStatusHistory.Save(Connection, Transaction); #endregion foreach (var item in approvedShoppingCarts) { var shoppingProducts = CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_Product.Query.Search(Connection, Transaction, new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_Product.Query { IsCanceled = false, ORD_PRC_ShoppingCart_RefID = item.ORD_PRC_ShoppingCartID, IsDeleted = false }); #region Procurement Order Shopping Products // Create and save procurement order for shopping products foreach (var shoppingProduct in shoppingProducts) { var procurementOrderPosition = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Position(); procurementOrderPosition.Tenant_RefID = securityTicket.TenantID; procurementOrderPosition.ProcurementOrder_Header_RefID = procurementOrderHeader.ORD_PRC_ProcurementOrder_HeaderID; procurementOrderPosition.Position_Quantity = shoppingProduct.Quantity; procurementOrderPosition.CMN_PRO_Product_RefID = shoppingProduct.CMN_PRO_Product_RefID; procurementOrderPosition.CMN_PRO_Product_Release_RefID = shoppingProduct.CMN_PRO_Product_Release_RefID; procurementOrderPosition.CMN_PRO_Product_Variant_RefID = shoppingProduct.CMN_PRO_Product_Variant_RefID; procurementOrderPosition.Save(Connection, Transaction); var shoppingCart2ProcurementOrder = new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_2_ProcurementOrderPosition(); shoppingCart2ProcurementOrder.Tenant_RefID = securityTicket.TenantID; shoppingCart2ProcurementOrder.ORD_PRC_ShoppingCart_Product_RefID = shoppingProduct.ORD_PRC_ShoppingCart_ProductID; shoppingCart2ProcurementOrder.ORD_PRC_ProcurementOrder_Position_RefID = procurementOrderPosition.ORD_PRC_ProcurementOrder_PositionID; shoppingCart2ProcurementOrder.Save(Connection, Transaction); } #endregion #region Shopping Cart var shoppingCart = new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart(); shoppingCart.Load(Connection, Transaction, item.ORD_PRC_ShoppingCartID); shoppingCart.IsProcurementOrderCreated = true; //returnValue = new FR_Guid(shoppingCart.Save(Connection, Transaction), procurementOrderHeader.ORD_PRC_ProcurementOrder_HeaderID); shoppingCart.Save(Connection, Transaction); // Create and save new shopping cart history var shoppingHistory = new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCartStatus_History(); shoppingHistory.ORD_PRC_ShoppingCart_RefID = shoppingCart.ORD_PRC_ShoppingCartID; shoppingHistory.ORD_PRC_ShoppingCart_Status_RefID = statusOrdered.ORD_PRC_ShoppingCart_StatusID; shoppingHistory.PerformedBy_Account_RefID = securityTicket.AccountID; shoppingHistory.Tenant_RefID = securityTicket.TenantID; shoppingHistory.Save(Connection, Transaction); #endregion } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); // Get shopping cart status - Ordered var statusOrdered = CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_Status.Query.Search(Connection, Transaction, new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_Status.Query() { GlobalPropertyMatchingID = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(DLCore_DBCommons.APODemand.EShoppingCartStatus.Ordered), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); var tenant = securityTicket.TenantID; #region Find All Shopping Carts in Approved state for TenantID var statusApproved = CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_Status.Query.Search(Connection, Transaction, new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_Status.Query { Tenant_RefID = securityTicket.TenantID, GlobalPropertyMatchingID = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(DLCore_DBCommons.APODemand.EShoppingCartStatus.Approved), IsDeleted = false }).Single(); var approvedShoppingCarts = CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart.Query.Search(Connection, Transaction, new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart.Query { ShoppingCart_CurrentStatus_RefID = statusApproved.ORD_PRC_ShoppingCart_StatusID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }); if (approvedShoppingCarts == null || approvedShoppingCarts.Count() == 0) { returnValue.Result = Guid.Empty; return(returnValue); } #endregion #region Procurement Order // Get procurement order status var procurementOrderStatus = CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Status.Query.Search(Connection, Transaction, new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Status.Query() { GlobalPropertyMatchingID = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(DLCore_DBCommons.APODemand.EProcurementStatus.Active), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); var account = new CL1_USR.ORM_USR_Account(); account.Load(Connection, Transaction, securityTicket.AccountID); #region var incrNumberParam = new P_L2NR_GaIINfUA_1454() { GlobalStaticMatchingID = EnumUtils.GetEnumDescription(ENumberRangeUsageAreaType.ProcurementOrderNumber) }; var procurementNumber = cls_Get_and_Increase_IncreasingNumber_for_UsageArea.Invoke(Connection, Transaction, incrNumberParam, securityTicket).Result.Current_IncreasingNumber; #endregion // Create procurement order header var procurementOrderHeader = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Header(); procurementOrderHeader.Tenant_RefID = securityTicket.TenantID; procurementOrderHeader.CreatedBy_BusinessParticipant_RefID = account.BusinessParticipant_RefID; procurementOrderHeader.Current_ProcurementOrderStatus_RefID = procurementOrderStatus.ORD_PRC_ProcurementOrder_StatusID; procurementOrderHeader.ProcurementOrder_Supplier_RefID = Guid.Empty; procurementOrderHeader.ProcurementOrder_Date = DateTime.Now; procurementOrderHeader.TotalValue_BeforeTax = 0; procurementOrderHeader.ProcurementOrder_Number = procurementNumber; procurementOrderHeader.Save(Connection, Transaction); // Create procurement order status history var procurementOrderStatusHistory = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_StatusHistory(); procurementOrderStatusHistory.Tenant_RefID = securityTicket.TenantID; procurementOrderStatusHistory.ProcurementOrder_Header_RefID = procurementOrderHeader.ORD_PRC_ProcurementOrder_HeaderID; procurementOrderStatusHistory.ProcurementOrder_Status_RefID = procurementOrderStatus.ORD_PRC_ProcurementOrder_StatusID; procurementOrderStatusHistory.Save(Connection, Transaction); // Set return value returnValue.Result = procurementOrderHeader.ORD_PRC_ProcurementOrder_HeaderID; #endregion foreach (var item in approvedShoppingCarts) { #region Procurement Order Shopping Products var param = new P_L5AWSSC_GSPfSC_1650(); param.ShoppingCartID = item.ORD_PRC_ShoppingCartID; var shoppingProducts = cls_Get_ShoppingProducts_for_ShoppingCartID.Invoke(Connection, Transaction, param, securityTicket).Result; //when office is deleted but there is ordered items for it if (shoppingProducts == null) { continue; } // Create and save procurement order for shopping products foreach (var shoppingProduct in shoppingProducts.Products) { #region Skip if Product is not good if (shoppingProduct.IsProductCanceled || shoppingProduct.IsProductDeleted) { continue; } #endregion var procurementOrderPosition = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Position(); procurementOrderPosition.ORD_PRC_ProcurementOrder_PositionID = Guid.NewGuid(); procurementOrderPosition.ProcurementOrder_Header_RefID = procurementOrderHeader.ORD_PRC_ProcurementOrder_HeaderID; procurementOrderPosition.Position_Quantity = shoppingProduct.Quantity; procurementOrderPosition.Position_ValuePerUnit = shoppingProduct.Price; procurementOrderPosition.Position_ValueTotal = shoppingProduct.Price * (Decimal)shoppingProduct.Quantity; procurementOrderPosition.Position_Unit_RefID = Guid.Empty; procurementOrderPosition.Position_RequestedDateOfDelivery = new DateTime(); procurementOrderPosition.CMN_PRO_Product_RefID = shoppingProduct.CMN_PRO_Product_RefID; procurementOrderPosition.CMN_PRO_Product_Release_RefID = shoppingProduct.CMN_PRO_Product_Release_RefID; procurementOrderPosition.CMN_PRO_Product_Variant_RefID = shoppingProduct.CMN_PRO_Product_Variant_RefID; procurementOrderPosition.Creation_Timestamp = DateTime.Now; procurementOrderPosition.Tenant_RefID = securityTicket.TenantID; procurementOrderPosition.IsProductReplacementAllowed = shoppingProduct.IsProductReplacementAllowed; procurementOrderPosition.Save(Connection, Transaction); var shoppingCart2ProcurementOrder = new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_2_ProcurementOrderPosition(); shoppingCart2ProcurementOrder.AssignmentID = Guid.NewGuid(); shoppingCart2ProcurementOrder.ORD_PRC_ShoppingCart_Product_RefID = shoppingProduct.ORD_PRC_ShoppingCart_ProductID; shoppingCart2ProcurementOrder.ORD_PRC_ProcurementOrder_Position_RefID = procurementOrderPosition.ORD_PRC_ProcurementOrder_PositionID; shoppingCart2ProcurementOrder.Tenant_RefID = securityTicket.TenantID; shoppingCart2ProcurementOrder.Save(Connection, Transaction); procurementOrderHeader.TotalValue_BeforeTax += procurementOrderPosition.Position_ValueTotal; } #endregion #region ShoppingCartNotes var notesParam = new P_L5AWSAR_GSCNfSC_1454() { ShoppingCartID = item.ORD_PRC_ShoppingCartID }; var scNotes = cls_Get_ShoppingCart_Notes_for_ShoppingCartID.Invoke(Connection, Transaction, notesParam, securityTicket).Result; var count = 1; foreach (var scNote in scNotes) { if (!scNote.IsNoteForProcurementOrder) { continue; } var officeInfo = ORM_ORD_PRC_Office_ShoppingCart.Query.Search(Connection, Transaction, new ORM_ORD_PRC_Office_ShoppingCart.Query() { ORD_PRC_ShoppingCart_RefID = item.ORD_PRC_ShoppingCartID, IsDeleted = false }).Single(); var note = new ORM_ORD_PRC_ProcurementOrder_Note(); note.ORD_PRC_ProcurementOrder_NoteID = Guid.NewGuid(); note.ORD_PRC_ProcurementOrder_Header_RefID = procurementOrderHeader.ORD_PRC_ProcurementOrder_HeaderID; note.ORD_PRC_ProcurementOrder_Position_RefID = Guid.Empty; note.CMN_STR_Office_RefID = officeInfo.CMN_STR_Office_RefID; note.Comment = scNote.Memo_Text; note.Title = ""; note.NotePublishDate = scNote.UpdatedOn; note.SequenceOrderNumber = count; note.Tenant_RefID = securityTicket.TenantID; note.Save(Connection, Transaction); count++; } #endregion #region Shopping Cart // Change shopping cart status item.ShoppingCart_CurrentStatus_RefID = statusOrdered.ORD_PRC_ShoppingCart_StatusID; item.IsProcurementOrderCreated = true; item.Save(Connection, Transaction); // Create and save new shopping cart history var shoppingHistory = new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCartStatus_History(); shoppingHistory.ORD_PRC_ShoppingCart_RefID = item.ORD_PRC_ShoppingCartID; shoppingHistory.ORD_PRC_ShoppingCart_Status_RefID = statusOrdered.ORD_PRC_ShoppingCart_StatusID; shoppingHistory.PerformedBy_Account_RefID = securityTicket.AccountID; shoppingHistory.Tenant_RefID = securityTicket.TenantID; shoppingHistory.Save(Connection, Transaction); #endregion } //Save TotalValue_BeforeTax after updates procurementOrderHeader.Save(Connection, Transaction); return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5WS_DOfSC_1525 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); //Put your code here #region Shopping cart // Get shopping cart var shoppingCart = new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart(); shoppingCart.Load(Connection, Transaction, Parameter.ORD_PRC_ShoppingCartID); // Get shopping cart status var statusOrdered = CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_Status.Query.Search(Connection, Transaction, new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_Status.Query() { GlobalPropertyMatchingID = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(DLCore_DBCommons.APODemand.EShoppingCartStatus.Ordered), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); // Create and save new shopping cart history var shoppingHistory = new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCartStatus_History(); shoppingHistory.ORD_PRC_ShoppingCart_RefID = shoppingCart.ORD_PRC_ShoppingCartID; shoppingHistory.ORD_PRC_ShoppingCart_Status_RefID = statusOrdered.ORD_PRC_ShoppingCart_StatusID; shoppingHistory.PerformedBy_Account_RefID = securityTicket.AccountID; shoppingHistory.Tenant_RefID = securityTicket.TenantID; shoppingHistory.Save(Connection, Transaction); var shoppingProducts = CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_Product.Query.Search(Connection, Transaction, new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_Product.Query { ORD_PRC_ShoppingCart_RefID = Parameter.ORD_PRC_ShoppingCartID, IsDeleted = false }); // Save shopping cart shoppingCart.IsProcurementOrderCreated = true; shoppingCart.ShoppingCart_CurrentStatus_RefID = statusOrdered.ORD_PRC_ShoppingCart_StatusID; #endregion #region Procurement Order // Get procurement order status var procurementOrderStatus = CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Status.Query.Search(Connection, Transaction, new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Status.Query() { GlobalPropertyMatchingID = DLCore_DBCommons.Utils.EnumUtils.GetEnumDescription(DLCore_DBCommons.APODemand.EProcurementStatus.Active), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); var account = new CL1_USR.ORM_USR_Account(); account.Load(Connection, Transaction, securityTicket.AccountID); // Find last added procurement order header var lastProcurementOrderHeader = CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Header.Query.Search(Connection, Transaction, new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Header.Query { Tenant_RefID = securityTicket.TenantID }).OrderByDescending(x => Convert.ToInt64(x.ProcurementOrder_Number)).FirstOrDefault(); // Find last procurement order number long procurementOrderNumber = 0; if (lastProcurementOrderHeader != null) { procurementOrderNumber = Convert.ToInt64(lastProcurementOrderHeader.ProcurementOrder_Number); } // Create procurement order header var procurementOrderHeader = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Header(); procurementOrderHeader.Tenant_RefID = securityTicket.TenantID; procurementOrderHeader.CreatedBy_BusinessParticipant_RefID = account.BusinessParticipant_RefID; procurementOrderHeader.Current_ProcurementOrderStatus_RefID = procurementOrderStatus.ORD_PRC_ProcurementOrder_StatusID; procurementOrderHeader.ProcurementOrder_Supplier_RefID = Guid.Empty; procurementOrderHeader.ProcurementOrder_Date = DateTime.Now; //procurementOrderHeader.TotalValue_BeforeTax = 0; procurementOrderHeader.ProcurementOrder_Number = (++procurementOrderNumber).ToString(); procurementOrderHeader.Save(Connection, Transaction); // Create procurement order status history var procurementOrderStatusHistory = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_StatusHistory(); procurementOrderStatusHistory.Tenant_RefID = securityTicket.TenantID; procurementOrderStatusHistory.ProcurementOrder_Header_RefID = procurementOrderHeader.ORD_PRC_ProcurementOrder_HeaderID; procurementOrderStatusHistory.ProcurementOrder_Status_RefID = procurementOrderStatus.ORD_PRC_ProcurementOrder_StatusID; procurementOrderStatusHistory.Save(Connection, Transaction); returnValue = new FR_Guid(shoppingCart.Save(Connection, Transaction), procurementOrderHeader.ORD_PRC_ProcurementOrder_HeaderID); #endregion #region Procurement Order Shopping Products // Create and save procurement order for shopping products foreach (var shoppingProduct in shoppingProducts) { var procurementOrderPosition = new CL1_ORD_PRC.ORM_ORD_PRC_ProcurementOrder_Position(); procurementOrderPosition.Tenant_RefID = securityTicket.TenantID; procurementOrderPosition.ProcurementOrder_Header_RefID = procurementOrderHeader.ORD_PRC_ProcurementOrder_HeaderID; procurementOrderPosition.Position_Quantity = shoppingProduct.Quantity; procurementOrderPosition.CMN_PRO_Product_RefID = shoppingProduct.CMN_PRO_Product_RefID; procurementOrderPosition.CMN_PRO_Product_Release_RefID = shoppingProduct.CMN_PRO_Product_Release_RefID; procurementOrderPosition.CMN_PRO_Product_Variant_RefID = shoppingProduct.CMN_PRO_Product_Variant_RefID; procurementOrderPosition.Save(Connection, Transaction); var shoppingCart2ProcurementOrder = new CL1_ORD_PRC.ORM_ORD_PRC_ShoppingCart_2_ProcurementOrderPosition(); shoppingCart2ProcurementOrder.Tenant_RefID = securityTicket.TenantID; shoppingCart2ProcurementOrder.ORD_PRC_ShoppingCart_Product_RefID = shoppingProduct.ORD_PRC_ShoppingCart_ProductID; shoppingCart2ProcurementOrder.ORD_PRC_ProcurementOrder_Position_RefID = procurementOrderPosition.ORD_PRC_ProcurementOrder_PositionID; shoppingCart2ProcurementOrder.Save(Connection, Transaction); } #endregion return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5CO_CSHfCO_1528 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); #region Get CustomerOrderHeader var customerOrderHeader = new CL1_ORD_CUO.ORM_ORD_CUO_CustomerOrder_Header(); customerOrderHeader.Load(Connection, Transaction, Parameter.CustomerOrderHeaderID); #endregion var incrNumberParam = new P_L2NR_GaIINfUA_1454() { GlobalStaticMatchingID = EnumUtils.GetEnumDescription(ENumberRangeUsageAreaType.ShipmentNumber) }; var shipmentHeaderNumber = cls_Get_and_Increase_IncreasingNumber_for_UsageArea.Invoke(Connection, Transaction, incrNumberParam, securityTicket).Result.Current_IncreasingNumber; var shipmentHeader = new CL1_LOG_SHP.ORM_LOG_SHP_Shipment_Header(); shipmentHeader.LOG_SHP_Shipment_HeaderID = Guid.NewGuid(); shipmentHeader.ShipmentHeader_Number = shipmentHeaderNumber; shipmentHeader.Tenant_RefID = securityTicket.TenantID; shipmentHeader.IsPartiallyReadyForPicking = false; shipmentHeader.IsReadyForPicking = false; shipmentHeader.HasPickingFinished = false; shipmentHeader.HasPickingStarted = false; shipmentHeader.IsShipped = false; shipmentHeader.IsBilled = false; shipmentHeader.IsPartialShippingAllowed = true; shipmentHeader.ShipmentHeader_Currency_RefID = customerOrderHeader.CustomerOrder_Currency_RefID; shipmentHeader.RecipientBusinessParticipant_RefID = customerOrderHeader.OrderingCustomer_BusinessParticipant_RefID; shipmentHeader.Shippipng_AddressUCD_RefID = customerOrderHeader.ShippingAddressUCD_RefID; shipmentHeader.Save(Connection, Transaction); if (shipmentHeader.Shippipng_AddressUCD_RefID == Guid.Empty) { var AllAddressForShipmentHeader = cls_Get_AllAddresses_for_ShipmentHeaderID.Invoke(Connection, Transaction, new P_L3SO_GAAfSHI_1612 { ShipmentHeaderID = shipmentHeader.LOG_SHP_Shipment_HeaderID }, securityTicket).Result.ToList(); var defaultAddressForOU = AllAddressForShipmentHeader.Where(x => x.hasOrganizationUnit).SingleOrDefault(x => x.IsDefault); if (defaultAddressForOU != null) { shipmentHeader.Shippipng_AddressUCD_RefID = cls_Save_Address_for_ShipmentHeaderID.Invoke(Connection, Transaction, new P_L3SO_SA_f_SHI_1535 { LOG_SHP_Shipment_HeaderID = shipmentHeader.LOG_SHP_Shipment_HeaderID, StreetName = defaultAddressForOU.Street_Name, StreetNumber = defaultAddressForOU.Street_Number, Town = defaultAddressForOU.Town, ZIP = defaultAddressForOU.ZIP, IsCompany = defaultAddressForOU.IsCompany }, securityTicket).Result; } else { var defaultAddressForCustomer = AllAddressForShipmentHeader.Where(x => !x.hasOrganizationUnit && x.IsCompany && x.IsShipping).SingleOrDefault(x => x.IsDefault); if (defaultAddressForCustomer != null) { shipmentHeader.Shippipng_AddressUCD_RefID = cls_Save_Address_for_ShipmentHeaderID.Invoke(Connection, Transaction, new P_L3SO_SA_f_SHI_1535 { LOG_SHP_Shipment_HeaderID = shipmentHeader.LOG_SHP_Shipment_HeaderID, StreetName = defaultAddressForCustomer.Street_Name, StreetNumber = defaultAddressForCustomer.Street_Number, Town = defaultAddressForCustomer.Town, ZIP = defaultAddressForCustomer.ZIP, IsCompany = defaultAddressForCustomer.IsCompany }, securityTicket).Result; } else { var defaultPersonAddress = AllAddressForShipmentHeader.Where(x => !x.IsCompany).SingleOrDefault(x => x.IsDefault); if (defaultPersonAddress != null) { shipmentHeader.Shippipng_AddressUCD_RefID = cls_Save_Address_for_ShipmentHeaderID.Invoke(Connection, Transaction, new P_L3SO_SA_f_SHI_1535 { LOG_SHP_Shipment_HeaderID = shipmentHeader.LOG_SHP_Shipment_HeaderID, StreetName = defaultPersonAddress.Street_Name, StreetNumber = defaultPersonAddress.Street_Number, Town = defaultPersonAddress.Town, ZIP = defaultPersonAddress.ZIP, IsCompany = defaultPersonAddress.IsCompany }, securityTicket).Result; } } } } var shipmentToCustomerOrderHeader = new CL1_LOG_SHP.ORM_LOG_SHP_ShipmentHeader_2_CustomerOrderHeader(); shipmentToCustomerOrderHeader.ORD_CUO_CustomerOrder_Header_RefID = Parameter.CustomerOrderHeaderID; shipmentToCustomerOrderHeader.LOG_SHP_Shipment_Header_RefID = shipmentHeader.LOG_SHP_Shipment_HeaderID; shipmentToCustomerOrderHeader.Tenant_RefID = securityTicket.TenantID; shipmentToCustomerOrderHeader.Save(Connection, Transaction); #region Status #region Get Current Account var account = new CL1_USR.ORM_USR_Account(); account.Load(Connection, Transaction, securityTicket.AccountID); #endregion var statusCreated = CL1_LOG_SHP.ORM_LOG_SHP_Shipment_Status.Query.Search(Connection, Transaction, new CL1_LOG_SHP.ORM_LOG_SHP_Shipment_Status.Query() { GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EShipmentStatus.Created), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); var shipmentStatusHistory = new CL1_LOG_SHP.ORM_LOG_SHP_Shipment_StatusHistory(); shipmentStatusHistory.LOG_SHP_Shipment_Header_RefID = shipmentHeader.LOG_SHP_Shipment_HeaderID; shipmentStatusHistory.LOG_SHP_Shipment_Status_RefID = statusCreated.LOG_SHP_Shipment_StatusID; shipmentStatusHistory.PerformedBy_BusinessParticipant_RefID = account.BusinessParticipant_RefID; shipmentStatusHistory.Tenant_RefID = (account == null) ? Guid.Empty : account.Tenant_RefID; shipmentStatusHistory.Save(Connection, Transaction); #endregion returnValue.Result = shipmentHeader.LOG_SHP_Shipment_HeaderID; return(returnValue); #endregion UserCode }
protected static FR_L5SO_SSHwP_1030 Execute(DbConnection Connection, DbTransaction Transaction, P_L5SO_SSHwP_1030 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5SO_SSHwP_1030(); returnValue.Result = new L5SO_SSHwP_1030(); var oldShipmentHeader = new CL1_LOG_SHP.ORM_LOG_SHP_Shipment_Header(); oldShipmentHeader.Load(Connection, Transaction, Parameter.HeaderID); var oldPositions = CL1_LOG_SHP.ORM_LOG_SHP_Shipment_Position.Query.Search(Connection, Transaction, new CL1_LOG_SHP.ORM_LOG_SHP_Shipment_Position.Query { LOG_SHP_Shipment_Header_RefID = Parameter.HeaderID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); bool isThereAnyDifference = false; foreach (var item in Parameter.Positions) { var oldPosition = oldPositions.Single(x => x.LOG_SHP_Shipment_PositionID == item.PositionID); if (oldPosition.QuantityToShip > item.PickingQuantity) { isThereAnyDifference = true; break; } } if (!isThereAnyDifference) { throw new ShipmentHeaderException(ResultMessage.SplitShipment_ThereIsNoDifferenceBetweenNewAndOldOne); } #region Create New ShippmentHeader var incrNumberParam = new P_L2NR_GaIINfUA_1454() { GlobalStaticMatchingID = EnumUtils.GetEnumDescription(ENumberRangeUsageAreaType.ShipmentNumber) }; var shipmentOrderNumber = cls_Get_and_Increase_IncreasingNumber_for_UsageArea.Invoke(Connection, Transaction, incrNumberParam, securityTicket).Result.Current_IncreasingNumber; var newShipmentHeader = new CL1_LOG_SHP.ORM_LOG_SHP_Shipment_Header(); newShipmentHeader.LOG_SHP_Shipment_HeaderID = Guid.NewGuid(); newShipmentHeader.ShipmentHeader_Number = shipmentOrderNumber; newShipmentHeader.Tenant_RefID = securityTicket.TenantID; newShipmentHeader.Creation_Timestamp = DateTime.Now; newShipmentHeader.IsPartialShippingAllowed = oldShipmentHeader.IsPartialShippingAllowed; newShipmentHeader.Shippipng_AddressUCD_RefID = oldShipmentHeader.Shippipng_AddressUCD_RefID; newShipmentHeader.Source_Warehouse_RefID = oldShipmentHeader.Source_Warehouse_RefID; newShipmentHeader.ShipmentPriority = oldShipmentHeader.ShipmentPriority; newShipmentHeader.ShipmentType_RefID = oldShipmentHeader.ShipmentType_RefID; newShipmentHeader.RecipientBusinessParticipant_RefID = oldShipmentHeader.RecipientBusinessParticipant_RefID; newShipmentHeader.Save(Connection, Transaction); var assignmentQuery = new CL1_LOG_SHP.ORM_LOG_SHP_ShipmentHeader_2_CustomerOrderHeader.Query(); assignmentQuery.LOG_SHP_Shipment_Header_RefID = oldShipmentHeader.LOG_SHP_Shipment_HeaderID; assignmentQuery.IsDeleted = false; assignmentQuery.Tenant_RefID = securityTicket.TenantID; var oldAssignment = CL1_LOG_SHP.ORM_LOG_SHP_ShipmentHeader_2_CustomerOrderHeader.Query.Search(Connection, Transaction, assignmentQuery).Single(); var shipmentToCustomerOrderHeader = new CL1_LOG_SHP.ORM_LOG_SHP_ShipmentHeader_2_CustomerOrderHeader(); shipmentToCustomerOrderHeader.ORD_CUO_CustomerOrder_Header_RefID = oldAssignment.ORD_CUO_CustomerOrder_Header_RefID; shipmentToCustomerOrderHeader.LOG_SHP_Shipment_Header_RefID = newShipmentHeader.LOG_SHP_Shipment_HeaderID; shipmentToCustomerOrderHeader.Tenant_RefID = securityTicket.TenantID; shipmentToCustomerOrderHeader.Creation_Timestamp = DateTime.Now; shipmentToCustomerOrderHeader.Save(Connection, Transaction); #region Status var statusCreated = CL1_LOG_SHP.ORM_LOG_SHP_Shipment_Status.Query.Search(Connection, Transaction, new CL1_LOG_SHP.ORM_LOG_SHP_Shipment_Status.Query() { GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EShipmentStatus.Created), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single(); var account = new CL1_USR.ORM_USR_Account(); account.Load(Connection, Transaction, securityTicket.AccountID); var shipmentStatusHistory = new CL1_LOG_SHP.ORM_LOG_SHP_Shipment_StatusHistory(); shipmentStatusHistory.LOG_SHP_Shipment_Header_RefID = newShipmentHeader.LOG_SHP_Shipment_HeaderID; shipmentStatusHistory.LOG_SHP_Shipment_Status_RefID = statusCreated.LOG_SHP_Shipment_StatusID; shipmentStatusHistory.PerformedBy_BusinessParticipant_RefID = account.BusinessParticipant_RefID; shipmentStatusHistory.Tenant_RefID = account.Tenant_RefID; shipmentStatusHistory.Save(Connection, Transaction); #endregion #endregion var param = new P_L5SO_GSPwPaSfSH_1141() { ShippmentHeaderID = Parameter.HeaderID, LanguageID = Parameter.LanguageID }; var splittingPositions = cls_Get_ShipmentPositions_with_Prices_and_Stock_for_ShipmentHeaderID.Invoke(Connection, Transaction, param, securityTicket).Result; decimal totalAmountForOldHeader = 0; decimal totalAmountForNewHeader = 0; foreach (var item in Parameter.Positions) { var oldPosition = oldPositions.Single(x => x.LOG_SHP_Shipment_PositionID == item.PositionID); var newQuantity = oldPosition.QuantityToShip - item.PickingQuantity; var positionToSplit = splittingPositions.Single(x => x.ShipmentPositionID == item.PositionID); var availableQuantity = positionToSplit.QuantityAvailable; decimal unitPrice = oldPosition.ShipmentPosition_PricePerUnitValueWithoutTax; if (item.PickingQuantity > availableQuantity + positionToSplit.ReservedQuantity) { throw new ShipmentHeaderException(ResultMessage.SplitShipment_FreeQuantityNotAvailable); } if (newQuantity > 0) { var newPosition = new CL1_LOG_SHP.ORM_LOG_SHP_Shipment_Position { LOG_SHP_Shipment_PositionID = Guid.NewGuid(), LOG_SHP_Shipment_Header_RefID = newShipmentHeader.LOG_SHP_Shipment_HeaderID, Tenant_RefID = securityTicket.TenantID, CMN_PRO_Product_RefID = oldPosition.CMN_PRO_Product_RefID, QuantityToShip = newQuantity, ShipmentPosition_PricePerUnitValueWithoutTax = unitPrice, ShipmentPosition_ValueWithoutTax = unitPrice * (decimal)newQuantity }; newPosition.Save(Connection, Transaction); totalAmountForNewHeader += newPosition.ShipmentPosition_ValueWithoutTax; var oldAssignmentCustomerOrderToShipmentPosition = CL1_ORD_CUO.ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition.Query.Search(Connection, Transaction, new CL1_ORD_CUO.ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition.Query { LOG_SHP_Shipment_Position_RefID = oldPosition.LOG_SHP_Shipment_PositionID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Single(); var customerOrder2ShipmentPosition = new CL1_ORD_CUO.ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition { AssignmentID = Guid.NewGuid(), Creation_Timestamp = DateTime.Now, Tenant_RefID = securityTicket.TenantID, IsDeleted = false, LOG_SHP_Shipment_Position_RefID = newPosition.LOG_SHP_Shipment_PositionID, ORD_CUO_CustomerOrder_Position_RefID = oldAssignmentCustomerOrderToShipmentPosition.ORD_CUO_CustomerOrder_Position_RefID, CMN_BPT_CTM_OrganizationalUnit_RefID = oldAssignmentCustomerOrderToShipmentPosition.CMN_BPT_CTM_OrganizationalUnit_RefID }; customerOrder2ShipmentPosition.Save(Connection, Transaction); } oldPosition.QuantityToShip = item.PickingQuantity; oldPosition.ShipmentPosition_ValueWithoutTax = unitPrice * (decimal)item.PickingQuantity; oldPosition.IsDeleted = (oldPosition.QuantityToShip == 0); oldPosition.Save(Connection, Transaction); totalAmountForOldHeader += oldPosition.ShipmentPosition_ValueWithoutTax; } oldShipmentHeader.ShipmentHeader_ValueWithoutTax = totalAmountForOldHeader; oldShipmentHeader.Save(Connection, Transaction); newShipmentHeader.ShipmentHeader_ValueWithoutTax = totalAmountForNewHeader; newShipmentHeader.Save(Connection, Transaction); // set return value to ok and new header's id returnValue.Result.NewHeaderID = newShipmentHeader.LOG_SHP_Shipment_HeaderID; returnValue.Result.Message = CL5_APOLogistic_ShippingOrder.Utils.ResultMessage.SplitShipment_OK; return(returnValue); #endregion UserCode }