示例#1
0
        public string setInvoiceHeader(M_InvoiceData req)
        {
            //   InvoiceDetailSaving Check = new InvoiceDetailSaving();

            string RequestId = req.RequestId;

            try
            {
                string InvoiceNo = string.Empty;

                using (DBLinqDataContext dbContext = new DBLinqDataContext())
                {
                    dbContext.Connection.ConnectionString = Connection_;
                    dbContext.Connection.Open();

                    try
                    {
                        if (req.GrossTotal != 0)
                        {
                            dbContext.Transaction = dbContext.Connection.BeginTransaction();
                            B_RecordSequence seqmanager = new B_RecordSequence();
                            Int64            RequestNo  = seqmanager.getNextSequence("InvoiceNo", dbContext);

                            InvoiceNo = "STM" + DateTime.Now.ToString("yy") + String.Format("{0:D9}", RequestNo);
                            dbContext._setInvoiceHeader(InvoiceNo,
                                                        req.CustomerId,
                                                        req.StartDate,
                                                        req.EndDate,
                                                        req.GrossTotal,
                                                        req.InvoiceTotal,
                                                        req.IsTaxInvoice,
                                                        req.Createdby,
                                                        req.PrintCount);

                            dbContext.SubmitChanges();
                            dbContext.Transaction.Commit();
                        }
                    }
                    catch (Exception ex)
                    {
                        dbContext.Transaction.Rollback();
                        ErrorLog.LogError(ex);
                    }

                    return(InvoiceNo);
                }
            }
            catch (Exception ex)
            {
                ErrorLog.LogError(ex);
                return(string.Empty);
            }
        }
示例#2
0
 public bool setInvoiceDetails(M_InvoiceData req)
 {
     try
     {
         DBLinqDataContext datacontext = new DBLinqDataContext();
         datacontext.Connection.ConnectionString = Connection_;
         datacontext._setInvoiceDetails(req.RequestId, req.Rate, req.Createdby, req.invoiceNo);
         return(true);
     }
     catch (Exception ex)
     {
         ErrorLog.LogError(ex);
         return(false);
     }
 }
示例#3
0
        //For Invoice Genaration
        public List <M_SupportDocument> getSuuportingDocumentApproval(M_InvoiceData M)
        {
            try
            {
                List <M_SupportDocument> DocList = new List <M_SupportDocument>();
                using (DBLinqDataContext datacontext = new DBLinqDataContext())
                {
                    datacontext.Connection.ConnectionString = Connection_;
                    System.Data.Linq.ISingleResult <_getSuppotingDocumentPeriodicDetailResult> lst = datacontext._getSuppotingDocumentPeriodicDetail(M.CustomerId,
                                                                                                                                                     M.SupportingDocStatus,
                                                                                                                                                     M.Start.ToString(),
                                                                                                                                                     M.End.ToString(),
                                                                                                                                                     M.InvoiceRateId,
                                                                                                                                                     M.OtherRateId,
                                                                                                                                                     M.SupDocInvoiceRateId,
                                                                                                                                                     M.SupDocOtherRateId,
                                                                                                                                                     M.AttachSheetId);
                    foreach (_getSuppotingDocumentPeriodicDetailResult result in lst)
                    {
                        M_SupportDocument SRH = new M_SupportDocument();
                        SRH.Request_ID              = result.RequestID;
                        SRH.SupportingDocument_Id   = result.SupportingDocID;
                        SRH.SupportingDocument_Name = result.UploadDocName;
                        SRH.Rate_Id = result.RatesId;
                        SRH.Rate_   = result.Rates;


                        DocList.Add(SRH);
                    }
                }
                return(DocList);
            }
            catch (Exception ex)
            {
                ErrorLog.LogError(ex);
                return(null);
            }
        }
示例#4
0
        public ActionResult GenarateInvoice(DateTime S, DateTime E, string C)
        {
            /*Start get data for Calculate And Insert to invoice Header for get Invoice No*/
            String Start = S.ToString("yyyyMMdd");
            String End   = E.ToString("yyyyMMdd");
            /*end make date for corrct format*/

            String Certi_Status  = "A";//Certificate Status
            String SDoc_Status   = "A";
            String AttachSheetId = System.Configuration.ConfigurationManager.AppSettings["AttachedSheetId"];

            String CertificateRateId       = System.Configuration.ConfigurationManager.AppSettings["CertificateRateId"];       //get Certificate Rate Id from Web Config
            String SupDocCertificateRateId = System.Configuration.ConfigurationManager.AppSettings["SupDocCertificateRateId"]; //get Certificate Rate Id from Web Config

            String InvoiceRateId        = System.Configuration.ConfigurationManager.AppSettings["InvoiceRateId"];              //get Invoice Rate Id
            String OtherRateId          = System.Configuration.ConfigurationManager.AppSettings["OtherRateId"];                //get Other Rate Id
            String SupDocOtherRateId    = System.Configuration.ConfigurationManager.AppSettings["SupdocOtherRateId"];          //get Supprting Document Id for Other Rate
            String SupsDocInvoiceRateId = System.Configuration.ConfigurationManager.AppSettings["SupdocInvoiceRateId"];        //get Supporting Document id For Invoice Rate

            String VATCode = System.Configuration.ConfigurationManager.AppSettings["VatCode"];

            M_InvoiceData Invo_data = new M_InvoiceData();

            Invo_data.CustomerId          = C;
            Invo_data.Start               = Start;
            Invo_data.End                 = End;
            Invo_data.InvoiceRateId       = InvoiceRateId;
            Invo_data.OtherRateId         = OtherRateId;
            Invo_data.SupDocInvoiceRateId = SupsDocInvoiceRateId;
            Invo_data.SupDocOtherRateId   = SupDocOtherRateId;
            Invo_data.AttachSheetId       = AttachSheetId;
            Invo_data.SupportingDocStatus = SDoc_Status;
            Invo_data.StartDate           = S;
            Invo_data.EndDate             = E;

            decimal Cost_Certificate = 0;
            decimal Cost_SupprotDoc  = 0;
            decimal BeforTax_Total   = 0;
            /*start get Certificate Data*/
            decimal TaxCount       = 0;
            decimal AfterTax_Total = 0;
            string  Is_SVat        = string.Empty;

            string checkTaxInvoice = "N";

            foreach (var requst in objInv.getInvoiceDetail_Certs(Certi_Status, Start, End, C, CertificateRateId))
            {
                Cost_Certificate += requst.Rate_; // Calculate Certificate cost befor tax
                Is_SVat           = requst.Is_SVAT;
            }
            /*start get Suporting Document Data*/
            foreach (var supporting in objSDApp.getSuuportingDocumentApproval(Invo_data))
            {
                Cost_SupprotDoc += supporting.Rate_;
            }

            BeforTax_Total       = Cost_Certificate + Cost_SupprotDoc;//get gross total=Total Certificate value+total Supproting Document Value
            AfterTax_Total       = BeforTax_Total;
            Invo_data.GrossTotal = BeforTax_Total;

            if (Is_SVat.Equals("Y"))
            {
                foreach (var money in objInv.getTaxDetails("Y", "Y"))
                {
                    decimal presentage = money.RateValue;
                    TaxCount        = presentage * AfterTax_Total / 100;
                    AfterTax_Total += TaxCount;
                    checkTaxInvoice = "Y";
                }
            }
            else
            {
                foreach (var money in objInv.getTaxDetails("Y", VATCode))
                {
                    decimal presentage = money.RateValue;
                    TaxCount        = presentage * AfterTax_Total / 100;
                    AfterTax_Total += TaxCount;
                    checkTaxInvoice = "Y";
                }
            }

            Invo_data.InvoiceTotal = AfterTax_Total;
            Invo_data.IsTaxInvoice = checkTaxInvoice;
            Invo_data.PrintCount   = 0;
            Invo_data.Createdby    = "Admin";
            string Invoice_No = objInv.setInvoiceHeader(Invo_data);
            /*end get Suporting Document Data*/

            M_InvoiceData objInde = new M_InvoiceData();

            /*start set Value for Invoice detail Table*/
            foreach (var requst in objInv.getInvoiceDetail_Certs(Certi_Status, Start, End, Invo_data.CustomerId, CertificateRateId))
            {
                /*---------------insert value to detail table------------------*/
                objInde.RequestId = requst.Request_Id;
                objInde.invoiceNo = Invoice_No;
                objInde.Rate      = requst.Rate_;
                objInde.Createdby = "Admin";
                objInv.setInvoiceDetails(objInde);
            }
            /*end set Value for Invoice detail Table*/

            foreach (var supporting in objSDApp.getSuuportingDocumentApproval(Invo_data))
            {
                string RateId = supporting.Rate_Id;
                // string SuportingId = supporting.SupportingDocument_Id;

                M_SupportDocument CRH = new M_SupportDocument();
                CRH.ClientID_  = Invo_data.CustomerId;
                CRH.Invoice_No = Invoice_No;
                CRH.Request_ID = supporting.Request_ID;
                CRH.Rate_Id    = RateId;
                CRH.Rate_      = supporting.Rate_;
                CRH.Created_By = "Admin";

                objInv.setInvoiceRate(CRH);
                /*end to set Invoice rate Table*/
            }

            decimal TaxCounts = 0;
            decimal NetTotal  = BeforTax_Total;

            if (Is_SVat.Equals("Y"))
            {
                foreach (var money in objInv.getTaxDetails("Y", "Y"))
                {
                    /*---------------------insert value to invoice tax------------------*/

                    decimal presentage = money.RateValue;

                    TaxCounts = presentage * BeforTax_Total / 100;
                    NetTotal  = NetTotal + TaxCounts;

                    M_TaxNRates taxdeta = new M_TaxNRates();

                    taxdeta.InvoiceId     = Invoice_No;
                    taxdeta.RateID        = money.RateID;
                    taxdeta.RateValue     = TaxCounts;
                    taxdeta.CreatedBy     = "Admin";
                    taxdeta.TaxPresentage = presentage;

                    objInv.setInvoiceTaxDetails(taxdeta);
                }
            }
            else
            {
                foreach (var money in objInv.getTaxDetails("Y", VATCode))
                {
                    /*---------------------insert value to invoice tax------------------*/

                    decimal presentage = money.RateValue;

                    TaxCounts = presentage * BeforTax_Total / 100;
                    NetTotal  = NetTotal + TaxCounts;

                    M_TaxNRates taxdeta = new M_TaxNRates();

                    taxdeta.InvoiceId     = Invoice_No;
                    taxdeta.RateID        = money.RateID;
                    taxdeta.RateValue     = TaxCounts;
                    taxdeta.CreatedBy     = "Admin";
                    taxdeta.TaxPresentage = presentage;

                    objInv.setInvoiceTaxDetails(taxdeta);
                }
            }

            return(RedirectToAction("InvoiceView", new { Invo = Invoice_No }));
        }