private decimal GetVAT() { OnLoadSystemCommonData _onload = new OnLoadSystemCommonData(); _onload.GetSysConfigList(); _onload.GetTAOrderItem(); var lstOI = CommonData.TaOrderItemList.Where(s => s.CheckCode.Equals(chkNum)); if (CommonData.SysConfigList.Any()) { var lstVAT = from o in lstOI join m in CommonData.TaMenuItemList on o.ItemCode equals m.DishCode where !string.IsNullOrEmpty(m.IsWithoutVAT) && m.IsWithoutVAT.Equals("Y") && m.MenuSetID.Equals(strMenuID) select new { itemTotalPrice = o.ItemTotalPrice }; decimal dTotal = 0; decimal dVat = 0; decimal dVatTmp = 0; if (lstVAT.Any()) { dTotal = lstVAT.ToList().Sum(vat => Convert.ToDecimal(vat.itemTotalPrice)); //交税 dVatTmp = (Convert.ToDecimal(CommonData.SysConfigList.FirstOrDefault().VATPerct) / 100) * dTotal; dVat = Math.Round(dVatTmp, 2, MidpointRounding.AwayFromZero); return(dVat); } else { return(0); } } else { return(0); } }
private void btnNotPaid_Click(object sender, EventArgs e) { htPay["Tendered"] = txtTendered.Text; htPay["Change"] = txtChange.Text; OnLoadSystemCommonData onLoadSystemCommonData = new OnLoadSystemCommonData(); onLoadSystemCommonData.GetTAOrderItem(); onLoadSystemCommonData.GetSysConfigList(); onLoadSystemCommonData.GetTAMenuItemList(); var lstOrderItem = CommonData.TaOrderItemList.Where(s => s.CheckCode.Equals(chkNum)); var lstOI = lstOrderItem.ToList(); #region VAT计算 if (CommonData.SysConfigList.Any()) { //税率 htPay["Rate1"] = CommonData.SysConfigList.FirstOrDefault().VATPerct + "%"; var lstVAT = from o in lstOI join m in CommonData.TaMenuItemList on o.ItemCode equals m.DishCode where !string.IsNullOrEmpty(m.IsWithoutVAT) && m.IsWithoutVAT.Equals("Y") select new { itemTotalPrice = o.ItemTotalPrice }; decimal dTotal = 0; decimal dVatTmp = 0; decimal dVat = 0; if (lstVAT.Any()) { dTotal = lstVAT.ToList().Sum(vat => Convert.ToDecimal(vat.itemTotalPrice)); //交税 dVatTmp = (Convert.ToDecimal(CommonData.SysConfigList.FirstOrDefault().VATPerct) / 100) * dTotal; dVat = Math.Round(dVatTmp, 2, MidpointRounding.AwayFromZero); } htPay["VAT-A"] = dVat.ToString(); //税前 htPay["Net1"] = (dTotal - dVat).ToString(); //总价 htPay["Gross1"] = dTotal.ToString(); htPay["Rate2"] = "0.00%"; htPay["Net2"] = (Convert.ToDecimal(txtTotal.Text) - dTotal).ToString(); htPay["VAT-B"] = "0.00"; htPay["Gross2"] = (Convert.ToDecimal(txtTotal.Text) - dTotal).ToString(); } else { htPay["Rate1"] = "0.00%"; htPay["Net1"] = "0.00"; htPay["VAT-A"] = "0.00"; htPay["Gross1"] = "0.00"; htPay["Rate2"] = "0.00%"; htPay["Net2"] = "0.00"; htPay["VAT-B"] = "0.00"; htPay["Gross2"] = "0.00"; } #endregion PrtPrint.PrtReceipt(lstOI, htPay); }
private void btnPrtReceipt_Click(object sender, EventArgs e) { string sChkNum = dgvPendOrder.CurrentRow.Cells[1].Value.ToString(); string sTotal = dgvPendOrder.CurrentRow.Cells[9].Value.ToString(); Hashtable htPay = new Hashtable(); htPay["Staff"] = userInfo.UsrName; htPay["ItemQty"] = GetOrderItemCount(sChkNum); htPay["SubTotal"] = GetDgvItemTotalPrice(sChkNum); htPay["Total"] = GetDgvItemTotalPrice(sChkNum); htPay["PayType"] = "CASH"; htPay["OrderNo"] = sChkNum; htPay["Tendered"] = "0.00"; htPay["Change"] = "0.00"; OnLoadSystemCommonData onLoadSystemCommonData = new OnLoadSystemCommonData(); onLoadSystemCommonData.GetTAOrderItem(); onLoadSystemCommonData.GetSysConfigList(); onLoadSystemCommonData.GetTAMenuItemList(); var lstOrderItem = CommonData.TaOrderItemList.Where(s => s.CheckCode.Equals(sChkNum)); var lstOI = lstOrderItem.ToList(); #region VAT计算 if (CommonData.SysConfigList.Any()) { //税率 htPay["Rate1"] = CommonData.SysConfigList.FirstOrDefault().VATPerct + "%"; var lstVAT = from o in lstOI join m in CommonData.TaMenuItemList on o.ItemCode equals m.DishCode where !string.IsNullOrEmpty(m.IsWithoutVAT) && m.IsWithoutVAT.Equals("Y") select new { itemTotalPrice = o.ItemTotalPrice }; decimal dTotal = 0; decimal dVatTmp = 0; decimal dVat = 0; if (lstVAT.Any()) { dTotal = lstVAT.ToList().Sum(vat => Convert.ToDecimal(vat.itemTotalPrice)); //交税 dVatTmp = (Convert.ToDecimal(CommonData.SysConfigList.FirstOrDefault().VATPerct) / 100) * dTotal; dVat = Math.Round(dVatTmp, 2, MidpointRounding.AwayFromZero); } htPay["VAT-A"] = dVat.ToString(); //税前 htPay["Net1"] = (dTotal - dVat).ToString(); //总价 htPay["Gross1"] = dTotal.ToString(); htPay["Rate2"] = "0.00%"; htPay["Net2"] = (Convert.ToDecimal(sTotal) - dTotal).ToString(); htPay["VAT-B"] = "0.00"; htPay["Gross2"] = (Convert.ToDecimal(sTotal) - dTotal).ToString(); } else { htPay["Rate1"] = "0.00%"; htPay["Net1"] = "0.00"; htPay["VAT-A"] = "0.00"; htPay["Gross1"] = "0.00"; htPay["Rate2"] = "0.00%"; htPay["Net2"] = "0.00"; htPay["VAT-B"] = "0.00"; htPay["Gross2"] = "0.00"; } #endregion PrtPrint.PrtReceipt(lstOI, htPay); }