public static List <B2cl> GetB2clGst1Save(DataTable dtInvoice, DataTable dtInvoiceItemRate) { #region B2B Section List <B2cl> _resB2BList = new List <B2cl>(); List <Inv2> _resB2clInv = new List <Inv2>(); List <Itm2> _resB2clItm = new List <Itm2>(); #endregion List <B2cl> _b2clList = new List <B2cl>(); var distinctctin = (from DataRow dRow in dtInvoice.Rows select new { col1 = dRow["pos"] }).Distinct().ToList(); for (int k = 0; k < distinctctin.Count(); k++) { B2cl _b2cl = new B2cl(); _b2cl.pos = distinctctin[k].ToString().Replace("col1 =", "").Replace("{", "").Replace("}", ""); string _selectParam = "pos =" + "'" + _b2cl.pos.TrimStart().TrimEnd() + "'"; var currInvoiceLoop = dtInvoice.Select(_selectParam).CopyToDataTable(); List <ItmDet2> _itmdetList = new List <ItmDet2>(); string JSONString = string.Empty; JSONString = JsonConvert.SerializeObject(currInvoiceLoop); _resB2clInv = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Inv2> >(JSONString); string JSONStringItem = string.Empty; JSONStringItem = JsonConvert.SerializeObject(dtInvoiceItemRate); _itmdetList = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ItmDet2> >(JSONStringItem); _b2cl.inv = _resB2clInv; List <Inv2> _invList = new List <Inv2>(); for (int i = 0; i < currInvoiceLoop.Rows.Count; i++) { Inv2 _inv = new Inv2(); List <ItmDet2> itmdetList = new List <ItmDet2>(); List <Itm2> _itmList = new List <Itm2>(); string invoiceId = _b2cl.inv[i].InvoiceId; var _curritm = (List <ItmDet2>)_itmdetList.Where(x => x.InvoiceId == invoiceId).Select(x => x).ToList(); _inv = _resB2clInv[i]; for (int j = 0; j < _curritm.Count(); j++) { Itm2 _itm = new Itm2(); ItmDet2 _itmdet = new ItmDet2(); _itmdet = (_curritm[j]); _itm.num = i + 1; _itm.itm_det = _itmdet; _itmList.Add(_itm); _inv.itms = _itmList; _b2cl.inv[i] = _inv; } } _b2clList.Add(_b2cl); } return(_b2clList); }
public ItmDet2 GetItmDet2(GST_TRN_INVOICE_DATA ItmDet2Invoice) { ItmDet2 invDet2 = new ItmDet2(); invDet2.csamt = (int?)ItmDet2Invoice.CessAmt; invDet2.iamt = (int?)ItmDet2Invoice.IGSTAmt; invDet2.rt = ItmDet2Invoice.Rate == null ? null : (int?)ItmDet2Invoice.Rate; invDet2.txval = (int?)ItmDet2Invoice.TotalAmountWithTax; return(invDet2); }
public ItmDet2 GetItmDet2(GST_TRN_OFFLINE_INVOICE_DATAITEM ItmDet2Invoice) { ItmDet2 invDet2 = new ItmDet2(); invDet2.csamt = (int?)ItmDet2Invoice.CessAmt; invDet2.iamt = (int?)ItmDet2Invoice.IGSTAmt; invDet2.rt = ItmDet2Invoice.GST_TRN_OFFLINE_INVOICE_RATE == null ? null : (int?)ItmDet2Invoice.GST_TRN_OFFLINE_INVOICE_RATE.RATE; invDet2.txval = (int?)ItmDet2Invoice.TotalTaxableValue; return(invDet2); }