protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L5BL_SBPVBT_1153 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Bool(); //Put your code here foreach (var position in Parameter.BillPositions) { var billPosition = new CL1_BIL.ORM_BIL_BillPosition(); billPosition.Load(Connection, Transaction, position.BillPositionID); if (billPosition != null) { billPosition.PositionPricePerUnitValue_BeforeTax = position.ChangedPrice; billPosition.PositionValue_BeforeTax = position.ChangedPrice * billPosition.Quantity; var tax = CL1_ACC_TAX.ORM_ACC_TAX_Tax.Query.Search(Connection, Transaction, new CL1_ACC_TAX.ORM_ACC_TAX_Tax.Query { ACC_TAX_TaxeID = billPosition.ApplicableSalesTax_RefID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (tax != null) { billPosition.PositionPricePerUnitValue_IncludingTax = MoneyUtils.CalculateGrossPriceForTaxInPercent(position.ChangedPrice, (decimal)tax.TaxRate); billPosition.PositionValue_IncludingTax = billPosition.PositionPricePerUnitValue_IncludingTax * billPosition.Quantity; } billPosition.Save(Connection, Transaction); var billHeader = new CL1_BIL.ORM_BIL_BillHeader(); billHeader.Load(Connection, Transaction, billPosition.BIL_BilHeader_RefID); var allPositionsForHeader = CL5_APOBilling_Bill.Complex.Retrieval.cls_Get_BillPositions_with_Articles_for_BillHeader.Invoke(Connection, Transaction, new P_L5BL_GBPwAfBH_1848 { BillHeaderID = billHeader.BIL_BillHeaderID }, securityTicket).Result; var billSumIncludeTax = allPositionsForHeader.Sum(x => x.BillPosition.PositionValue_IncludingTax); var billSumBeforeTax = allPositionsForHeader.Sum(x => x.BillPosition.PositionValue_BeforeTax); billHeader.TotalValue_BeforeTax = billSumBeforeTax; billHeader.TotalValue_IncludingTax = billSumIncludeTax; billHeader.Save(Connection, Transaction); } } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5BL_CBP_1330 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var billHeader = new CL1_BIL.ORM_BIL_BillHeader(); billHeader.Load(Connection, Transaction, Parameter.BillHeaderID); foreach (var item in Parameter.BillPositionIDs) { // Retrieve Bill Position var billPosition = new CL1_BIL.ORM_BIL_BillPosition(); billPosition.Load(Connection, Transaction, item); // Delete relationship between Bill Positions and Shipment Positions in Assignment table. CL1_BIL.ORM_BIL_BillPosition_2_ShipmentPosition.Query.SoftDelete(Connection, Transaction, new CL1_BIL.ORM_BIL_BillPosition_2_ShipmentPosition.Query { BIL_BillPosition_RefID = billPosition.BIL_BillPositionID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }); CL1_BIL.ORM_BIL_BillPosition_2_CustomerOrderReturnPosition.Query.SoftDelete(Connection, Transaction, new CL1_BIL.ORM_BIL_BillPosition_2_CustomerOrderReturnPosition.Query { BIL_BillPosition_RefID = billPosition.BIL_BillPositionID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }); // Delete bill position billPosition.IsDeleted = true; billPosition.Save(Connection, Transaction); // Substract values for bill header billHeader.TotalValue_BeforeTax -= billPosition.PositionValue_BeforeTax; billHeader.TotalValue_IncludingTax -= billPosition.PositionValue_IncludingTax; } billHeader.Save(Connection, Transaction); returnValue.Status = FR_Status.Success; return(returnValue); #endregion UserCode }