/// <summary> /// Function for Tax View By ProductId /// </summary> /// <param name="strProductCode"></param> /// <returns></returns> public TaxInfo TaxViewByProductId(string strProductCode) { TaxInfo taxInfo = new TaxInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("TaxViewByProductId", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.VarChar); sprmparam.Value = strProductCode; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { taxInfo.TaxId = Convert.ToDecimal(sdrreader["taxId"].ToString()); taxInfo.TaxName = sdrreader["taxName"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(taxInfo); }
public void Will_Throw_When_CalculationDirection_Unknown() { var taxInfo = new TaxInfo("23%", 0.23m); Should.Throw <InvalidOperationException>( () => taxInfo.GetNetValue(CalculationDirection.Unknown, 123)); }
public void Will_Return_TaxValue(decimal taxMultiplier, decimal value, CalculationDirection direction, decimal expected) { var taxInfo = new TaxInfo("test", taxMultiplier); var position = new InvoicePosition(1, "", 1, taxInfo, value, string.Empty); position.GetTaxValue(direction).ShouldBe(expected); }
public ListTaxResponse LoadTaxInfo(string filePath) { ListTaxResponse response = new ListTaxResponse(); response.Success = true; response.TaxList = new List <TaxInfo>(); try { using (StreamReader reader = new StreamReader(filePath)) { reader.ReadLine(); string line; while ((line = reader.ReadLine()) != null) { TaxInfo stateTax = new TaxInfo(); string[] columns = line.Split(','); stateTax.StateAbbreviation = columns[0]; stateTax.StateName = columns[1]; stateTax.TaxRate = decimal.Parse(columns[2]); response.TaxList.Add(stateTax); } } } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return(response); }
public async Task <bool> StoreNewTaxInfoAsync(int CustomerId, TaxInfo TaxInfo) { TaxInfo.CustomerId = CustomerId; _context.TaxInfos.Add(TaxInfo); return((await _context.SaveChangesAsync()) > 0); }
private TaxInfo GetTaxValues(DataRow dr) { TaxInfo Tax = new TaxInfo(); Tax.TaxId = Convert.ToInt32(dr["TaxId"]); if (!dr.IsNull("TaxName")) { Tax.TaxName = Convert.ToString(dr["TaxName"]); } if (!dr.IsNull("TaxCode")) { Tax.TaxCode = Convert.ToString(dr["TaxCode"]); } if (!dr.IsNull("TaxRate")) { Tax.TaxRate = Convert.ToDecimal(dr["TaxRate"]); } if (!dr.IsNull("IsActive")) { Tax.IsActive = Convert.ToBoolean(dr["IsActive"]); } return(Tax); }
public async Task PutTaxInfo(string id, [FromBody] OrganizationTaxInfoUpdateRequestModel model) { var orgIdGuid = new Guid(id); if (!await _currentContext.OrganizationOwner(orgIdGuid)) { throw new NotFoundException(); } var organization = await _organizationRepository.GetByIdAsync(orgIdGuid); if (organization == null) { throw new NotFoundException(); } var taxInfo = new TaxInfo { TaxIdNumber = model.TaxId, BillingAddressLine1 = model.Line1, BillingAddressLine2 = model.Line2, BillingAddressCity = model.City, BillingAddressState = model.State, BillingAddressPostalCode = model.PostalCode, BillingAddressCountry = model.Country, }; await _paymentService.SaveTaxInfoAsync(organization, taxInfo); }
public void Will_Return_False_When_TaxInfo_Compared_To_Null() { var taxInfo = new TaxInfo("23%", 0.23m); taxInfo.Equals(null).ShouldBeFalse(); (taxInfo == null).ShouldBeFalse(); }
public void Will_Return_True_When_Compared_The_Same_TaxInfo() { var taxInfo1 = new TaxInfo("23%", 0.23m); var taxInfo2 = new TaxInfo("23%", 0.23m); taxInfo1.Equals(taxInfo2).ShouldBeTrue(); (taxInfo1 == taxInfo2).ShouldBeTrue(); }
public StockTaxesController(TobinTaxerContext context, ILogger <StockTaxesController> logger, IOptionsMonitor <Services> servicesOptions, IOptionsMonitor <TaxInfo> taxOptions, IRabbitMqClient rabbitMqClient) { _context = context; _logger = logger; _rabbitMqClient = rabbitMqClient; _services = servicesOptions.CurrentValue; _taxInfo = taxOptions.CurrentValue; }
public void Will_Return_False_When_Compared_The_Same_TaxInfo() { var taxInfo1 = new TaxInfo("0%", 0m); var taxInfo2 = new TaxInfo("zw", 0m); taxInfo1.Equals(taxInfo2).ShouldBeFalse(); (taxInfo1 == taxInfo2).ShouldBeFalse(); }
public async Task <bool> DeleteTaxInfo(TaxInfo TaxInfo) { using (IDbConnection con = this.GetConnection()) { await con.ExecuteAsync(sql : "spCMTaxInfoDelete", new { TaxInfo.Id }, commandType : CommandType.StoredProcedure); } return(true); }
/// <summary> /// Function to Update values in Tax Table /// </summary> /// <param name="taxinfo"></param> public void TaxEdit(TaxInfo taxinfo) { try { } catch (Exception ex) { MessageBox.Show("TBLL1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void Will_Throw_For_Ordinal_Numbers_Not_In_Sequence() { var invoice = GenerateEmptyTestInvoice(); var taxInfo = new TaxInfo("test", 0.23m); var position1 = new InvoicePosition(1, "p1", 2, taxInfo, 100, "pc"); var position2 = new InvoicePosition(3, "p2", 1, taxInfo, 400, "pc"); Assert.Throws <InvalidOperationException>(() => invoice.SetPositions(new() { position1, position2 })); }
public void HasTaxId_ReturnsExpected(string taxIdNumber, string billingAddressCountry, bool expected) { var taxInfo = new TaxInfo { TaxIdNumber = taxIdNumber, BillingAddressCountry = billingAddressCountry, }; Assert.Equal(expected, taxInfo.HasTaxId); }
public OrderResponse Validate(DateTime date, string name, TaxInfo tax, Product product, decimal area) { OrderResponse response = new OrderResponse(); if (date < DateTime.Today) { response.Success = false; response.Message = "Orders must be placed for future dates."; return(response); } if (name.Length < 1) { response.Success = false; response.Message = "Name field cannot be left blank."; return(response); } if (tax == null) { response.Success = false; response.Message = "The state you entered in is invalid or we do not currently deliver to that location."; return(response); } if (product == null) { response.Success = false; response.Message = "The product type you entered is invalid."; return(response); } if (area < 100) { response.Success = false; response.Message = "Area must be greater than 100 square ft."; return(response); } response.Success = true; response.Order.CustomerName = name; response.Order.State = tax.StateAbbrevation; response.Order.TaxRate = tax.TaxRate; response.Order.Area = area; response.Order.ProductType = product.ProductType; response.Order.CostPerSquareFoot = product.CostPerSquareFoot; response.Order.LaborCostPerSqareFoot = product.LaborCostPerSquareFoot; response.Order.MaterialCost = area * product.CostPerSquareFoot; response.Order.LaborCost = area * product.LaborCostPerSquareFoot; response.Order.Tax = (response.Order.MaterialCost + product.LaborCostPerSquareFoot) * (tax.TaxRate / 100); response.Order.Total = response.Order.MaterialCost + response.Order.LaborCost + response.Order.Tax; return(response); }
public CommerceLibOrderInfo(DataRow orderRow) { Shipping = new ShippingInfo(); Tax = new TaxInfo(); OrderID = Int32.Parse(orderRow["OrderID"].ToString()); DateCreated = orderRow["DateCreated"].ToString(); DateShipped = orderRow["DateShipped"].ToString(); Comments = orderRow["Comments"].ToString(); Status = Int32.Parse(orderRow["Status"].ToString()); AuthCode = orderRow["AuthCode"].ToString(); Reference = orderRow["Reference"].ToString(); Customer = Membership.GetUser( new Guid(orderRow["CustomerID"].ToString())); CustomerProfile = (HttpContext.Current.Profile as ProfileCommon) .GetProfile(Customer.UserName); CreditCard = new SecureCard(CustomerProfile.CreditCard); OrderDetails = CommerceLibAccess.GetOrderDetails( orderRow["OrderID"].ToString()); // Get Shipping Data if (orderRow["ShippingID"] != DBNull.Value && orderRow["ShippingType"] != DBNull.Value && orderRow["ShippingCost"] != DBNull.Value) { Shipping.ShippingID = Int32.Parse(orderRow["ShippingID"].ToString()); Shipping.ShippingType = orderRow["ShippingType"].ToString(); Shipping.ShippingCost = double.Parse(orderRow["ShippingCost"].ToString()); } else { Shipping.ShippingID = -1; } // Get Tax Data if (orderRow["TaxID"] != DBNull.Value && orderRow["TaxType"] != DBNull.Value && orderRow["TaxPercentage"] != DBNull.Value) { Tax.TaxID = Int32.Parse(orderRow["TaxID"].ToString()); Tax.TaxType = orderRow["TaxType"].ToString(); Tax.TaxPercentage = double.Parse(orderRow["TaxPercentage"].ToString()); } else { Tax.TaxID = -1; } // set info properties Refresh(); }
public TaxViewModel() { Tax = new TaxInfo(); Filter = new TaxFilter(); Taxes = new List <TaxInfo>(); Pager = new PaginationInfo(); FriendlyMessage = new List <FriendlyMessage>(); }
public void ShouldPassMultipleInputValidations() { string opName = "PlaceOrder"; ValidationParameterInspector inspector = GetInspector(opName, typeof(ITestService)); string customerId = "AGoodCustomer"; TaxInfo taxInfo = new TaxInfo("123434", "WA"); ItemInfo itemInfo = new ItemInfo("Item002", "A Fictitious book", 2); CustomerDiscountInfo discountInfo = new CustomerDiscountInfo(customerId, .15); inspector.BeforeCall(opName, new object[] { customerId, taxInfo, itemInfo, discountInfo }); }
public void roundTest() { Assert.Equal(3.10, TaxInfo.quarterPointRound(3.075)); Assert.Equal(3.10, TaxInfo.quarterPointRound(3.076)); Assert.Equal(3.05, TaxInfo.quarterPointRound(3.074)); Assert.Equal(3.05, TaxInfo.quarterPointRound(3.050)); Assert.Equal(3.05, TaxInfo.quarterPointRound(3.026)); Assert.Equal(3.05, TaxInfo.quarterPointRound(3.025)); Assert.Equal(3.05, TaxInfo.quarterPointRound(3.024)); Assert.Equal(3.05, TaxInfo.quarterPointRound(3.001)); Assert.Equal(3.00, TaxInfo.quarterPointRound(2.975)); Assert.Equal(11.85, TaxInfo.quarterPointRound(11.8125)); }
public static TaxInfo GetState(String oldState, List <TaxInfo> states) { string prompt = $"Enter state [{oldState}]: "; TaxInfo result = DIContainer.Kernel.Get <TaxInfo>(); Output.SendToConsole($"Select state (1 - {states.Count} from the following list\n"); int cnt = 0; foreach (var st in states) { cnt++; Output.SendToConsole($"{cnt,2}) { st.StateAbbreviation} - { st.StateName}"); } ; while (true) { Output.SendToConsole(); Console.Write(prompt); var input = Console.ReadLine().Trim(); if (input.Length > 0) { if (int.TryParse(input, out int selection)) { if (selection > 0 && selection <= states.Count()) { result = states.ElementAt(selection - 1); break; } else { Output.SendToConsole("Invalid selection. Press any key to try again..."); Console.ReadKey(); } } else { Output.SendToConsole("Invalid input. Press any key to try again..."); Console.ReadKey(); } } else { break; } } ; return(result); }
public static TaxInfo GetTaxInfo() { var dt = DataAccess.GetTableFromQuery("Select * from MastersTax where Id = 1", null, CommandType.Text); var objTaxInfo = new TaxInfo(); if (dt.Rows.Count > 0) { objTaxInfo.ID = dt.Rows[0]["ID"].ToString(); objTaxInfo.SGST = dt.Rows[0]["SGST"].ToString(); objTaxInfo.CGST = dt.Rows[0]["CGST"].ToString(); objTaxInfo.IGST = dt.Rows[0]["IGST"].ToString(); } return(objTaxInfo); }
public void Will_Set_Invoice_Positions() { var invoice = GenerateEmptyTestInvoice(); var taxInfo = new TaxInfo("test", 0.23m); var position1 = new InvoicePosition(1, "p1", 2, taxInfo, 100, "pc"); var position3 = new InvoicePosition(3, "p2", 1, taxInfo, 400, "pc"); var position2 = new InvoicePosition(2, "p2", 1, taxInfo, 100, "pc"); invoice.SetPositions(new() { position1, position2, position3 }); invoice.InvoicePositions.Count.ShouldBe(3); invoice.TotalNetValue.ShouldBe(700); }
// This will be the controller static void Main(string[] args) { IReadOnlyTaxManager <TaxInfo> readOnlyManagerDefault = GetReadOnlyTaxManager(1); IReadOnlyTaxManager <TaxInfo> readOnlyManagerChina = GetReadOnlyTaxManager(2); IReadOnlyTaxManager <TaxInfo> readOnlyManagerTaiwan = GetReadOnlyTaxManager(3); TaxInfo defaultTaxInfo = GetTaxInfo(readOnlyManagerDefault); TaxInfo taiwanTaxInfo = GetTaxInfo(readOnlyManagerTaiwan); TaxInfo chinaTaxInfo = GetTaxInfo(readOnlyManagerChina); SaveTaxInfo(1, defaultTaxInfo); SaveTaxInfo(2, chinaTaxInfo); SaveTaxInfo(3, taiwanTaxInfo); }
public TaxInfo GetTaxInfoByState(string state) { TaxInfo t = null; List <TaxInfo> taxes = GetAllTaxInfos(); foreach (var tax in taxes) { if (state.ToUpper() == tax.StateAbbrevation || state.ToUpper() == tax.StateName.ToUpper()) { t = tax; } } return(t); }
public void GetTaxIdType_Success(string billingAddressCountry, string taxIdNumber, string billingAddressState, string expectedTaxIdType) { var taxInfo = new TaxInfo { BillingAddressCountry = billingAddressCountry, TaxIdNumber = taxIdNumber, BillingAddressState = billingAddressState, }; Assert.Equal(expectedTaxIdType, taxInfo.TaxIdType); }
/// <summary> /// Function for insert values and return id /// </summary> /// <param name="taxinfo"></param> /// <returns></returns> public decimal TaxAddWithIdentity(TaxInfo taxinfo) { decimal decTaxId = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("TaxAddWithIdentity", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@taxName", SqlDbType.VarChar); sprmparam.Value = taxinfo.TaxName; sprmparam = sccmd.Parameters.Add("@applicableOn", SqlDbType.VarChar); sprmparam.Value = taxinfo.ApplicableOn; sprmparam = sccmd.Parameters.Add("@rate", SqlDbType.Decimal); sprmparam.Value = taxinfo.Rate; sprmparam = sccmd.Parameters.Add("@calculatingMode", SqlDbType.VarChar); sprmparam.Value = taxinfo.CalculatingMode; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = taxinfo.Narration; sprmparam = sccmd.Parameters.Add("@isActive", SqlDbType.Bit); sprmparam.Value = taxinfo.IsActive; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = taxinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = taxinfo.Extra2; object objTaxId = sccmd.ExecuteScalar(); if (objTaxId != null) { decTaxId = decimal.Parse(objTaxId.ToString()); } else { decTaxId = 0; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(decTaxId); }
/// <summary> /// Function for Tax View By ProductId /// </summary> /// <param name="strProductCode"></param> /// <returns></returns> public TaxInfo TaxViewByProductId(string strProductCode) { TaxInfo infoTax = new TaxInfo(); try { infoTax = spTax.TaxViewByProductId(strProductCode); } catch (Exception ex) { MessageBox.Show("TBLL11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(infoTax); }
/// <summary> /// Function for insert values and return id /// </summary> /// <param name="taxinfo"></param> /// <returns></returns> public decimal TaxAddWithIdentity(TaxInfo infoTax) { decimal decTaxId = 0; try { decTaxId = spTax.TaxAddWithIdentity(infoTax); } catch (Exception ex) { MessageBox.Show("TBLL1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(decTaxId); }
/// <summary> /// Function to get particular values from Tax Table based on the parameter /// </summary> /// <param name="taxId"></param> /// <returns></returns> public TaxInfo TaxView(decimal decTaxId) { TaxInfo infoTax = new TaxInfo(); try { infoTax = spTax.TaxView(decTaxId); } catch (Exception ex) { MessageBox.Show("TBLL1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(infoTax); }
/// <summary> /// Function for Amount Calculations for Gross value, Net amount, Tax amount and Total amount /// </summary> /// <param name="columnName"></param> /// <param name="inIndexOfRow"></param> public void AmountCalculation(string columnName, int inIndexOfRow) { try { string strTaxRate = string.Empty; decimal decTaxAmt = 0; decimal decTotalAmnt = 0; decimal decdgvtxtgrossValue = 0, decDiscountCalc = 0, decNetAmount = 0; decimal decTaxPercent = 0; decimal decTaxId = 0; DataGridViewRow dgrow = dgvPurchaseReturn.Rows[inIndexOfRow]; ProductInfo infoProduct = new ProductInfo(); RackBll BllRack = new RackBll(); TaxInfo infotax = new TaxInfo(); TaxBll bllTax = new TaxBll(); if (dgrow.Cells["dgvtxtqty"].Value != null && dgrow.Cells["dgvtxtqty"].Value.ToString() != string.Empty) { decQty = Convert.ToDecimal(dgrow.Cells["dgvtxtqty"].Value.ToString()); } if (dgrow.Cells["dgvtxtrate"].Value != null && dgrow.Cells["dgvtxtrate"].Value.ToString() != string.Empty) { decRate = Convert.ToDecimal(dgrow.Cells["dgvtxtrate"].Value.ToString()); decdgvtxtgrossValue = decQty * decRate; dgrow.Cells["dgvtxtgrossValue"].Value = Math.Round(decdgvtxtgrossValue, PublicVariables._inNoOfDecimalPlaces); } if (dgrow.Cells["dgvtxtgrossValue"].Value != null && dgrow.Cells["dgvtxtgrossValue"].Value.ToString() != string.Empty) { dgrow.Cells["dgvtxtgrossValue"].Value = Math.Round(decdgvtxtgrossValue, PublicVariables._inNoOfDecimalPlaces); if (dgrow.Cells["dgvtxtdiscount"].Value != null && dgrow.Cells["dgvtxtdiscount"].Value.ToString() != string.Empty) { decDiscountCalc = Convert.ToDecimal(dgrow.Cells["dgvtxtdiscount"].Value.ToString()); if (decdgvtxtgrossValue >= decDiscountCalc) { decNetAmount = Math.Round((decdgvtxtgrossValue - decDiscountCalc), PublicVariables._inNoOfDecimalPlaces); dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces); } else { dgrow.Cells["dgvtxtdiscount"].Value = 0; } } else { dgrow.Cells["dgvtxtdiscount"].Value = 0; dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces); } } if (dgrow.Cells["dgvtxtNetAmount"].Value != null && dgrow.Cells["dgvtxtNetAmount"].Value.ToString() != string.Empty) { decNetAmount = Math.Round(decdgvtxtgrossValue - decDiscountCalc, PublicVariables._inNoOfDecimalPlaces); decNetAmount = Convert.ToDecimal(dgrow.Cells["dgvtxtNetAmount"].Value.ToString()); dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces); } if (dgvcmbTax.Visible) { if (dgrow.Cells["dgvtxtproductId"].Value != null && dgrow.Cells["dgvtxtproductId"].Value.ToString() != string.Empty) { if (dgrow.Cells["dgvcmbTax"].Value != null && dgrow.Cells["dgvcmbTax"].Value.ToString() != string.Empty && dgrow.Cells["dgvcmbTax"].Value.ToString() != "NA") { decTaxId = Convert.ToDecimal(dgrow.Cells["dgvcmbTax"].Value.ToString()); infotax = bllTax.TaxView(decTaxId); decTaxPercent = infotax.Rate; if (decTaxPercent != 0) { if (strTaxComboFill != string.Empty) { decTaxAmt = ((decNetAmount * decTaxPercent) / 100); } else { dgrow.Cells["dgvtxttaxAmount"].Value = "0"; } decTotalAmnt = Math.Round((decNetAmount + decTaxAmt), PublicVariables._inNoOfDecimalPlaces); dgrow.Cells["dgvtxttaxAmount"].Value = Math.Round(decTaxAmt, PublicVariables._inNoOfDecimalPlaces); decTaxAmt = Convert.ToDecimal(dgrow.Cells["dgvtxttaxAmount"].Value.ToString()); dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decTotalAmnt, PublicVariables._inNoOfDecimalPlaces); } else { dgrow.Cells["dgvtxttaxAmount"].Value = "0"; dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces); } } else { decTaxPercent = 0; dgrow.Cells["dgvtxttaxAmount"].Value = "0"; dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces); } } Calculate(); } } catch (Exception ex) { MessageBox.Show("PR:34 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// save function /// </summary> public void SaveFunction() { try { TaxInfo infoTax = new TaxInfo(); TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo(); TaxBll bllTax = new TaxBll(); infoTax.TaxName = txtTaxName.Text.Trim(); infoTax.Rate = Convert.ToDecimal(txtRate.Text.ToString()); infoTax.ApplicableOn = cmbApplicableFor.SelectedItem.ToString(); if (cmbCalculationMode.Enabled != true) { infoTax.CalculatingMode = string.Empty; } else { infoTax.CalculatingMode = cmbCalculationMode.SelectedItem.ToString(); } infoTax.Narration = txtNarration.Text.Trim(); if (cbxActive.Checked) { infoTax.IsActive = true; } else { infoTax.IsActive = false; } infoTax.Extra1 = string.Empty; infoTax.Extra2 = string.Empty; if (bllTax.TaxCheckExistence(0, txtTaxName.Text.Trim()) == false) { decTaxId = bllTax.TaxAddWithIdentity(infoTax); decIdForOtherForms = decTaxId; if (dgvTaxSelection.RowCount > 0) { bool isOk = false; foreach (DataGridViewRow dgvRow in dgvTaxSelection.Rows) { isOk = Convert.ToBoolean(dgvRow.Cells["dgvcbxSelect"].Value); if (isOk) { infoTaxDetails.TaxId = decTaxId; infoTaxDetails.SelectedtaxId = Convert.ToDecimal(dgvRow.Cells["dgvtxtTaxId"].Value.ToString());//dgvRow.Cells[0].Value.ToString(); infoTaxDetails.ExtraDate = DateTime.Now; infoTaxDetails.Extra1 = string.Empty; infoTaxDetails.Extra2 = string.Empty; bllTax.TaxDetailsAddWithoutId(infoTaxDetails); } } } CreateLedger(); Messages.SavedMessage(); Clear(); SearchClear(); } else { Messages.InformationMessage(" Tax or ledger already exist"); txtTaxName.Focus(); } if (frmProductCreationObj != null) { this.Close(); } } catch (Exception ex) { MessageBox.Show("TC4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// delete function /// </summary> public void Delete() { try { if (PublicVariables.isMessageDelete) { if (Messages.DeleteMessage()) { TaxInfo infoTax = new TaxInfo(); TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo(); TaxBll bllTax = new TaxBll(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); bool isExist = bllTax.TaxReferenceCheck(decTaxId); if (!isExist) { if ((bllTax.TaxReferenceDelete(decTaxId,decLedgerId)) == -1) { Messages.ReferenceExistsMessage(); } else { bllTax.TaxDetailsDeleteWithTaxId(decTaxId); bllAccountLedger.AccountLedgerDelete(decLedgerId); Messages.DeletedMessage(); TaxSearchGridFill(); TaxSelectionGridFill(); Clear(); SearchClear(); } } else { Messages.ReferenceExistsMessage(); } } } else { TaxInfo infoTax = new TaxInfo(); TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo(); TaxBll bllTax = new TaxBll(); bool isExist = bllTax.TaxReferenceCheck(decTaxId); if (!isExist) { if ((bllTax.TaxReferenceDelete(decTaxId,decLedgerId)) == -1) { Messages.ReferenceExistsMessage(); } else { bllTax.TaxDetailsDeleteWithTaxId(decTaxId); Messages.DeletedMessage(); TaxSearchGridFill(); TaxSelectionGridFill(); Clear(); SearchClear(); } } else { Messages.ReferenceExistsMessage(); } } } catch (Exception ex) { MessageBox.Show("TC11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Grid fill function Againest SalseOrderDetails /// </summary> public void gridFillAgainestSalseOrderDetails() { BrandBll BllBrand = new BrandBll(); //SalesOrderBll bllSalesOrder = new SalesOrderBll(); SalesOrderBll bllSalesOrder = new SalesOrderBll(); ProductInfo infoproduct = new ProductInfo(); //SalesMasterSP spSalesMaster = new SalesMasterSP(); SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll(); BrandInfo InfoBrand = new BrandInfo(); TaxInfo infoTax = new TaxInfo(); TaxBll bllTax = new TaxBll(); try { if (cmbSalesModeOrderNo.SelectedIndex > 0) { inMaxCount = 0; isValueChange = false; for (int i = 0; i < dgvSalesInvoice.RowCount - 1; i++) { if (dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value != null && dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString() != string.Empty) { lstArrOfRemove.Add(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString()); } } dgvSalesInvoice.Rows.Clear(); isValueChange = true; List<DataTable> ListObj= bllSalesOrder.SalesInvoiceGridfillAgainestSalesOrder(Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString())); cmbPricingLevel.SelectedValue = Convert.ToDecimal(ListObj[0].Rows[0]["pricingLevelId"].ToString()); cmbCurrency.SelectedValue = Convert.ToDecimal(ListObj[0].Rows[0]["exchangeRateId"].ToString()); if (ListObj[0].Rows[0]["employeeId"].ToString() != string.Empty) { strSalesManId = ListObj[0].Rows[0]["employeeId"].ToString(); cmbSalesMan.SelectedValue = strSalesManId; if (cmbSalesMan.SelectedValue == null) { salesManComboFill(); cmbSalesMan.SelectedValue = ListObj[0].Rows[0]["employeeId"].ToString(); } } cmbPricingLevel.Enabled = false; btnNewPricingLevel.Enabled = false; cmbCurrency.Enabled = false; ListObj = bllSalesOrder.SalesInvoiceGridfillAgainestSalesOrderUsingSalesDetails(Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()), Convert.ToDecimal(decSalesInvoiceIdToEdit), DecSalesInvoiceVoucherTypeId); int inRowIndex = 0; foreach (DataRow drowDetails in ListObj[0].Rows) { dgvSalesInvoice.Rows.Add(); isValueChange = false; IsSetGridValueChange = false; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSISalesOrderDetailsId"].Value = drowDetails["salesOrderDetailsId"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductCode"].Value = drowDetails["productCode"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceBarcode"].Value = drowDetails["barcode"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvcmbSalesInvoiceBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString()); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherNo"].Value = drowDetails["voucherNo"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value = drowDetails["invoiceNo"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value = drowDetails["voucherTypeId"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value = "0"; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInRowIndex"].Value = drowDetails["salesOrderDetailsId"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value = drowDetails.ItemArray[2].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value = drowDetails["unitConversionId"].ToString(); infoproduct = BllSalesInvoice.ProductViewByProductIdforSalesInvoice(Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value).ToString()); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductName"].Value = infoproduct.ProductName; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceMrp"].Value = infoproduct.Mrp; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicePurchaseRate"].Value = infoproduct.PurchaseRate; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceSalesRate"].Value = infoproduct.SalesRate; InfoBrand = BllBrand.BrandView(infoproduct.BrandId); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceBrand"].Value = InfoBrand.BrandName; infoTax = bllTax.TaxViewByProductId(Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value).ToString()); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvcmbSalesInvoiceTaxName"].Value = infoTax.TaxId; isValueChange = false; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicembUnitName"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString()); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicembUnitName"].ReadOnly = true; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceQty"].Value = drowDetails["Qty"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceRate"].Value = drowDetails["rate"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceAmount"].Value = drowDetails["amount"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceConversionRate"].Value = drowDetails["conversionRate"].ToString(); isFromAgainest = true; gridColumnMakeEnables(); int intIndex = 0; intIndex = Convert.ToInt32(drowDetails["salesOrderDetailsId"].ToString()); if (inMaxCount < intIndex) inMaxCount = intIndex; inRowIndex++; isValueChange = true; isFromAgainest = false; GrossValueCalculation(dgvSalesInvoice.Rows.Count - 2); discountCalculation(dgvSalesInvoice.Rows.Count - 2); taxAndGridTotalAmountCalculation(dgvSalesInvoice.Rows.Count - 2); } IsSetGridValueChange = true; for (int i = inRowIndex; i < dgvSalesInvoice.Rows.Count; ++i) dgvSalesInvoice["dgvtxtSalesInvoiceInRowIndex", i].Value = GetNextinRowIndex().ToString(); SerialNoforSalesInvoice(); strVoucherNoTostockPost = dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherNo"].Value.ToString(); strInvoiceNoTostockPost = dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value.ToString(); decVouchertypeIdTostockPost = Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value); } else { SiGridTotalAmountCalculation(); ClearGridAgainest(); } SiGridTotalAmountCalculation(); } catch (Exception ex) { MessageBox.Show("SI: 51" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// fill the curresponding details for update /// </summary> public void TaxSelectionFillForUpdate() { try { int inRowCount = dgvTaxSelection.RowCount; for (int i = 0; i < inRowCount; i++) { dgvTaxSelection.Rows[i].Cells["dgvcbxSelect"].Value = false; } decTaxId = Convert.ToDecimal(dgvTaxSearch.CurrentRow.Cells["dgvtxtTaxIdSearch"].Value.ToString()); TaxInfo infoTax = new TaxInfo(); TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo(); TaxBll bllTax = new TaxBll(); infoTax = bllTax.TaxView(decTaxId); txtTaxName.Text = infoTax.TaxName; txtRate.Text = infoTax.Rate.ToString(); cmbApplicableFor.Text = infoTax.ApplicableOn; cmbCalculationMode.Text = infoTax.CalculatingMode; txtNarration.Text = infoTax.Narration; if (infoTax.IsActive.ToString() == "True") { cbxActive.Checked = true; } else { cbxActive.Checked = false; } strTaxName = infoTax.TaxName; decTaxIdForEdit = infoTax.TaxId; btnSave.Text = "Update"; btnDelete.Enabled = true; List<DataTable> ListObj = new List<DataTable>(); ListObj = bllTax.TaxIdForTaxSelectionUpdate(decTaxId); foreach (DataRow dr in ListObj[0].Rows) { string strTaxId = dr["selectedtaxId"].ToString(); for (int i = 0; i < inRowCount; i++) { if (dgvTaxSelection.Rows[i].Cells["dgvtxtTaxId"].Value.ToString() == strTaxId) { dgvTaxSelection.Rows[i].Cells["dgvcbxSelect"].Value = true; } } } AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); decLedgerId = bllAccountLedger.AccountLedgerIdGetByName(txtTaxName.Text); } catch (Exception ex) { MessageBox.Show("TC10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to calculate total amount /// </summary> /// <param name="inRowIndex"></param> public void Calculate(int inRowIndex) { decimal decDiscount = 0; decimal decDiscountPercent = 0; decimal decGrossValue = 0; decimal decNetValue = 0; decimal decTaxAmount = 0; decimal decTaxPercent = 0; decimal decTaxId = 0; decimal decAmount = 0; decimal decTotalAmount = 0; decimal decProductId = 0; decimal decDefaultTotalAmount = 0; decimal decProductRate = 0; decimal decQuantity = 0; ProductInfo infoProduct = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); TaxInfo infotax = new TaxInfo(); TaxBll bllTax = new TaxBll(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); try { if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductId"].Value != null) { if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductId"].Value.ToString() != string.Empty) { if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value != null) { if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value.ToString() != string.Empty && dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value.ToString() != ".") { decProductRate = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value.ToString()); } } if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtQuantity"].Value != null) { if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtQuantity"].Value.ToString() != string.Empty && dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtQuantity"].Value.ToString() != ".") { decQuantity = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtQuantity"].Value.ToString()); } } decGrossValue = decProductRate * decQuantity; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtGrossValue"].Value = Math.Round(decGrossValue, PublicVariables._inNoOfDecimalPlaces); if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value != null) { if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value.ToString() != string.Empty) { decDiscountPercent = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value.ToString()); } else { dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value = 0; } } else { dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value = 0; } if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value != null) { if (dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value.ToString() != string.Empty) { decDiscount = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value.ToString()); } else { dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = 0; } } else { dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = 0; } /*------------------------------Calculate-----------------------------------*/ /*------------------------------Discount Calculation-----------------------------------*/ if (decGrossValue >= decDiscount) { dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = Math.Round(decDiscount, PublicVariables._inNoOfDecimalPlaces); } else { dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value = 0; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = 0; decDiscount = 0; } decNetValue = decGrossValue - decDiscount; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtNetValue"].Value = Math.Round(decNetValue, PublicVariables._inNoOfDecimalPlaces); /*------------------------------Tax Calculation-----------------------------------*/ if (dgvcmbTax.Visible) { if (dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value != null) { if (dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value.ToString() != string.Empty && dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value.ToString() != "0") { decTaxId = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value.ToString()); infotax = bllTax.TaxView(decTaxId); decTaxPercent = infotax.Rate; } else { decTaxPercent = 0; } } else { decTaxPercent = 0; } decProductId = Convert.ToDecimal(dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductId"].Value.ToString()); infoProduct = BllProductCreation.ProductView(decProductId); if (infoProduct.TaxapplicableOn == "MRP") { decTaxAmount = infoProduct.Mrp * decTaxPercent / 100; } else { decTaxAmount = decNetValue * decTaxPercent / 100; } dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtTaxAmount"].Value = Math.Round(decTaxAmount, PublicVariables._inNoOfDecimalPlaces); } decAmount = decNetValue + decTaxAmount; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtAmount"].Value = Math.Round(decAmount, PublicVariables._inNoOfDecimalPlaces); decTotalAmount = decTotalAmount + decAmount; decDefaultTotalAmount = decTotalAmount * 1; //CalculateTotalAmount(); //if (dgvTax.Visible) //{ // TotalTaxAmount(); //} //CalculateGrandTotal(); } } } catch (Exception ex) { MessageBox.Show("PI84:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// update function /// </summary> public void EditFunction() { try { TaxInfo infoTax = new TaxInfo(); TaxDetailsInfo infoTaxDetails = new TaxDetailsInfo(); TaxBll bllTax = new TaxBll(); infoTax.TaxName = txtTaxName.Text.Trim(); infoTax.Rate = Convert.ToDecimal(txtRate.Text.ToString()); infoTax.ApplicableOn = cmbApplicableFor.SelectedItem.ToString(); if (cmbCalculationMode.Enabled != true) { infoTax.CalculatingMode = string.Empty; } else { infoTax.CalculatingMode = cmbCalculationMode.SelectedItem.ToString(); } infoTax.Narration = txtNarration.Text.Trim(); if (cbxActive.Checked) { infoTax.IsActive = true; } else { infoTax.IsActive = false; } infoTax.Extra1 = string.Empty; infoTax.Extra2 = string.Empty; if (txtTaxName.Text.ToString() != strTaxName) { if (bllTax.TaxCheckExistence(decTaxIdForEdit, txtTaxName.Text.Trim()) == false) { infoTax.TaxId = decTaxId; bllTax.TaxEdit(infoTax); //-- Delete And Add Tax details --// bllTax.TaxDetailsDeleteWithTaxId(decTaxId); if (dgvTaxSelection.RowCount > 0) { bool isOk = false; foreach (DataGridViewRow dgvRow in dgvTaxSelection.Rows) { isOk = Convert.ToBoolean(dgvRow.Cells["dgvcbxSelect"].Value); if (isOk) { infoTaxDetails.TaxId = decTaxId; infoTaxDetails.SelectedtaxId = Convert.ToDecimal(dgvRow.Cells["dgvtxtTaxId"].Value.ToString());//dgvRow.Cells[0].Value.ToString(); infoTaxDetails.ExtraDate = DateTime.Now; infoTaxDetails.Extra1 = string.Empty; infoTaxDetails.Extra2 = string.Empty; bllTax.TaxDetailsAddWithoutId(infoTaxDetails); } } } LedgerEdit(); Messages.UpdatedMessage(); Clear(); } else { Messages.InformationMessage(" Tax or ledger already exist"); txtTaxName.Focus(); } } else { infoTax.TaxId = decTaxId; bllTax.TaxEdit(infoTax); bllTax.TaxDetailsDeleteWithTaxId(decTaxId); if (dgvTaxSelection.RowCount > 0) { bool isOk = false; foreach (DataGridViewRow dgvRow in dgvTaxSelection.Rows) { isOk = Convert.ToBoolean(dgvRow.Cells["dgvcbxSelect"].Value); if (isOk) { infoTaxDetails.TaxId = decTaxId; infoTaxDetails.SelectedtaxId = Convert.ToDecimal(dgvRow.Cells["dgvtxtTaxId"].Value.ToString());//dgvRow.Cells[0].Value.ToString(); infoTaxDetails.ExtraDate = DateTime.Now; infoTaxDetails.Extra1 = string.Empty; infoTaxDetails.Extra2 = string.Empty; bllTax.TaxDetailsAddWithoutId(infoTaxDetails); } } } LedgerEdit(); Messages.UpdatedMessage(); Clear(); } } catch (Exception ex) { MessageBox.Show("TC5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }