Exemplo n.º 1
0
        public bool SaleRegister(GST_TRN_INVOICE invoice)
        {
            foreach (GST_TRN_INVOICE_DATA item in invoice.GST_TRN_INVOICE_DATA)
            {
                var itemType = unitOfWork.ItemRepository.Find(f => f.Item_ID == item.Item_ID).ItemType;
                // var purchaseItems = unitOfWork.PurchaseDataRepositry.Filter(f => f.Status == true && item.Item_ID == f.Item_ID).Select(s => s.GST_MST_PURCHASE_REGISTER.UserID).ToList();
                if (itemType == (byte)EnumConstants.ItemType.HSN)
                {
                    //string uId = seller.SellerUserID;
                    //int iTem = Convert.ToInt32(item.Item_ID);
                    //decimal LeftQty = purchaseRegister.GetLeftItemQty(iTem, uId);

                    //if (LeftQty > item.Qty)
                    //{
                    GST_MST_SALE_REGISTER salRegister = new GST_MST_SALE_REGISTER();
                    salRegister.InvoiceID   = invoice.InvoiceID;
                    salRegister.PerUnitRate = item.Rate;
                    salRegister.Item_ID     = item.Item_ID;
                    salRegister.Qty         = item.Qty;
                    salRegister.CreatedBy   = invoice.CreatedBy;
                    salRegister.CreatedDate = DateTime.Now;
                    salRegister.Status      = true;
                    salRegister.Id          = invoice.SellerUserID;
                    salRegister.SaleStatus  = (byte)EnumConstants.SaleStatus.Fresh;
                    unitOfWork.SaleRegisterDataRepositry.Create(salRegister);

                    //q }
                }
            }
            unitOfWork.Save();
            return(true);
        }
Exemplo n.º 2
0
        public bool SaveInvoiveDataInPurchaseRegister(GST_TRN_INVOICE invoice)
        {
            var prData = unitOfWork.PurchaseRegisterDataRepositry.Find(f => f.SupplierInvoiceNo == invoice.InvoiceNo);

            if (prData == null)
            {
                SavePurchaseRegister(Purchase_Register_Data(invoice));
            }
            return(true);
        }
Exemplo n.º 3
0
        private At Getatsdata(GST_TRN_INVOICE atdata)
        {
            At at = new At();

            at.itms = new List <Itm4>();
            // at.pos = atdata.GST_MST_STATE.StateName;
            at.itms.AddRange(GetItm4(atdata));
            at.sply_ty = atdata.IsInter == true ? "INTER" : "INTRA";
            return(at);
        }
Exemplo n.º 4
0
        //public bool UpdateInvoiceDataItemFromPurchaseRegsiter(GST_TRN_INVOICE invoice)
        //{
        //    var prData = unitOfWork.PurchaseRegisterDataRepositry.Find(f => f.SupplierInvoiceNo == invoice.InvoiceNo);
        //    if (prData != null)
        //    {
        //        foreach (GST_MST_PURCHASE_DATA data in prData.GST_MST_PURCHASE_DATA)
        //        {
        //            unitOfWork.PurchaseDataRepositry.Delete(data);
        //        }
        //        unitOfWork.Save();
        //    }

        //    UpdatePurchaseData(invoice);
        //    return true;
        //}



        private GST_MST_PURCHASE_REGISTER Purchase_Register_Data(GST_TRN_INVOICE invoice)
        {
            GST_MST_PURCHASE_REGISTER PR = new GST_MST_PURCHASE_REGISTER();

            if (invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.Import)
            {
                PR.SellerName       = SellerName;       //invoice.AspNetUser.OrganizationName;
                PR.SellerAddress    = SellerAddress;    //invoice.AspNetUser.Address;
                PR.SellerGSTN       = SellerGSTN;       //invoice.AspNetUser.GSTNNo;
                PR.ReceiverName     = ReceiverName;     //invoice.AspNetUser1.OrganizationName;
                PR.ReceiverAddress  = ReceiverAddress;  //invoice.AspNetUser1.Address;
                PR.ConsigneeName    = ConsigneeName;    //invoice.AspNetUser2.OrganizationName;
                PR.ConsigneeAddress = ConsigneeAddress; //invoice.AspNetUser2.Address;
                PR.StateCode        = StateCode;
            }
            else
            {
                PR.SellerName       = invoice.AspNetUser.OrganizationName;
                PR.SellerAddress    = invoice.AspNetUser.Address;
                PR.SellerGSTN       = invoice.AspNetUser.GSTNNo;
                PR.ReceiverName     = invoice.AspNetUser1.OrganizationName;
                PR.ReceiverAddress  = invoice.AspNetUser1.Address;
                PR.ConsigneeName    = invoice.AspNetUser2.OrganizationName;
                PR.ConsigneeAddress = invoice.AspNetUser2.Address;
                PR.StateCode        = Convert.ToString(invoice.AspNetUser.StateCode);
            }
            PR.UserID                     = LoggedinUserID;
            PR.StockInwardDate            = DateTime.Now;
            PR.StockOrderDate             = invoice.InvoiceDate;
            PR.OrderPo                    = null; //TODO
            PR.OrderPoDate                = null; //TODO
            PR.SupplierInvoiceNo          = invoice.InvoiceNo;
            PR.SupplierInvoiceDate        = invoice.InvoiceDate;
            PR.SupplierInvoiceMonth       = invoice.InvoiceMonth;
            PR.Freight                    = invoice.Freight;
            PR.Insurance                  = invoice.Insurance;
            PR.PackingAndForwadingCharges = invoice.PackingAndForwadingCharges;
            PR.ElectronicReferenceNo      = invoice.ElectronicReferenceNo;
            PR.ElectronicReferenceNoDate  = invoice.ElectronicReferenceNoDate;
            //PR.StateID = getinvocdtls.
            PR.PurchaseStatus = Convert.ToByte(EnumConstants.InvoiceStatus.Fresh);
            PR.Status         = true;

            PR.CreatedBy   = invoice.CreatedBy;
            PR.CreatedDate = DateTime.Now;

            List <GST_MST_PURCHASE_DATA> data = new List <GST_MST_PURCHASE_DATA>();

            foreach (GST_TRN_INVOICE_DATA invData in invoice.GST_TRN_INVOICE_DATA)
            {
                data.Add(PurchaseData(invData));
            }
            PR.GST_MST_PURCHASE_DATA = data;
            return(PR);
        }
Exemplo n.º 5
0
        private void BindInvoice(GST_TRN_INVOICE invoice)
        {
            //List<GST_TRN_INVOICE> listInvoice = new List<GST_TRN_INVOICE>();
            //listInvoice.Add(invoice);

            // fvInvoice.DataSource = listInvoice;
            //fvInvoice.DataBind();
            //GridView gv = (GridView)fvInvoice.FindControl("gvItems");
            gvInvoice_Items.DataSource = invoice.GST_TRN_INVOICE_DATA;
            gvInvoice_Items.DataBind();
            lkbUpdateInvoice.Visible = true;
        }
Exemplo n.º 6
0
        public B2cl GetB2cl(GST_TRN_INVOICE b2clInvoice)
        {
            B2cl b2cldata = new B2cl();

            b2cldata.inv = new List <Inv2>();
            b2cldata.pos = b2clInvoice.AspNetUser.StateCode.ToString();
            foreach (var data in b2clInvoice.GST_TRN_INVOICE_DATA)
            {
                b2cldata.inv.Add(GetInv2(data));
            }
            return(b2cldata);
        }
Exemplo n.º 7
0
        //Test Methods
        private Txpd Gettxpdata(GST_TRN_INVOICE txpddata)
        {
            Txpd txpd = new Txpd();

            txpd.pos     = Convert.ToString(txpddata.TaxBenefitingState);
            txpd.sply_ty = txpddata.IsInter == true ? "INTER" : "INTRA";
            foreach (var data in txpddata.GST_TRN_INVOICE_DATA)
            {
                txpd.itms.Add(GetItm7(data));
            }

            return(txpd);
        }
Exemplo n.º 8
0
 public void BindInvoice(GST_TRN_INVOICE invoice)
 {
     try
     {
         gvInvoice_Items.DataSource = invoice.GST_TRN_INVOICE_DATA;
         gvInvoice_Items.DataBind();
         lkbUpdateInvoice.Visible = true;
     }catch (Exception ex)
     {
         cls_ErrorLog ob = new cls_ErrorLog();
         cls_ErrorLog.LogError(ex, Common.LoggedInUserID());
     }
 }
Exemplo n.º 9
0
        private List <Itm4> GetItm4(GST_TRN_INVOICE atdata)
        {
            List <Itm4> itm4s = new List <Itm4>();
            Itm4        itm4  = new Itm4();

            foreach (var data in atdata.GST_TRN_INVOICE_DATA)
            {
                itm4.camt  = (double?)data.CGSTAmt;
                itm4.csamt = (int?)data.CessAmt;
                itm4.iamt  = (double?)data.IGSTAmt;
                itm4.rt    = (int?)data.Rate;
                itm4.samt  = (int?)data.SGSTAmt;
                itm4s.Add(itm4);
            }
            return(itm4s);
        }
Exemplo n.º 10
0
        private List <B2clAOutward> GetB2CLAJson(List <B2clAOutward> b2cl, GST_TRN_INVOICE invoice)
        {
            string b2cJson = string.Empty;


            B2clAOutward b2clItem = new B2clAOutward();
            B2CLAInv     inv      = new B2CLAInv();

            inv.inum = invoice.InvoiceNo;
            inv.idt  = invoice.InvoiceDate.Value.ToString("dd-MM-yyyy");
            inv.val  = Convert.ToDouble(invoice.GST_TRN_INVOICE_DATA.Sum(s => s.TaxableAmount));
            inv.pos  = invoice.TaxBenefitingState;
            //inv.chksum = invoice.
            //inv.cname = GetNameFromGSTIN(invoice.ReceiverUserID);
            //inv.etin =
            //inv.itms =
            //inv.prs =

            //TODO:need to change and update according to count according to in invoice item.
            List <B2CLitem> lineItems = new List <B2CLitem>();

            foreach (GST_TRN_INVOICE_DATA itm in invoice.GST_TRN_INVOICE_DATA)
            {
                B2CLitem invItem = new B2CLitem();
                invItem.num = itm.LineID.Value;
                B2CLItmDet itemDetail = new B2CLItmDet();
                itemDetail.irt    = Convert.ToDouble(itm.Rate);
                itemDetail.txval  = Convert.ToDouble(itm.TaxableAmount);
                itemDetail.iamt   = Convert.ToDouble(itm.IGSTAmt);
                itemDetail.csamt  = Convert.ToDouble(itm.CGSTAmt);
                itemDetail.cssrt  = Convert.ToDouble(itm.CessRate);
                itemDetail.irt    = Convert.ToDouble(itm.IGSTRate);
                itemDetail.hsn_sc = Convert.ToString(itm.Item_ID);
                //itemDetail.ty
                invItem.itm_det = itemDetail;
                lineItems.Add(invItem);
            }
            inv.itms = lineItems;
            List <B2CLAInv> invList = new List <B2CLAInv>();

            invList.Add(inv);
            b2clItem.inv = invList;
            b2cl.Add(b2clItem);
            return(b2cl);
        }
Exemplo n.º 11
0
        private SaveGSTRData Savegstrdata(GST_TRN_INVOICE invoice)
        {
            SaveGSTRData gstrdata = new SaveGSTRData();

            gstrdata.gstin  = invoice.AspNetUser.GSTNNo;
            gstrdata.fp     = Convert.ToString(invoice.FinYear_ID);
            gstrdata.gt     = Convert.ToInt64(invoice.AspNetUser.GrossTurnOver);
            gstrdata.cur_gt = Convert.ToInt64(invoice.AspNetUser.GrossTurnOver);

            List <B2b> b2b = new List <B2b>();

            foreach (var crData in invoice.GST_TRN_CRDR_NOTE)
            {
                b2b.Add(b2bData(crData));
            }
            //   gstrdata.B2b = b2b;

            return(gstrdata);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Update purchase data items from invoice--check and update qty  --done--when ACCEPT Condition by receiver--in mismatch GSTR2
        /// </summary>
        /// <param name="invoice"></param>
        /// <returns></returns>
        public bool UpdatePurchaseDataItemFromInvoice(GST_TRN_INVOICE invoice)
        {
            List <GST_MST_PURCHASE_DATA> data = new List <GST_MST_PURCHASE_DATA>();
            var prData = unitOfWork.PurchaseRegisterDataRepositry.Find(f => f.SupplierInvoiceNo == invoice.InvoiceNo);

            foreach (GST_MST_PURCHASE_DATA pData in prData.GST_MST_PURCHASE_DATA.ToList())
            {
                unitOfWork.PurchaseDataRepositry.Delete(pData);
            }
            unitOfWork.Save();

            foreach (GST_TRN_INVOICE_DATA invData in invoice.GST_TRN_INVOICE_DATA)
            {
                var item = PurchaseData(invData);
                item.PurchageRegisterID = prData.PurchageRegisterID;
                SavePurchaseRegister(item);
            }
            return(true);
        }
Exemplo n.º 13
0
        private List <Inv3> GetInv3(GST_TRN_INVOICE expdata)
        {
            List <Inv3> invs3 = new List <Inv3>();
            Inv3        inv3;

            foreach (var dataitem in expdata.GST_TRN_INVOICE_DATA)
            {
                inv3      = new Inv3();
                inv3.itms = new List <Itm3>();
                inv3.idt  = Convert.ToDateTime(dataitem.GST_TRN_INVOICE.InvoiceDate).ToString("dd-mm-yyyy");
                inv3.inum = dataitem.GST_TRN_INVOICE.InvoiceNo;
                inv3.itms.Add(GetItm3(dataitem));
                //  inv3.sbdt = Convert.ToDateTime(dataitem.GST_TRN_OFFLINE_INVOICE.ShippingBillDate).ToString("dd-mm-yyyy");
                // inv3.sbnum = Convert.ToInt32(dataitem.GST_TRN_OFFLINE_INVOICE.ShippingBillNo);
                // inv3.sbpcode = dataitem.GST_TRN_OFFLINE_INVOICE.PortCode;
                inv3.val = (int?)dataitem.TotalAmountWithTax;
                invs3.Add(inv3);
            }
            return(invs3);
        }
Exemplo n.º 14
0
        private List <Inv> GetInv(GST_TRN_INVOICE B2B)
        {
            List <Inv> invs = new List <Inv>();
            Inv        inv;

            foreach (var dataitem in B2B.GST_TRN_INVOICE_DATA)
            {
                inv         = new Inv();
                inv.itms    = new List <Itm>();
                inv.idt     = Convert.ToDateTime(dataitem.GST_TRN_INVOICE.InvoiceDate).ToString("dd-mm-yyyy");
                inv.inum    = dataitem.GST_TRN_INVOICE.InvoiceNo;
                inv.inv_typ = dataitem.GST_TRN_INVOICE.InvoiceType == null ? "" : ((EnumConstants.InvoiceType)dataitem.GST_TRN_INVOICE.InvoiceType).ToString()[0].ToString();
                inv.itms.Add(GetItm(dataitem));
                //inv.pos = dataitem..PlaceofSupply == null ? "" : dataitem.GST_TRN_OFFLINE_INVOICE.GST_MST_STATE.StateCode;
                //inv.rchrg = Convert.ToBoolean(dataitem.GST_TRN_OFFLINE_INVOICE.ReverseCharge) ? "Y" : "N";
                inv.val = (int?)dataitem.TotalAmountWithTax;
                invs.Add(inv);
            }
            return(invs);
        }
Exemplo n.º 15
0
        public B2cs GetB2cs(GST_TRN_INVOICE ItmB2csInvoice)
        {
            B2cs invb2cs = new B2cs();

            invb2cs.pos = Convert.ToString(ItmB2csInvoice.AspNetUser.StateCode);
            // invb2cs.typ = Convert.ToString(ItmB2csInvoice.Type);
            var b2bdata = ItmB2csInvoice.GST_TRN_INVOICE_DATA.FirstOrDefault();

            if (b2bdata != null)
            {
                invb2cs.camt  = (int?)b2bdata.CGSTAmt;
                invb2cs.csamt = (int?)b2bdata.CessAmt;
                //invb2cs.etin = ItmB2csInvoice.TinNo;
                invb2cs.iamt = (int?)b2bdata.IGSTAmt;
                invb2cs.samt = (int?)b2bdata.SGSTAmt;
                //invb2cs.sply_ty = ItmB2csInvoice.
                invb2cs.txval = (double?)b2bdata.TaxableAmount;
                invb2cs.rt    = b2bdata.Rate == null ? null : (int?)b2bdata.Rate;
            }
            return(invb2cs);
        }
Exemplo n.º 16
0
        private List <B2bAOutward> GetB2BAJson(List <B2bAOutward> b2ba, GST_TRN_INVOICE invoice)
        {
            string b2bJson = string.Empty;

            B2bAOutward b2baItem = new B2bAOutward();

            b2baItem.ctin = invoice.AspNetUser2.GSTNNo;//.ConsigneeUserID;
            B2BAInv inv = new B2BAInv();

            inv.inum    = invoice.InvoiceNo;
            inv.idt     = invoice.InvoiceDate.Value.ToString("dd-MM-yyyy");
            inv.val     = Convert.ToDouble(invoice.GST_TRN_INVOICE_DATA.Sum(s => s.TaxableAmount));
            inv.pos     = invoice.TaxBenefitingState;
            inv.rchrg   = "N"; //TODO:need to change
            inv.inv_typ = "R"; //
            //TODO:need to change and update according to count according to in invoice item.
            List <B2Bitem> lineItems = new List <B2Bitem>();

            foreach (GST_TRN_INVOICE_DATA itm in invoice.GST_TRN_INVOICE_DATA)
            {
                B2Bitem invItem = new B2Bitem();
                invItem.num = itm.LineID.Value;
                ItmDet itemDetail = new ItmDet();
                itemDetail.rt    = Convert.ToDouble(itm.Rate);
                itemDetail.txval = Convert.ToDouble(itm.TaxableAmount);
                itemDetail.iamt  = Convert.ToDouble(itm.IGSTAmt);
                itemDetail.camt  = Convert.ToDouble(itm.CGSTAmt);
                itemDetail.samt  = Convert.ToDouble(itm.SGSTAmt);
                invItem.itm_det  = itemDetail;
                lineItems.Add(invItem);
            }
            inv.itms = lineItems;
            List <B2BAInv> invList = new List <B2BAInv>();

            invList.Add(inv);

            b2baItem.inv = invList;
            b2ba.Add(b2baItem);
            return(b2ba);
        }
Exemplo n.º 17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="invoice"></param>
        /// <param name="note"></param>
        /// <returns></returns>
        private GST_TRN_CRDR_NOTE RefectorNote(GST_TRN_INVOICE invoice)
        {
            GST_TRN_CRDR_NOTE item = new GST_TRN_CRDR_NOTE();

            item.From_UserID    = invoice.SellerUserID;
            item.To_UserID      = invoice.ReceiverUserID;
            item.InvoiceID      = invoice.InvoiceID;
            item.NoteTypeStatus = (byte)EnumConstants.NoteTypeStatus.Fresh;
            item.CDN_Date       = DateTime.Now;
            item.NoteType       = this.NoteType;
            item.Description    = this.Description;
            string noteNo = "";

            if ((EnumConstants.NoteType) this.NoteType == EnumConstants.NoteType.Credit)
            {
                noteNo = "CR" + UniqueNoGenerate.RandomValueNote();
            }
            else if ((EnumConstants.NoteType) this.NoteType == EnumConstants.NoteType.Debit)
            {
                noteNo = "DR" + UniqueNoGenerate.RandomValueNote();
            }
            else
            {
                noteNo = UniqueNoGenerate.RandomValueNote();
            }
            item.NoteNumber  = noteNo;
            item.CreatedBy   = invoice.SellerUserID;
            item.CreatedDate = DateTime.Now;

            List <GST_TRN_CRDR_NOTE_DATA> data = new List <GST_TRN_CRDR_NOTE_DATA>();

            foreach (GST_TRN_INVOICE_DATA invData in invoice.GST_TRN_INVOICE_DATA)
            {
                data.Add(ItemData(invData));
            }
            item.GST_TRN_CRDR_NOTE_DATA = data;

            return(item);
        }
Exemplo n.º 18
0
        public override int SaveInvoiceData(Seller seller)
        {
            cls_Invoice invoiceObject = new cls_Invoice();
            int         result        = 0;

            GST_TRN_INVOICE inv = new GST_TRN_INVOICE();

            inv.InvoiceNo    = seller.SellerInvoice;
            inv.InvoiceDate  = DateTime.Now;//Convert.ToDateTime(seller.DateOfInvoice);
            inv.InvoiceMonth = Convert.ToByte(DateTime.Now.Month);
            //  inv.InvoiceMonth = Convert.ToByte(DateTime.Now.Month);
            inv.SellerUserID               = seller.SellerUserID;
            inv.ReceiverUserID             = seller.Reciever.RecieveruserID;
            inv.ConsigneeUserID            = seller.Consignee.ConsigneeUserID;
            inv.VendorID                   = seller.Invoice.VendorID;
            inv.TransShipment_ID           = seller.Invoice.TransShipment_ID;
            inv.Freight                    = seller.Invoice.Freight;
            inv.Insurance                  = seller.Invoice.Insurance;
            inv.PackingAndForwadingCharges = seller.Invoice.PackingAndForwadingCharges;
            inv.FinYear_ID                 = invoiceObject.GetCurrentFinYear(); // Convert.ToInt32(DateTime.UtcNow.Year + "-" + DateTime.UtcNow.AddYears(1));//Convert.ToInt32(seller.SerialNoInvoice.FinancialYear);
            // inv.IsInter = seller.Reciever.StateCode == seller.Consignee.StateCode ? true : false;
            inv.ReceiverFinYear_ID = invoiceObject.GetCurrentFinYear();         // Convert.ToInt32(DateTime.UtcNow.Year + "-" + DateTime.UtcNow.AddYears(1));// Convert.ToInt32(seller.SerialNoInvoice.FinancialYear);
            inv.Status             = true;
            inv.CreatedDate        = DateTime.Now;
            inv.InvoiceStatus      = (byte)EnumConstants.InvoiceStatus.Fresh;
            // inv.InvoiceStatus = (byte)EnumConstants.InvoiceStatus.Fresh;
            bool isInter = GetConsumptionDestinationOfGoodsOrServices(seller.SellerStateCode, seller.Reciever.StateCode, seller.Consignee.StateCode);

            inv.IsInter            = isInter;
            inv.TaxBenefitingState = seller.Consignee.StateCode;
            inv.CreatedBy          = seller.CreatedBy;
            //condition for tax con.
            //if ((EnumConstants.InvoiceSpecialCondition.Regular).ToString || Convert.ToBoolean(EnumConstants.InvoiceSpecialCondition.Export) || Convert.ToBoolean(EnumConstants.InvoiceSpecialCondition.Advance) || Convert.ToBoolean(EnumConstants.InvoiceSpecialCondition.JobWork) || Convert.ToBoolean(EnumConstants.InvoiceSpecialCondition.SEZUnit) || Convert.ToBoolean(EnumConstants.InvoiceSpecialCondition.SEZDeveloper) || Convert.ToBoolean(EnumConstants.InvoiceSpecialCondition.DeemedExport) || Convert.ToBoolean(EnumConstants.InvoiceSpecialCondition.B2CS) || Convert.ToBoolean(EnumConstants.InvoiceSpecialCondition.B2CL) || Convert.ToBoolean(EnumConstants.InvoiceSpecialCondition.ECommerce))
            if (seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.Regular.ToString() || seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.Export.ToString() || seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.Advance.ToString() || seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.JobWork.ToString() || seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.SEZDeveloper.ToString() || seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.SEZUnit.ToString() || seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.DeemedExport.ToString() || seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.B2CS.ToString() || seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.B2CL.ToString() || seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.ECommerce.ToString())
            // if (seller.Invoice.InvoiceSpecialCondition == (EnumConstants.InvoiceSpecialCondition.Regular) || (EnumConstants.InvoiceSpecialCondition.Export) || (EnumConstants.InvoiceSpecialCondition.Advance).ToString() || (EnumConstants.InvoiceSpecialCondition.JobWork).ToString() || (EnumConstants.InvoiceSpecialCondition.SEZUnit).ToString() || (EnumConstants.InvoiceSpecialCondition.SEZDeveloper).ToString() || (EnumConstants.InvoiceSpecialCondition.DeemedExport).ToString() || (EnumConstants.InvoiceSpecialCondition.B2CS).ToString() || (EnumConstants.InvoiceSpecialCondition.B2CL).ToString() || (EnumConstants.InvoiceSpecialCondition.ECommerce).ToString())
            {
                //inv.InvoiceUserID = seller.Reciever.RecieveruserID;
                inv.InvoiceUserID = seller.SellerUserID;
            }
            else
            {
                inv.InvoiceUserID = seller.Reciever.RecieveruserID;
            }
            inv.InvoiceType = (byte)(EnumConstants.InvoiceType)Enum.Parse(typeof(EnumConstants.InvoiceType), seller.Invoice.InvoiceType);

            if (inv.InvoiceType == (byte)EnumConstants.InvoiceType.B2C)
            {
                var totalBillamount = seller.Invoice.LineEntry.Sum(amt => amt.AmountWithTax);
                if (totalBillamount > 250000)
                {
                    inv.InvoiceSpecialCondition = (byte)(EnumConstants.InvoiceSpecialCondition.B2CL);
                }
                else
                {
                    inv.InvoiceSpecialCondition = (byte)(EnumConstants.InvoiceSpecialCondition)Enum.Parse(typeof(EnumConstants.InvoiceSpecialCondition), seller.Invoice.InvoiceSpecialCondition);
                }
            }
            else
            {
                inv.InvoiceSpecialCondition = (byte)(EnumConstants.InvoiceSpecialCondition)Enum.Parse(typeof(EnumConstants.InvoiceSpecialCondition), seller.Invoice.InvoiceSpecialCondition);
            }

            if (inv.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.ECommerce)
            {
                inv.OrderDate = seller.OrderDate;
            }

            var invoiceCreate = unitOfWork.InvoiceRepository.Create(inv);

            unitOfWork.Save();

            if (seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.Export.ToString())
            {
                bool isStateExampted = false;
            }
            else
            {
                bool isStateExampted = unitOfWork.StateRepository.Find(f => f.StateCode == seller.Consignee.StateCode).IsExempted.Value;
            }
            bool isExported = false;

            if (seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.Export.ToString() || seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.SEZDeveloper.ToString() || seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.SEZUnit.ToString() || seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.DeemedExport.ToString())
            {
                isExported = true;
            }

            bool isJobwork   = (seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.JobWork.ToString());
            bool isImport    = (seller.Invoice.InvoiceSpecialCondition == EnumConstants.InvoiceSpecialCondition.Import.ToString());
            var  stateData   = unitOfWork.StateRepository.Find(c => c.StateCode == seller.SellerStateCode);
            var  isUTState   = stateData.UT.Value;
            var  isExempted  = stateData.IsExempted.Value;
            var  isEcom      = false;
            var  isUn        = false;
            var  invLineItem = from invo in seller.Invoice.LineEntry
                               select new GST_TRN_INVOICE_DATA
            {
                InvoiceID = invoiceCreate.InvoiceID,
                LineID    = invo.LineID,
                // GST_MST_ITEM = invo.Item,
                Item_ID       = invo.Item.Item_ID,
                Qty           = invo.Qty,
                Rate          = invo.PerUnitRate,
                TotalAmount   = invo.TotalLineIDWise,
                Discount      = invo.Discount,
                TaxableAmount = invo.TaxableValueLineIDWise,
                // TotalAmountWithTax = invo.TaxValue,
                IGSTRate = Calculate.TaxRate(invo.Item, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.IGST, invo.TaxableValueLineIDWise, invo.Item.IGST.Value),                   //isJobwork ? 0 : (isUTState ? 0 : (isInter ? invo.Item.IGST : (isExport ? invo.Item.IGST : (isImport ? invo.Item.IGST : 0)))),
                IGSTAmt  = Calculate.TaxCalculate(invo.Item, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.IGST, invo.TaxableValueLineIDWise, invo.Item.IGST.Value),              // isJobwork ? 0 : (isUTState ? 0 : (isInter ? Calculate.CalculateIGSTLineIDWise(invo.TaxableValueLineIDWise, invo.Item.IGST.Value) : (isExport ? Calculate.CalculateIGSTLineIDWise(invo.TaxableValueLineIDWise, invo.Item.IGST.Value) : (isImport ? Calculate.CalculateIGSTLineIDWise(invo.TaxableValueLineIDWise, invo.Item.IGST.Value) : 0)))),
                CGSTRate = Calculate.TaxRate(invo.Item, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.CGST, invo.TaxableValueLineIDWise, invo.Item.CGST.Value),
                CGSTAmt  = Calculate.TaxCalculate(invo.Item, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.CGST, invo.TaxableValueLineIDWise, invo.Item.CGST.Value),
                SGSTRate = Calculate.TaxRate(invo.Item, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.SGST, invo.TaxableValueLineIDWise, invo.Item.SGST.Value),
                SGSTAmt  = Calculate.TaxCalculate(invo.Item, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.SGST, invo.TaxableValueLineIDWise, invo.Item.SGST.Value),
                UGSTRate = Calculate.TaxRate(invo.Item, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.UTGST, invo.TaxableValueLineIDWise, invo.Item.UGST.Value),
                UGSTAmt  = Calculate.TaxCalculate(invo.Item, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.UTGST, invo.TaxableValueLineIDWise, invo.Item.UGST.Value),
                CessRate = isJobwork ? 0 : invo.Item.CESS,
                CessAmt  = isJobwork ? 0 : Calculate.CalculateCESSLineIDWise(invo.TaxableValueLineIDWise, invo.Item.CESS.Value)
            };


            foreach (GST_TRN_INVOICE_DATA item in invLineItem)
            {
                item.TotalAmountWithTax = item.TaxableAmount + item.IGSTAmt + item.CGSTAmt + item.SGSTAmt + item.UGSTAmt + item.CessAmt;
                item.CreatedDate        = DateTime.Now;
                unitOfWork.InvoiceDataRepository.Create(item);
            }

            unitOfWork.Save();

            //start- Mapp Regular and Jobwork Challan no.
            foreach (Int64 itm in seller.ChallanInvoiceIds)
            {
                GST_TRN_INVOICE_MAP map = new GST_TRN_INVOICE_MAP();
                map.MapfromInvoiceID = itm;
                map.MaptoInvoiceID   = invoiceCreate.InvoiceID;
                map.Status           = true;
                map.CreatedBy        = seller.CreatedBy;
                map.CreatedDate      = DateTime.Now;
                unitOfWork.InvoiceMapRepository.Create(map);
            }

            unitOfWork.Save();
            //end
            foreach (Int64 itm in seller.AdvanceInvoiceIds)
            {
                GST_TRN_INVOICE_MAP map = new GST_TRN_INVOICE_MAP();
                map.MapfromInvoiceID = itm;
                map.MaptoInvoiceID   = invoiceCreate.InvoiceID;
                map.Status           = true;
                map.CreatedBy        = seller.CreatedBy;
                map.CreatedDate      = DateTime.Now;
                unitOfWork.InvoiceMapRepository.Create(map);
            }
            unitOfWork.Save();

            cls_ITC itc = new cls_ITC();

            itc.ITCVoucherType = (byte)EnumConstants.ITCVoucherType.TaxInvoice;
            itc.SaveItc(invoiceCreate);

            cls_PurchaseRegister purchaseRegister = new cls_PurchaseRegister();

            //var allitems = invLineItem.Select(s => s.Item_ID).Distinct();
            if (inv.InvoiceSpecialCondition == (byte)(EnumConstants.InvoiceSpecialCondition.Advance))
            {
                //No data will be save in sale and purchase.
            }
            else if (inv.InvoiceSpecialCondition != (byte)(EnumConstants.InvoiceSpecialCondition.Import))  //enumm
            {
                foreach (GST_TRN_INVOICE_DATA item in invLineItem)
                {
                    var itemType = unitOfWork.ItemRepository.Find(f => f.Item_ID == item.Item_ID).ItemType;
                    // var purchaseItems = unitOfWork.PurchaseDataRepositry.Filter(f => f.Status == true && item.Item_ID == f.Item_ID).Select(s => s.GST_MST_PURCHASE_REGISTER.UserID).ToList();
                    if (itemType == (byte)EnumConstants.ItemType.HSN)
                    {
                        string  uId     = seller.SellerUserID;
                        int     iTem    = Convert.ToInt32(item.Item_ID);
                        decimal LeftQty = purchaseRegister.GetLeftItemQty(iTem, uId);

                        if (LeftQty > item.Qty)
                        {
                            GST_MST_SALE_REGISTER salRegister = new GST_MST_SALE_REGISTER();
                            salRegister.InvoiceID   = invoiceCreate.InvoiceID;
                            salRegister.PerUnitRate = item.Rate;
                            salRegister.Item_ID     = item.Item_ID;
                            salRegister.Qty         = item.Qty;
                            salRegister.CreatedBy   = seller.CreatedBy;
                            salRegister.CreatedDate = DateTime.Now;
                            salRegister.Status      = true;
                            salRegister.Id          = uId;
                            salRegister.SaleStatus  = (byte)EnumConstants.SaleStatus.Fresh;
                            unitOfWork.SaleRegisterDataRepositry.Create(salRegister);
                            unitOfWork.Save();
                        }
                    }
                }
            }

            else
            {
                //Add stock in PURCHSE Reagister When item is import from seller..
                purchaseRegister.LoggedinUserID   = invoiceCreate.SellerUserID;
                purchaseRegister.SellerName       = seller.NameAsOnGST;
                purchaseRegister.SellerAddress    = seller.Address;
                purchaseRegister.SellerGSTN       = seller.GSTIN;
                purchaseRegister.ReceiverName     = seller.Reciever.NameAsOnGST;
                purchaseRegister.ReceiverAddress  = seller.Reciever.Address;
                purchaseRegister.ConsigneeName    = seller.Consignee.NameAsOnGST;
                purchaseRegister.ConsigneeAddress = seller.Consignee.Address;
                purchaseRegister.StateCode        = seller.SellerStateCode;

                purchaseRegister.SaveInvoiveDataInPurchaseRegister(inv);
            }

            if (inv.InvoiceSpecialCondition == (byte)(EnumConstants.InvoiceSpecialCondition.SupplierMissingInvoice))
            {
                GST_TRN_INVOICE_AUDIT_TRAIL IAT = new GST_TRN_INVOICE_AUDIT_TRAIL();

                IAT.InvoiceID        = invoiceCreate.InvoiceID;
                IAT.AuditTrailStatus = (byte)EnumConstants.InvoiceAuditTrailSatus.Import2A;
                IAT.InvoiceAction    = (byte)EnumConstants.InvoiceActionAuditTrail.Add;
                IAT.UserIP           = HelperUtility.IP;
                //IAT.SellerInvoiceAction = "" ;
                IAT.ReceiverInvoiceAction = (byte)EnumConstants.InvoiceActionAuditTrail.Add;
                // IAT.SellerInvoiceActionDate = DateTime.Now;
                IAT.ReceiverInvoiceActionDate = DateTime.Now;
                IAT.CreatedBy   = invoiceCreate.CreatedBy;
                IAT.CreatedDate = DateTime.Now;
                unitOfWork.InvoiceAuditTrailRepositry.Create(IAT);
                unitOfWork.Save();
            }
            //foreach (GST_TRN_INVOICE_DATA item in invLineItem)
            //{
            // itc.UserID = seller.Reciever.RecieveruserID;
            // itc.Amount = item.IGSTAmt + item.CGSTAmt + item.SGSTAmt + item.UGSTAmt + item.CessAmt;
            //itc.InvoiceID = invoiceCreate.InvoiceID;
            // itc.ITCStatus = (byte)(EnumConstants.ITCStatus.Active);
            // itc.ITCVoucherType = (byte)EnumConstants.ITCMovement.Credit;
            // itc.ITCDate = DateTime.Now;
            // itc.ITCMovement = (byte)(EnumConstants.InvoiceSpecialCondition.Import);
            //// itc.TaxType = item.UGSTAmt;
            // itc.IGST = item.IGSTAmt;
            // itc.CGST = item.CGSTAmt;
            // if (item.SGSTAmt != 0)
            // {
            // itc.SGST = item.SGSTAmt;
            // }
            // else
            // {
            //     itc.SGST = item.UGSTAmt;
            // }
            // itc.CreatedBy = seller.CreatedBy;
            // itc.CreatedDate = DateTime.Now;
            // unitOfWork.ITCRepository.Create(itc);
            // unitOfWork.Save();
            //}


            //User Current TurnOver
            GST_MST_USER_CURRENT_TURNOVER turnOver = new GST_MST_USER_CURRENT_TURNOVER();

            turnOver.User_ID                 = inv.SellerUserID;
            turnOver.Month                   = inv.InvoiceMonth;
            turnOver.InvoiceID               = invoiceCreate.InvoiceID;
            turnOver.InvoiceAmountWithTax    = invLineItem.Sum(s => s.TotalAmount);
            turnOver.InvoiceAmountWithoutTax = invLineItem.Sum(s => s.TaxableAmount);
            turnOver.TurnOverStatus          = 0;//TODO:Need to change
            turnOver.CreatedBy               = inv.CreatedBy;
            turnOver.CreatedDate             = DateTime.Now;
            turnOver.Status                  = true;
            unitOfWork.CurrentTurnoverRepositry.Create(turnOver);
            unitOfWork.Save();
            //// ExcelDB exceldb = new ExcelDB();
            ////result = exceldb.SaveInvoiceData(seller);

            //  }
            return(result);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Receiver SIDE ITC ADD/UPDATE
        /// </summary>
        /// <param name="invoiceData"></param>
        /// <returns></returns>
        public bool SaveItcReceiver(GST_TRN_INVOICE invoiceData)
        {
            GST_TRN_ITC item = new GST_TRN_ITC();

            item.Amount = invoiceData.GST_TRN_INVOICE_DATA.Sum(s => s.TotalAmountWithTax);
            item.IGST   = invoiceData.GST_TRN_INVOICE_DATA.Sum(s => s.IGSTAmt);
            if (item.IGST > 0)
            {
                item.TaxType = (byte)EnumConstants.TaxType.IGST;
            }

            item.CGST = invoiceData.GST_TRN_INVOICE_DATA.Sum(s => s.CGSTAmt);
            if (item.CGST > 0)
            {
                item.TaxType = (byte)EnumConstants.TaxType.CGST;
            }

            item.SGST = invoiceData.GST_TRN_INVOICE_DATA.Sum(s => s.SGSTAmt);
            if (item.SGST > 0)
            {
                item.TaxType = (byte)EnumConstants.TaxType.SGST;
            }

            if (item.SGST.Value == 0)
            {
                item.TaxType = (byte)EnumConstants.TaxType.UTGST;
                item.SGST    = invoiceData.GST_TRN_INVOICE_DATA.Sum(s => s.UGSTAmt);
            }

            item.Cess = invoiceData.GST_TRN_INVOICE_DATA.Sum(s => s.CessAmt);

            item.InvoiceID = invoiceData.InvoiceID;
            item.ITCStatus = (byte)EnumConstants.ITCStatus.Active;
            if (invoiceData.InvoiceSpecialCondition.Value == (byte)EnumConstants.InvoiceSpecialCondition.Import || invoiceData.InvoiceSpecialCondition.Value == (byte)EnumConstants.InvoiceSpecialCondition.ReverseCharges)
            {
                //item.UserID = invoiceData.ReceiverUserID;
                // item.ITCMovement = (byte)EnumConstants.ITCMovement.Debit;
            }
            else
            {
                item.UserID = invoiceData.ReceiverUserID;
                //item.ITCMovement = (byte)EnumConstants.ITCMovement.Credit;
                //item.UserID = invoiceData.ReceiverUserID;
            }
            if (invoiceData.ParentInvoiceID.HasValue)
            {
                item.ITCParentID = null;
            }

            item.ITCMovement    = GetITCMovementReceiver(invoiceData.InvoiceSpecialCondition);
            item.ITCVoucherType = this.ITCVoucherType;
            item.ITCDate        = DateTime.Now;
            item.CreatedDate    = DateTime.Now;
            item.CreatedBy      = invoiceData.CreatedBy;
            bool isSave = false;

            //   if (invoiceData.InvoiceSpecialCondition != (byte)EnumConstants.InvoiceSpecialCondition.RegularRCM || invoiceData.InvoiceSpecialCondition.Value != (byte)EnumConstants.InvoiceSpecialCondition.JobWork)
            if (invoiceData.InvoiceSpecialCondition.Value == (byte)EnumConstants.InvoiceSpecialCondition.RegularRCM)
            {
                isSave = SaveITC(item);
            }
            else if (invoiceData.InvoiceSpecialCondition.Value == (byte)EnumConstants.InvoiceSpecialCondition.Regular)
            {
                isSave = SaveITC(item);
            }
            return(isSave);
        }
Exemplo n.º 20
0
 public B2b GetB2b(GST_TRN_INVOICE B2B)
 {
     return(new B2b {
         ctin = "tinno", inv = GetInv(B2B)
     });
 }
Exemplo n.º 21
0
 private Exp GetExpData(GST_TRN_INVOICE expdata)
 {
     return(new Exp {
         exp_typ = "Wpay", inv = GetInv3(expdata)
     });
 }
Exemplo n.º 22
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="invoice"></param>
 /// <param name="note"></param>
 /// <returns></returns>
 public bool SaveNote(GST_TRN_INVOICE invoice)
 {
     SaveNote(RefectorNote(invoice));
     return(true);
 }
Exemplo n.º 23
0
        protected void lkbUpdateInvoice_Click(object sender, EventArgs e)
        {
            try
            {
                // GridView gv = (GridView)fvInvoice.FindControl("gvItems");
                List <GST_TRN_INVOICE_DATA> items = GetGVData();
                //var it = Invoice;
                if (Invoice != null)
                {
                    GST_TRN_INVOICE inv = new GST_TRN_INVOICE();


                    inv.InvoiceDate  = DateTime.Now;
                    inv.InvoiceMonth = Convert.ToByte(DateTime.Now.Month);
                    //var totalInv=unitOfWork.InvoiceRepository.Filter(f => f.SellerUserID == Invoice.AspNetUser.Id).Count();// is
                    //var CurrentSrlNo = totalInv + 1;
                    //if (Invoice.ParentInvoiceID == null)
                    //{
                    inv.InvoiceNo = Invoice.InvoiceNo;// UniqueNoGenerate.RandomValue();//InvoiceOperation.InvoiceNo(Invoice.AspNetUser, Invoice.FinYear_ID.ToString(), CurrentSrlNo.ToString());
                    // }
                    inv.SellerUserID               = Invoice.SellerUserID;
                    inv.ReceiverUserID             = Invoice.ReceiverUserID;
                    inv.ConsigneeUserID            = Invoice.ConsigneeUserID;
                    inv.OrderDate                  = Invoice.OrderDate;
                    inv.VendorID                   = Invoice.VendorID;
                    inv.TransShipment_ID           = Invoice.TransShipment_ID;
                    inv.Freight                    = Invoice.Freight;
                    inv.Insurance                  = Invoice.Insurance;
                    inv.PackingAndForwadingCharges = Invoice.PackingAndForwadingCharges;
                    inv.ElectronicReferenceNo      = Invoice.ElectronicReferenceNo;
                    inv.ElectronicReferenceNoDate  = Invoice.ElectronicReferenceNoDate;
                    inv.InvoiceType                = Invoice.InvoiceType;
                    inv.FinYear_ID                 = Invoice.FinYear_ID;
                    inv.IsInter                    = Invoice.IsInter;
                    inv.ReceiverFinYear_ID         = Invoice.ReceiverFinYear_ID;
                    //  inv.ParentInvoiceID = Invoice.InvoiceID;
                    inv.TaxBenefitingState = Invoice.AspNetUser2.StateCode;
                    inv.Status             = true;
                    //  var invoicePeriod=unitOfWork.FinYearRepository.Find(f=>f.Fin_ID== Invoice.FinYear_ID).Finyear_Format;

                    //  GST_TRN_INVOICE updateInvoice = new GST_TRN_INVOICE();

                    inv.InvoiceStatus           = Convert.ToByte(EnumConstants.InvoiceStatus.Fresh);
                    inv.InvoiceSpecialCondition = Invoice.InvoiceSpecialCondition;
                    inv.CreatedDate             = DateTime.Now;
                    inv.UpdatedDate             = DateTime.Now;
                    inv.CreatedBy = Common.LoggedInUserID();
                    inv.UpdatedBy = Common.LoggedInUserID();
                    cls_PurchaseRegister insertPurchaseRegsiter = new cls_PurchaseRegister();
                    insertPurchaseRegsiter.LoggedinUserID = Common.LoggedInUserID();



                    //-------------End--------
                    // bool isInter =InvoiceOperation.GetConsumptionDestinationOfGoodsOrServices(Invoice.AspNetUser.StateCode, Invoice.AspNetUser2.StateCode, Invoice.AspNetUser1.StateCode);
                    bool isInter         = Invoice.IsInter.Value;
                    bool isStateExampted = unitOfWork.StateRepository.Find(f => f.StateCode == Invoice.AspNetUser2.StateCode).IsExempted.Value;
                    // bool isExport = (Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.Export || Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.SEZDeveloper || Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.SEZUnit || Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.DeemedExport);

                    bool isExported = false;
                    if (Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.Export || (byte)Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.SEZDeveloper || Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.SEZUnit || Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.DeemedExport)
                    {
                        isExported = true;
                    }
                    bool isJobwork  = (Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.JobWork);
                    bool isImport   = (Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.Import);
                    var  stateData  = unitOfWork.StateRepository.Find(c => c.StateCode == Invoice.AspNetUser.StateCode);
                    var  isUTState  = stateData.UT.Value;
                    var  isExempted = stateData.IsExempted.Value;
                    var  isEcom     = false;
                    var  isUn       = false;

                    var invLineItem = from invo in items
                                      select new GST_TRN_INVOICE_DATA
                    {
                        // InvoiceID = invoiceCreate.InvoiceID,
                        InvoiceDataID = invo.InvoiceDataID,
                        LineID        = invo.LineID,
                        // GST_MST_ITEM = invo.Item,
                        Item_ID       = invo.GST_MST_ITEM.Item_ID,
                        Qty           = invo.Qty,
                        Rate          = invo.Rate,
                        TotalAmount   = invo.TotalAmount,
                        Discount      = invo.Discount,
                        TaxableAmount = invo.TaxableAmount,
                        IGSTRate      = Calculate.TaxRate(invo.GST_MST_ITEM, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.IGST, invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.IGST.Value),              //isJobwork ? 0 : (isUTState ? 0 : (isInter ? invo.Item.IGST : (isExport ? invo.Item.IGST : (isImport ? invo.Item.IGST : 0)))),
                        IGSTAmt       = Calculate.TaxCalculate(invo.GST_MST_ITEM, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.IGST, invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.IGST.Value),         // isJobwork ? 0 : (isUTState ? 0 : (isInter ? Calculate.CalculateIGSTLineIDWise(invo.TaxableValueLineIDWise, invo.Item.IGST.Value) : (isExport ? Calculate.CalculateIGSTLineIDWise(invo.TaxableValueLineIDWise, invo.Item.IGST.Value) : (isImport ? Calculate.CalculateIGSTLineIDWise(invo.TaxableValueLineIDWise, invo.Item.IGST.Value) : 0)))),
                        CGSTRate      = Calculate.TaxRate(invo.GST_MST_ITEM, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.CGST, invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.CGST.Value),
                        CGSTAmt       = Calculate.TaxCalculate(invo.GST_MST_ITEM, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.CGST, invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.CGST.Value),
                        SGSTRate      = Calculate.TaxRate(invo.GST_MST_ITEM, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.SGST, invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.SGST.Value),
                        SGSTAmt       = Calculate.TaxCalculate(invo.GST_MST_ITEM, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.SGST, invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.SGST.Value),
                        UGSTRate      = Calculate.TaxRate(invo.GST_MST_ITEM, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.UTGST, invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.UGST.Value),
                        UGSTAmt       = Calculate.TaxCalculate(invo.GST_MST_ITEM, isInter, isExported, isImport, isUTState, isJobwork, isEcom, isUn, EnumConstants.TaxType.UTGST, invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.UGST.Value),
                        CessRate      = isJobwork ? 0 : invo.GST_MST_ITEM.CESS,
                        CessAmt       = isJobwork ? 0 : Calculate.CalculateCESSLineIDWise(invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.CESS.Value)
                                        //TotalAmountWithTax = invo.TaxableAmount + IGSTAmt,
                    };

                    bool invoiceHasParent = Invoice.ParentInvoiceID != null ? true : false;

                    if (!invoiceHasParent)
                    {
                        //Update old invoice status that is A or M---------------Start-------------
                        if (Invoice.InvoiceMonth == (byte)DateTime.Now.Month)
                        {
                            var oldInvoice = unitOfWork.InvoiceRepository.Find(f => f.InvoiceID == Invoice.InvoiceID);
                            oldInvoice.InvoiceStatus = Convert.ToByte(EnumConstants.InvoiceStatus.Amended);
                            // Invoice.InvoiceID = updateInvoice.InvoiceID;
                            var invoiceUpdate = unitOfWork.InvoiceRepository.Update(oldInvoice);
                            unitOfWork.Save();
                        }
                        else
                        {
                            var oldInvoice = unitOfWork.InvoiceRepository.Find(f => f.InvoiceID == Invoice.InvoiceID);
                            oldInvoice.InvoiceStatus = Convert.ToByte(EnumConstants.InvoiceStatus.Modified);
                            //  updateInvoice.InvoiceID = updateInvoice.InvoiceID;
                            var invoiceUpdate = unitOfWork.InvoiceRepository.Update(oldInvoice);
                            unitOfWork.Save();
                        }

                        inv.ParentInvoiceID = Invoice.InvoiceID;
                        var invoiceCreate = unitOfWork.InvoiceRepository.Create(inv);
                        unitOfWork.Save();
                        foreach (GST_TRN_INVOICE_DATA item in invLineItem)
                        {
                            item.InvoiceID          = invoiceCreate.InvoiceID;
                            item.TotalAmountWithTax = item.TaxableAmount + item.IGSTAmt + item.CGSTAmt + item.SGSTAmt + item.UGSTAmt + item.CessAmt;
                            unitOfWork.InvoiceDataRepository.Create(item);
                        }
                        unitOfWork.Save();
                        invoiceItem.AutoCorrectInvoice(invoiceCreate.InvoiceID);


                        bool isSave = insertPurchaseRegsiter.UpdatePurchaseDataItemFromInvoice(inv);

                        GST_TRN_INVOICE_AUDIT_TRAIL auditStatus = new GST_TRN_INVOICE_AUDIT_TRAIL();
                        auditStatus.InvoiceID                 = invoiceCreate.InvoiceID;
                        auditStatus.AuditTrailStatus          = (byte)EnumConstants.InvoiceAuditTrailSatus.Import2A;
                        auditStatus.InvoiceAction             = (byte)EnumConstants.InvoiceActionAuditTrail.Modify;
                        auditStatus.ReceiverInvoiceAction     = (byte)EnumConstants.InvoiceActionAuditTrail.Modify;
                        auditStatus.ReceiverInvoiceActionDate = DateTime.Now;                        //
                        auditStatus.CreatedDate               = DateTime.Now;
                        auditStatus.CreatedBy                 = Common.LoggedInUserID();
                        unitOfWork.InvoiceAuditTrailRepositry.Create(auditStatus);
                        unitOfWork.Save();
                    }
                    else
                    {
                        foreach (GST_TRN_INVOICE_DATA item in invLineItem)
                        {
                            //  item.InvoiceDataID = invp

                            item.InvoiceID          = Invoice.InvoiceID;
                            item.TotalAmountWithTax = item.TaxableAmount + item.IGSTAmt + item.CGSTAmt + item.SGSTAmt + item.UGSTAmt + item.CessAmt;
                            item.CreatedDate        = DateTime.Now;
                            unitOfWork.InvoiceDataRepository.Update(item);
                        }
                        unitOfWork.Save();
                        invoiceItem.AutoCorrectInvoice(Invoice.InvoiceID);

                        bool isSave = insertPurchaseRegsiter.UpdatePurchaseDataItemFromInvoice(Invoice);
                    }

                    gvInvoice_Items.DataSource = null;
                    gvInvoice_Items.DataBind();
                    lkbUpdateInvoice.Visible = false;
                    Invoice = new GST_TRN_INVOICE();
                    uc_sucess.SuccessMessage = "Data updated successfully.";
                    if (!string.IsNullOrEmpty(EditFrom))
                    {
                        if (EditFrom == "GSTR2")
                        {
                            cls_ITC itc = new cls_ITC();
                            itc.ITCVoucherType = (byte)EnumConstants.ITCVoucherType.Purchase;
                            itc.SaveItcReceiver(inv);
                        }
                    }
                    UpdateInvoiceClick(sender, e);
                }
            }

            catch (Exception ex)
            {
                cls_ErrorLog ob = new cls_ErrorLog();
                cls_ErrorLog.LogError(ex, Common.LoggedInUserID());
            }
        }
Exemplo n.º 24
0
        private GST_TRN_INVOICE GetInvoiceInformation(DataRow dataRow, string SupplierGSTIN, byte sheetCode, string UserId)
        {
            GST_TRN_INVOICE invoice = new GST_TRN_INVOICE();

            try
            {
                cls_Invoice invoiceObject = new cls_Invoice();
                //B2B
                if (sheetCode == 0)
                {
                    var RecieverGSTIN = dataRow.Field <string>("Column0");
                    var GstnExit      = unitOfWork.AspnetRepository.Filter(w => w.GSTNNo == RecieverGSTIN).FirstOrDefault();
                    invoice.InvoiceNo      = dataRow.ItemArray[1].ToString().Contains('.') ? dataRow.ItemArray[1].ToString().Split('.')[0] : dataRow.ItemArray[1].ToString();
                    invoice.InvoiceDate    = dataRow.Field <DateTime>("Column2");
                    invoice.InvoiceMonth   = (byte)invoice.InvoiceDate.Value.Month;
                    invoice.SellerUserID   = FindUserId(SupplierGSTIN);
                    invoice.ReceiverUserID = FindUserId(dataRow.Field <string>("Column0"));
                    var ConsigneeUserId = FindUserId(dataRow.Field <string>("Column7"));
                    invoice.ConsigneeUserID = ConsigneeUserId == null ? invoice.ReceiverUserID : ConsigneeUserId;
                    invoice.OrderDate       = dataRow.Field <DateTime>("Column2").Date;
                    //invoice.VendorID =
                    invoice.Freight   = Convert.ToInt32(dataRow.ItemArray[13].ToString().Split('.')[0]);
                    invoice.Insurance = Convert.ToInt32(dataRow.ItemArray[14].ToString().Split('.')[0]);
                    invoice.PackingAndForwadingCharges = Convert.ToInt32(dataRow.ItemArray[15].ToString().Split('.')[0]);
                    //invoice.   =
                    //invoice.ElectronicReferenceNoDate =
                    invoice.InvoiceType = sheetCode;
                    invoice.FinYear_ID  = invoiceObject.GetCurrentFinYear();
                    string getIsinter   = GstnExit == null ? "" : GstnExit.GSTNNo;
                    string strStatecode = getIsinter.Substring(0, 2);
                    string Statecod     = GstnExit == null ? "" : GstnExit.StateCode;
                    if (strStatecode == Statecod)
                    {
                        invoice.IsInter = false;
                    }
                    else
                    {
                        invoice.IsInter = true;
                    }
                    invoice.InvoiceStatus = Convert.ToByte(EnumConstants.InvoiceStatus.Fresh);
                    // invoice.TaxBenefitingState =
                    invoice.Status = true;
                    EnumConstants.InvoiceSpecialCondition value = (EnumConstants.InvoiceSpecialCondition)Enum.Parse(typeof(EnumConstants.InvoiceSpecialCondition), dataRow.ItemArray[6].ToString());
                    invoice.InvoiceSpecialCondition = (byte)value;
                }
                //B2CL
                else if (sheetCode == 1)
                {
                    var RecieverGSTIN = dataRow.ItemArray[14].ToString().Contains('.') ? dataRow.ItemArray[14].ToString().Split('.')[0] : dataRow.ItemArray[14].ToString();
                    var GstnExit      = unitOfWork.AspnetRepository.Filter(w => w.GSTNNo == RecieverGSTIN).FirstOrDefault();
                    invoice.InvoiceNo      = dataRow.ItemArray[0].ToString().Contains('.') ? dataRow.ItemArray[0].ToString().Split('.')[0] : dataRow.ItemArray[0].ToString();
                    invoice.InvoiceDate    = dataRow.Field <DateTime>("Column1");
                    invoice.InvoiceMonth   = (byte)invoice.InvoiceDate.Value.Month;
                    invoice.SellerUserID   = FindUserId(SupplierGSTIN);
                    invoice.ReceiverUserID = FindUserId(RecieverGSTIN);
                    var ConsigneeUserId = FindUserId(dataRow.Field <string>("Column7"));
                    invoice.ConsigneeUserID            = ConsigneeUserId == null ? invoice.ReceiverUserID : ConsigneeUserId;
                    invoice.Freight                    = Convert.ToInt32(dataRow.ItemArray[10].ToString().Split('.')[0]);
                    invoice.Insurance                  = Convert.ToInt32(dataRow.ItemArray[11].ToString().Split('.')[0]);
                    invoice.PackingAndForwadingCharges = Convert.ToInt32(dataRow.ItemArray[12].ToString().Split('.')[0]);
                    invoice.InvoiceType                = sheetCode;
                    invoice.FinYear_ID                 = invoiceObject.GetCurrentFinYear();
                    string getIsinter   = GstnExit == null ? "" : GstnExit.GSTNNo;
                    string strStatecode = getIsinter.Substring(0, 2);
                    string Statecod     = GstnExit == null ? "" : GstnExit.StateCode;
                    if (strStatecode == Statecod)
                    {
                        invoice.IsInter = false;
                    }
                    else
                    {
                        invoice.IsInter = true;
                    }
                    invoice.InvoiceStatus = Convert.ToByte(EnumConstants.InvoiceStatus.Fresh);
                    invoice.Status        = true;
                    EnumConstants.InvoiceSpecialCondition value = (EnumConstants.InvoiceSpecialCondition)Enum.Parse(typeof(EnumConstants.InvoiceSpecialCondition), dataRow.ItemArray[6].ToString());
                    invoice.InvoiceSpecialCondition = (byte)value;
                }
                //B2CS
                else if (sheetCode == 2)
                {
                    var RecieverGSTIN = dataRow.ItemArray[12].ToString().Contains('.') ? dataRow.ItemArray[12].ToString().Split('.')[0] : dataRow.ItemArray[12].ToString();
                    var GstnExit      = unitOfWork.AspnetRepository.Filter(w => w.GSTNNo == RecieverGSTIN).FirstOrDefault();
                    invoice.InvoiceNo      = dataRow.ItemArray[0].ToString().Contains('.') ? dataRow.ItemArray[0].ToString().Split('.')[0] : dataRow.ItemArray[0].ToString();
                    invoice.SellerUserID   = FindUserId(SupplierGSTIN);
                    invoice.ReceiverUserID = FindUserId(RecieverGSTIN);
                    var ConsigneeUserId = FindUserId(dataRow.Field <string>("Column5"));
                    invoice.ConsigneeUserID            = ConsigneeUserId == null ? invoice.ReceiverUserID : ConsigneeUserId;
                    invoice.Freight                    = Convert.ToInt32(dataRow.ItemArray[8].ToString().Split('.')[0]);
                    invoice.Insurance                  = Convert.ToInt32(dataRow.ItemArray[9].ToString().Split('.')[0]);
                    invoice.PackingAndForwadingCharges = Convert.ToInt32(dataRow.ItemArray[10].ToString().Split('.')[0]);
                    invoice.InvoiceType                = 1;
                    invoice.FinYear_ID                 = invoiceObject.GetCurrentFinYear();
                    string getIsinter   = GstnExit == null ? "" : GstnExit.GSTNNo;
                    string strStatecode = getIsinter.Substring(0, 2);
                    string Statecod     = GstnExit == null ? "" : GstnExit.StateCode;
                    if (strStatecode == Statecod)
                    {
                        invoice.IsInter = false;
                    }
                    else
                    {
                        invoice.IsInter = true;
                    }
                    invoice.InvoiceStatus = Convert.ToByte(EnumConstants.InvoiceStatus.Fresh);
                    invoice.Status        = true;
                    EnumConstants.InvoiceSpecialCondition value = (EnumConstants.InvoiceSpecialCondition)Enum.Parse(typeof(EnumConstants.InvoiceSpecialCondition), dataRow.ItemArray[6].ToString());
                    invoice.InvoiceSpecialCondition = (byte)value;
                }
                //CDNR
                else if (sheetCode == 3)
                {
                    var RecieverGSTIN = dataRow.Field <string>("Column0");
                    var GstnExit      = unitOfWork.AspnetRepository.Filter(w => w.GSTNNo == RecieverGSTIN).FirstOrDefault();
                    invoice.InvoiceNo                  = dataRow.ItemArray[1].ToString().Contains('.') ? dataRow.ItemArray[1].ToString().Split('.')[0] : dataRow.ItemArray[1].ToString();
                    invoice.InvoiceDate                = dataRow.Field <DateTime>("Column4");
                    invoice.InvoiceMonth               = (byte)invoice.InvoiceDate.Value.Month;
                    invoice.SellerUserID               = FindUserId(SupplierGSTIN);
                    invoice.ReceiverUserID             = FindUserId(dataRow.Field <string>("Column0"));
                    invoice.OrderDate                  = dataRow.Field <DateTime>("Column2").Date;
                    invoice.Freight                    = Convert.ToInt32(dataRow.ItemArray[14].ToString().Split('.')[0]);
                    invoice.Insurance                  = Convert.ToInt32(dataRow.ItemArray[15].ToString().Split('.')[0]);
                    invoice.PackingAndForwadingCharges = Convert.ToInt32(dataRow.ItemArray[16].ToString().Split('.')[0]);
                    invoice.FinYear_ID                 = invoiceObject.GetCurrentFinYear();
                    string getIsinter   = GstnExit == null ? "" : GstnExit.GSTNNo;
                    string strStatecode = getIsinter.Substring(0, 2);
                    string Statecod     = GstnExit == null ? "" : GstnExit.StateCode;
                    if (strStatecode == Statecod)
                    {
                        invoice.IsInter = false;
                    }
                    else
                    {
                        invoice.IsInter = true;
                    }
                    invoice.InvoiceStatus = Convert.ToByte(EnumConstants.InvoiceStatus.Fresh);
                    invoice.Status        = true;
                }
                //CDNUR
                else if (sheetCode == 4)
                {
                    var RecieverGSTIN = dataRow.ItemArray[19].ToString();
                    var GstnExit      = unitOfWork.AspnetRepository.Filter(w => w.GSTNNo == RecieverGSTIN).FirstOrDefault();
                    invoice.InvoiceNo                  = dataRow.ItemArray[4].ToString().Contains('.') ? dataRow.ItemArray[4].ToString().Split('.')[0] : dataRow.ItemArray[4].ToString();
                    invoice.InvoiceDate                = dataRow.Field <DateTime>("Column5");
                    invoice.InvoiceMonth               = (byte)invoice.InvoiceDate.Value.Month;
                    invoice.SellerUserID               = FindUserId(SupplierGSTIN);
                    invoice.ReceiverUserID             = FindUserId(dataRow.ItemArray[19].ToString());
                    invoice.OrderDate                  = dataRow.Field <DateTime>("Column2").Date;
                    invoice.Freight                    = Convert.ToInt32(dataRow.ItemArray[14].ToString().Split('.')[0]);
                    invoice.Insurance                  = Convert.ToInt32(dataRow.ItemArray[15].ToString().Split('.')[0]);
                    invoice.PackingAndForwadingCharges = Convert.ToInt32(dataRow.ItemArray[16].ToString().Split('.')[0]);
                    invoice.FinYear_ID                 = invoiceObject.GetCurrentFinYear();
                    string getIsinter   = GstnExit == null ? "" : GstnExit.GSTNNo;
                    string strStatecode = getIsinter.Substring(0, 2);
                    string Statecod     = GstnExit == null ? "" : GstnExit.StateCode;
                    if (strStatecode == Statecod)
                    {
                        invoice.IsInter = false;
                    }
                    else
                    {
                        invoice.IsInter = true;
                    }
                    invoice.InvoiceStatus = Convert.ToByte(EnumConstants.InvoiceStatus.Fresh);
                    invoice.Status        = true;
                    EnumConstants.InvoiceSpecialCondition value = (EnumConstants.InvoiceSpecialCondition)Enum.Parse(typeof(EnumConstants.InvoiceSpecialCondition), dataRow.ItemArray[1].ToString());
                    invoice.InvoiceSpecialCondition = (byte)value;
                }
                //EXP
                else if (sheetCode == 5)
                {
                    var RecieverGSTIN = dataRow.ItemArray[8].ToString().Contains('.') ? dataRow.ItemArray[8].ToString().Split('.')[0] : dataRow.ItemArray[8].ToString();
                    var GstnExit      = unitOfWork.AspnetRepository.Filter(w => w.GSTNNo == RecieverGSTIN).FirstOrDefault();
                    invoice.InvoiceNo      = dataRow.ItemArray[1].ToString().Contains('.') ? dataRow.ItemArray[1].ToString().Split('.')[0] : dataRow.ItemArray[1].ToString();
                    invoice.InvoiceDate    = dataRow.Field <DateTime>("Column2");
                    invoice.InvoiceMonth   = (byte)invoice.InvoiceDate.Value.Month;
                    invoice.SellerUserID   = FindUserId(SupplierGSTIN);
                    invoice.ReceiverUserID = FindUserId(RecieverGSTIN);
                    invoice.OrderDate      = dataRow.Field <DateTime>("Column2").Date;
                    //invoice.VendorID =
                    //invoice.Freight = Convert.ToInt32(dataRow.ItemArray[14].ToString().Split('.')[0]);
                    //invoice.Insurance = Convert.ToInt32(dataRow.ItemArray[15].ToString().Split('.')[0]);
                    //invoice.PackingAndForwadingCharges = Convert.ToInt32(dataRow.ItemArray[16].ToString().Split('.')[0]);
                    ////invoice.   =
                    //invoice.ElectronicReferenceNoDate =
                    invoice.InvoiceType = 0;
                    invoice.FinYear_ID  = invoiceObject.GetCurrentFinYear();
                    string getIsinter   = GstnExit == null ? "" : GstnExit.GSTNNo;
                    string strStatecode = getIsinter.Substring(0, 2);
                    string Statecod     = GstnExit == null ? "" : GstnExit.StateCode;
                    if (strStatecode == Statecod)
                    {
                        invoice.IsInter = false;
                    }
                    else
                    {
                        invoice.IsInter = true;
                    }
                    invoice.InvoiceStatus = Convert.ToByte(EnumConstants.InvoiceStatus.Fresh);
                    // invoice.TaxBenefitingState =
                    invoice.Status = true;
                    EnumConstants.InvoiceSpecialCondition value = (EnumConstants.InvoiceSpecialCondition)Enum.Parse(typeof(EnumConstants.InvoiceSpecialCondition), dataRow.ItemArray[1].ToString());
                    invoice.InvoiceSpecialCondition = (byte)value;
                }
                invoice.CreatedBy   = UserId;
                invoice.CreatedDate = DateTime.Now;
                unitOfWork.InvoiceRepository.Create(invoice);
                unitOfWork.Save();
            }


            catch (DbEntityValidationException ex)
            {
                foreach (var eve in ex.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
            }
            return(invoice);
        }
Exemplo n.º 25
0
        protected void lkbUpdateInvoice_Click(object sender, EventArgs e)
        {
            try
            {
                // GridView gv = (GridView)fvInvoice.FindControl("gvItems");
                List <GST_TRN_INVOICE_DATA> items = GetGVData();
                //var it = Invoice;
                if (Invoice != null)
                {
                    //Seller seller = new Seller();


                    GST_TRN_INVOICE inv = new GST_TRN_INVOICE();
                    inv.InvoiceDate  = DateTime.Now;
                    inv.InvoiceMonth = Convert.ToByte(DateTime.Now.Month);
                    var CurrentSrlNo = unitOfWork.InvoiceRepository.Filter(f => f.SellerUserID == Invoice.AspNetUser.Id).Count() + 1;
                    inv.InvoiceNo                  = InvoiceOperation.InvoiceNo(Invoice.AspNetUser, Invoice.FinYear_ID.ToString(), CurrentSrlNo.ToString());
                    inv.SellerUserID               = Invoice.SellerUserID;
                    inv.ReceiverUserID             = Invoice.ReceiverUserID;
                    inv.ConsigneeUserID            = Invoice.ConsigneeUserID;
                    inv.OrderDate                  = Invoice.OrderDate;
                    inv.VendorID                   = Invoice.VendorID;
                    inv.TransShipment_ID           = Invoice.TransShipment_ID;
                    inv.Freight                    = Invoice.Freight;
                    inv.Insurance                  = Invoice.Insurance;
                    inv.PackingAndForwadingCharges = Invoice.PackingAndForwadingCharges;
                    inv.ElectronicReferenceNo      = Invoice.ElectronicReferenceNo;
                    inv.ElectronicReferenceNoDate  = Invoice.ElectronicReferenceNoDate;
                    inv.InvoiceType                = Invoice.InvoiceType;
                    inv.FinYear_ID                 = Invoice.FinYear_ID;
                    inv.IsInter                    = Invoice.IsInter;
                    inv.ReceiverFinYear_ID         = Invoice.ReceiverFinYear_ID;
                    inv.ParentInvoiceID            = Invoice.InvoiceID;
                    inv.TaxBenefitingState         = Invoice.AspNetUser2.StateCode;
                    inv.Status = true;
                    //  var invoicePeriod=unitOfWork.FinYearRepository.Find(f=>f.Fin_ID== Invoice.FinYear_ID).Finyear_Format;

                    //  GST_TRN_INVOICE updateInvoice = new GST_TRN_INVOICE();

                    inv.InvoiceStatus           = Convert.ToByte(EnumConstants.InvoiceStatus.Fresh);
                    inv.InvoiceSpecialCondition = Invoice.InvoiceSpecialCondition;
                    inv.CreatedDate             = DateTime.Now;
                    inv.UpdatedDate             = DateTime.Now;
                    inv.CreatedBy = Common.LoggedInUserID();
                    inv.UpdatedBy = Common.LoggedInUserID();

                    var invoiceCreate = unitOfWork.InvoiceRepository.Create(inv);
                    unitOfWork.Save();
                    //Update old invoice status that is A or M---------------Start-------------
                    if (Invoice.InvoiceMonth == (byte)DateTime.Now.Month)
                    {
                        var oldInvoice = unitOfWork.InvoiceRepository.Find(f => f.InvoiceID == Invoice.InvoiceID);
                        oldInvoice.InvoiceStatus = Convert.ToByte(EnumConstants.InvoiceStatus.Amended);
                        // Invoice.InvoiceID = updateInvoice.InvoiceID;
                        var invoiceUpdate = unitOfWork.InvoiceRepository.Update(oldInvoice);
                        unitOfWork.Save();
                    }
                    else
                    {
                        var oldInvoice = unitOfWork.InvoiceRepository.Find(f => f.InvoiceID == Invoice.InvoiceID);
                        oldInvoice.InvoiceStatus = Convert.ToByte(EnumConstants.InvoiceStatus.Modified);
                        //  updateInvoice.InvoiceID = updateInvoice.InvoiceID;
                        var invoiceUpdate = unitOfWork.InvoiceRepository.Update(oldInvoice);
                        unitOfWork.Save();
                    }
                    //-------------End--------
                    // bool isInter =InvoiceOperation.GetConsumptionDestinationOfGoodsOrServices(Invoice.AspNetUser.StateCode, Invoice.AspNetUser2.StateCode, Invoice.AspNetUser1.StateCode);
                    bool isInter         = Invoice.IsInter.Value;
                    bool isStateExampted = unitOfWork.StateRepository.Find(f => f.StateCode == Invoice.AspNetUser2.StateCode).IsExempted.Value;
                    bool isExport        = (Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.Export || Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.SEZDeveloper || Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.SEZUnit || Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.DeemedExport);
                    bool isJobwork       = (Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.JobWork);
                    bool isImport        = (Invoice.InvoiceSpecialCondition == (byte)EnumConstants.InvoiceSpecialCondition.Import);
                    var  stateData       = unitOfWork.StateRepository.Find(c => c.StateCode == Invoice.AspNetUser.StateCode);
                    var  isUTState       = stateData.UT.Value;
                    var  isExempted      = stateData.IsExempted.Value;

                    var invLineItem = from invo in items
                                      select new GST_TRN_INVOICE_DATA
                    {
                        InvoiceID = invoiceCreate.InvoiceID,
                        LineID    = invo.LineID,
                        // GST_MST_ITEM = invo.Item,
                        Item_ID       = invo.GST_MST_ITEM.Item_ID,
                        Qty           = invo.Qty,
                        Rate          = invo.Rate,
                        TotalAmount   = invo.TotalAmount,
                        Discount      = invo.Discount,
                        TaxableAmount = invo.TaxableAmount,
                        IGSTRate      = isJobwork ? 0 : (isUTState ? 0 : (isInter ? 0 : (isExport ? invo.GST_MST_ITEM.IGST : (isImport ? invo.GST_MST_ITEM.IGST : 0)))),
                        IGSTAmt       = isJobwork ? 0 : (isUTState ? 0 : (isInter ? 0 : (isExport ? Calculate.CalculateIGSTLineIDWise(invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.IGST.Value) : (isImport ? Calculate.CalculateIGSTLineIDWise(invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.IGST.Value) : 0)))),
                        CGSTRate      = isJobwork ? 0 : (isUTState ? 0 : (isInter ? (isExport ? 0 : invo.GST_MST_ITEM.CGST) : 0)),
                        CGSTAmt       = isJobwork ? 0 : (isUTState ? 0 : (isInter ? (isExport ? 0 : Calculate.CalculateCGSTLineIDWise(invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.CGST.Value)) : 0)),
                        SGSTRate      = isJobwork ? 0 : (isUTState ? 0 : (isInter ? 0 : (isExport ? 0 : invo.GST_MST_ITEM.SGST))),
                        SGSTAmt       = isJobwork ? 0 : (isUTState ? 0 : (isInter ? 0 : (isExport ? 0 : Calculate.CalculateSGSTLineIDWise(invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.SGST.Value)))),
                        UGSTRate      = isJobwork ? 0 : (isExport ? 0 : (isUTState ? invo.GST_MST_ITEM.UGST.Value : 0)),
                        UGSTAmt       = isJobwork ? 0 : (isExport ? 0 : (isUTState ? Calculate.CalculateUGSTLineIDWise(invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.UGST.Value) : 0)),
                        CessRate      = isJobwork ? 0 : invo.GST_MST_ITEM.CESS,
                        CessAmt       = isJobwork ? 0 : Calculate.CalculateCESSLineIDWise(invo.TaxableAmount.HasValue ? invo.TaxableAmount.Value : 0, invo.GST_MST_ITEM.CESS.Value)
                                        //TotalAmountWithTax = invo.TaxableAmount + IGSTAmt,
                    };


                    foreach (GST_TRN_INVOICE_DATA item in invLineItem)
                    {
                        item.TotalAmountWithTax = item.TaxableAmount + item.IGSTAmt + item.CGSTAmt + item.SGSTAmt + item.UGSTAmt + item.CessAmt;

                        unitOfWork.InvoiceDataRepository.Create(item);
                    }
                    unitOfWork.Save();
                    gvInvoice_Items.DataSource = null;
                    gvInvoice_Items.DataBind();
                    lkbUpdateInvoice.Visible = false;
                    Invoice = new GST_TRN_INVOICE();
                    this.Master.SuccessMessage = "Data updated successfully.";
                    //uc_sucess.Visible = true;
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "viewInvoiceModelSucessMessage", "$('#viewInvoiceModelSucessMessage').modal();", true);
                }
            }

            catch (Exception ex) { }
        }
Exemplo n.º 26
0
 private void BindInvoice(GST_TRN_INVOICE invoice)
 {
     gvInvoice_Edit.DataSource = invoice.GST_TRN_INVOICE_DATA;
     gvInvoice_Edit.DataBind();
 }