Exemplo n.º 1
0
        public Invoice Create(Invoice invoice)
        {
            EInvoice eInvoice = EInvoice(invoice);

            eInvoice = _iDInvoice.Create(eInvoice);
            return(Invoice(eInvoice));
        }
Exemplo n.º 2
0
        private static IState TransferDocument()
        {
            MenuList      toTransferDocsMenu = new MenuList();
            String        label = "";
            SalesDocument sDoc;

            int i = 1;

            string labelFormat = "{0}\n{1}-{2}";

            label = String.Format(labelFormat, PosMessage.SELECT_DOCUMENT, i++, PosMessage.INVOICE);
            sDoc  = new Invoice(cr.Document);
            toTransferDocsMenu.Add(new MenuLabel(label, sDoc));

            label = String.Format(labelFormat, PosMessage.SELECT_DOCUMENT, i++, PosMessage.E_INVOICE);
            sDoc  = new EInvoice(cr.Document);
            toTransferDocsMenu.Add(new MenuLabel(label, sDoc));

            label = String.Format(labelFormat, PosMessage.SELECT_DOCUMENT, i++, PosMessage.E_ARCHIVE);
            sDoc  = new EArchive(cr.Document);
            toTransferDocsMenu.Add(new MenuLabel(label, sDoc));

            label = String.Format(labelFormat, PosMessage.SELECT_DOCUMENT, i++, PosMessage.MEAL_TICKET);
            sDoc  = new MealTicket(cr.Document);
            toTransferDocsMenu.Add(new MenuLabel(label, sDoc));

            return(List.Instance(toTransferDocsMenu, TransferToChoosenDoc, Continue));
        }
Exemplo n.º 3
0
        private EInvoice EInvoice(Invoice invoice)
        {
            EInvoice returnEInvoice = new EInvoice
            {
                //Amount = invoice.Amount,
                //GovernmentTax = invoice.GovernmentTax,
                //gtholder = invoice.gtholder,
                //lfholder = invoice.lfholder,
                Total = invoice.Total,
                //totalTax = invoice.totalTax,
                WithholdingTax = invoice.WithholdingTax,
                //whtholder = invoice.whtholder,
                //invIdholder = invoice.invIdholder,
                InvoiceId      = invoice.InvoiceId,
                Date           = invoice.Date,
                DueDate        = invoice.DueDate,
                ExpiringPeriod = invoice.ExpiringPeriod,
                StartPeriod    = invoice.StartPeriod,
                Comments       = invoice.Comments,
                Name           = invoice.Name,
                Currency       = invoice.Currency,
                Description    = invoice.Description,
                LateFee        = invoice.LateFee,
                Quantity       = invoice.Quantity,
                Rate           = invoice.Rate,
                Recipients     = invoice.Recipients,
                Status         = invoice.Status,
                TypeOfService  = invoice.TypeOfService,
                Services       = invoice.Services
            };

            return(returnEInvoice);
        }
Exemplo n.º 4
0
        private EInvoice EInvoice(Invoice invoice)
        {
            EInvoice returnEInvoice = new EInvoice
            {
                InvoiceId  = invoice.InvoiceId,
                Name       = invoice.Name,
                TaxTypeId  = invoice.TaxTypeId,
                Subtotal   = invoice.Subtotal,
                AmountDue  = invoice.AmountDue,
                CurrencyId = invoice.CurrencyId,
                Tax        = invoice.Tax,
                Services   = invoice.Services?.Select(a => new EService
                {
                    Quantity = a.Quantity,
                    Rate     = a.Rate,
                    Subtotal = a.Subtotal,

                    InvoiceId       = a.InvoiceId,
                    ServiceId       = a.ServiceId,
                    TypeOfServiceId = a.TypeOfServiceId,

                    Comments = a.Comments
                }).ToList() ?? null,
                SINo          = invoice.SINo,
                TIN           = invoice.TIN,
                Address       = invoice.Address,
                ClientId      = invoice.ClientId,
                CreatedDate   = invoice.CreatedDate,
                DueDate       = invoice.DueDate,
                UpdatedDate   = invoice.UpdatedDate,
                BillingPeriod = invoice.BillingPeriod
            };

            return(returnEInvoice);
        }
Exemplo n.º 5
0
        private Invoice Invoice(EInvoice eInvoice)
        {
            Invoice returnInvoice = new Invoice
            {
                Amount           = eInvoice.Amount,
                GovernmentTax    = eInvoice.GovernmentTax,
                gtholder         = eInvoice.gtholder,
                lfholder         = eInvoice.lfholder,
                Total            = eInvoice.Total,
                totalTax         = eInvoice.totalTax,
                WithholdingTax   = eInvoice.WithholdingTax,
                whtholder        = eInvoice.whtholder,
                invIdholder      = eInvoice.invIdholder,
                invoiceId        = eInvoice.invoiceId,
                Date             = eInvoice.Date,
                DueDate          = eInvoice.DueDate,
                ExpiringPeriod   = eInvoice.ExpiringPeriod,
                StartPeriod      = eInvoice.StartPeriod,
                Comments         = eInvoice.Comments,
                Name             = eInvoice.Name,
                Currency         = eInvoice.Currency,
                Description      = eInvoice.Description,
                LateFee          = eInvoice.LateFee,
                Quantity         = eInvoice.Quantity,
                Rate             = eInvoice.Rate,
                Recipients       = eInvoice.Recipients,
                Status           = eInvoice.Status,
                TypeOfService    = eInvoice.TypeOfService,
                multipleServices = eInvoice.multipleServices
            };

            return(returnInvoice);
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            // 1.建立依賴注入的容器
            var serviceCollection = new ServiceCollection();

            // 2. 註冊服務
            serviceCollection.AddTransient <HelloSelector>();
            serviceCollection.AddTransient <IHello, EngHello>();
            //serviceCollection.AddTransient<ConfigureServices>();

            serviceCollection.AddSingleton <ConfigSelector>();
            serviceCollection.AddSingleton <IConfigSetting, ConsoleSetting>();
            // 建立依賴服務提供者
            var serviceProvider = serviceCollection.BuildServiceProvider();

            // 3. 執行主服務
            serviceProvider.GetRequiredService <HelloSelector>().Say();

            var _configSelect = serviceProvider.GetRequiredService <ConfigSelector>();
            var _config       = _configSelect.GetConfig();

            //Console.WriteLine(_config.GetSection("TestSetting").Value);
            //Console.WriteLine(_config.GetSection("Settings").GetSection("Set1").Value);
            //Console.WriteLine(_config.GetSection("Settings:Set2").Value);
            EInvoice.UpdateXMLExported(_config.GetConnectionString("ReadWrite"));
            //Console.WriteLine(_config.GetConnectionString("ReadWrite"));

            //new SampleUseConnection(serviceProvider).ShowConnection();
        }
Exemplo n.º 7
0
        public Invoice Create(Invoice invoice)
        {
            EInvoice eInvoice = EInvoice(invoice);

            eInvoice             = _iDInvoice.Create(eInvoice);
            eInvoice.CreatedDate = DateTime.Now;
            return(Invoice(eInvoice));
        }
        public IHttpActionResult GetByAboxId(string idToRequest)
        {
            Guid processId = Guid.NewGuid();


            LogEventInfo log = new LogEventInfo(LogLevel.Debug, Logger.Name, $"ProcessID: {processId} Request hacia {Request.RequestUri} con parámetros:**START** {idToRequest} **END**");

            log.Properties["ProcessID"]  = processId;
            log.Properties["AppID"]      = AboxDynamicsBase.Classes.Constants.ApplicationIdWebAPI;
            log.Properties["MethodName"] = System.Reflection.MethodBase.GetCurrentMethod().Name;
            Logger.Log(log);

            EInvoice        invoiceProcedures = new EInvoice();
            OperationResult response          = null;

            try
            {
                if (idToRequest != null)
                {
                    response = invoiceProcedures.GetInvoice(idToRequest, InvoiceFields.IdAboxInvoice, processId);

                    if (response.IsSuccessful)
                    {
                        return(Ok(response));
                    }
                    else
                    {
                        return(Content(HttpStatusCode.NotFound, response));
                    }
                }
                else
                {
                    return(Content(HttpStatusCode.BadRequest, new OperationResult
                    {
                        Code = "",
                        IsSuccessful = false,
                        Data = null,
                        Message = "La solicitud JSON enviada es incorrecta"
                    }));
                }
            }
            catch (Exception ex)
            {
                LogEventInfo logEx = new LogEventInfo(LogLevel.Error, Logger.Name, null, $"Request hacia {Request.RequestUri} con parámetros:**START** {idToRequest} **END**", null, new Exception(ex.ToString()));
                logEx.Properties["ProcessID"]  = processId;
                logEx.Properties["AppID"]      = Constants.ApplicationIdWebAPI;
                logEx.Properties["MethodName"] = System.Reflection.MethodBase.GetCurrentMethod().Name;
                Logger.Log(logEx);

                return(Content(HttpStatusCode.InternalServerError, new OperationResult
                {
                    IsSuccessful = false,
                    Data = null,
                    Message = ex.ToString(),
                    Code = ""
                }));
            }
        }
Exemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            EInvoice einvoice = new EInvoice();
            int      DelTick;

            DelTick = 2147390252;
            //Chesapeake: 2147352613;
            einvoice.Main(@"D:\EDIInv\" + Convert.ToString(txtDelTicket.Text), Convert.ToInt32(txtDelTicket.Text));
        }
Exemplo n.º 10
0
 /// <summary>
 /// Code to get invoice next blatt numbers
 /// </summary>
 /// <param name="ObjEInvoice"></param>
 /// <returns></returns>
 public EInvoice GeTBlattNumbers(EInvoice ObjEInvoice)
 {
     try
     {
         ObjEInvoice = ObjDInvoice.GeTBlattNumbers(ObjEInvoice);
     }
     catch (Exception ex)
     {
         throw;
     }
     return(ObjEInvoice);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Code to save invoice
 /// </summary>
 /// <param name="ObjEInvoice"></param>
 /// <returns></returns>
 public EInvoice SaveInvoice(EInvoice ObjEInvoice)
 {
     try
     {
         ObjEInvoice = ObjDInvoice.SaveInvoice(ObjEInvoice);
     }
     catch (Exception ex)
     {
         throw;
     }
     return(ObjEInvoice);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Code to get list of invoices
 /// </summary>
 /// <param name="ObjEInvoice"></param>
 /// <returns></returns>
 public EInvoice GetInvoices(EInvoice ObjEInvoice)
 {
     try
     {
         ObjEInvoice = ObjDInvoice.GetInvoices(ObjEInvoice);
     }
     catch (Exception ex)
     {
         throw;
     }
     return(ObjEInvoice);
 }
Exemplo n.º 13
0
        public static void EnterDefaultDocumentCode(Object o)
        {
            MenuLabel label = o as MenuLabel;
            int       defDocType;
            String    docType = label.Value.ToString().Split('\n')[1].Trim();

            switch (docType)
            {
            case PosMessage.RECEIPT_TR:
                defDocType = 0;
                break;

            case PosMessage.INVOICE:
                defDocType = new Invoice().DocumentTypeId;
                break;

            case PosMessage.E_ARCHIVE:
                defDocType = new EArchive().DocumentTypeId;
                break;

            case PosMessage.E_INVOICE:
                defDocType = new EInvoice().DocumentTypeId;
                break;

            case PosMessage.MEAL_TICKET:
                defDocType = new MealTicket().DocumentTypeId;
                break;

            case PosMessage.CAR_PARKIMG:
                defDocType = new CarParkDocument().DocumentTypeId;
                break;

            case PosMessage.ADVANCE:
                defDocType = new Advance().DocumentTypeId;
                break;

            case PosMessage.COLLECTION_INVOICE:
                defDocType = new CollectionInvoice().DocumentTypeId;
                break;

            case PosMessage.CURRENT_ACCOUNT_COLLECTION:
                defDocType = new CurrentAccountDocument().DocumentTypeId;
                break;

            default:
                defDocType = 0;
                break;
            }

            customerInput.Append(defDocType.ToString().PadLeft(2, '0'));

            cr.State = SaveCustomerInput();
        }
Exemplo n.º 14
0
        // GET: invoices/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EInvoice invoice = db.invoices.Find(id);

            if (invoice == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(invoice));
        }
Exemplo n.º 15
0
        /*GENERATE PDF FUNCTION */
        public ActionResult ExportPDF(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EInvoice invoice = db.invoices.Find(id);

            var idHolder = id.ToString();

            return(new ActionAsPdf("printPDF", new { id = id })
            {
                FileName = "INV-00" + idHolder + " - ClientCode.pdf"
            });
        }
Exemplo n.º 16
0
 /// <summary>
 /// Code to get invoice next blatt numbers
 /// </summary>
 /// <param name="ObjEInvoice"></param>
 /// <returns></returns>
 public EInvoice GeTBlattNumbers(EInvoice ObjEInvoice)
 {
     try
     {
         DataSet dsInvoices = new DataSet();
         try
         {
             using (SqlCommand cmd = new SqlCommand())
             {
                 cmd.Connection  = SQLCon.Sqlconn();
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.CommandText = "[P_Get_BlattNumbers]";
                 cmd.Parameters.AddWithValue("@ProjectID", ObjEInvoice.ProjectID);
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(dsInvoices);
                 }
             }
             if (dsInvoices != null)
             {
                 if (dsInvoices.Tables.Count > 0)
                 {
                     ObjEInvoice.dtBlattNumbers = dsInvoices.Tables[0];
                 }
             }
         }
         catch (Exception ex)
         {
             if (System.Threading.Thread.CurrentThread.CurrentCulture.Name.ToString() == "de-DE")
             {
                 throw new Exception("Fehler beim Datenabruf zu den Aufmassen");
             }
             else
             {
                 throw new Exception("Error While Retrieving the Delivery Notes");
             }
         }
         finally
         {
             SQLCon.Close();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
     return(ObjEInvoice);
 }
Exemplo n.º 17
0
        ////////////////////////////////////PRACTICE///////
        // GET: AndersonPayy/Edit/5
        public ActionResult EditInvoice(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EInvoice invoice = db.invoices.Find(id);

            if (invoice == null)
            {
                return(HttpNotFound());
            }
            ViewBag.id            = id;
            ViewBag.CompanyName   = new SelectList(db.companies, "CompanyName", "CompanyName", invoice.CompanyName);
            ViewBag.TypeOfService = new SelectList(db.typeofservices, "typeofserviceId", "NameOfService", invoice.TypeOfService);
            return(View(invoice));
        }
Exemplo n.º 18
0
        private Invoice Invoice(EInvoice eInvoice)
        {
            Invoice returnInvoice = new Invoice
            {
                InvoiceId   = eInvoice.InvoiceId,
                Name        = eInvoice.Name,
                Subtotal    = eInvoice.Subtotal,
                AmountDue   = eInvoice.AmountDue,
                TaxTypeId   = eInvoice.TaxTypeId,
                CurrencyId  = eInvoice.CurrencyId,
                Tax         = eInvoice.Tax,
                SINo        = eInvoice.SINo,
                TIN         = eInvoice.TIN,
                Address     = eInvoice.Address,
                ClientId    = eInvoice.ClientId,
                CreatedDate = eInvoice.CreatedDate,
                UpdatedDate = eInvoice.UpdatedDate
            };

            return(returnInvoice);
        }
Exemplo n.º 19
0
        private EInvoice EInvoice(Invoice invoice)
        {
            EInvoice returnEInvoice = new EInvoice
            {
                //GovernmentTax = invoice.GovernmentTax,
                //gtholder = invoice.gtholder,
                //lfholder = invoice.lfholder,
                //totalTax = invoice.totalTax,
                //whtholder = invoice.whtholder,
                //invIdholder = invoice.invIdholder,
                //Date = invoice.Date,
                //DueDate = invoice.DueDate,
                //ExpiringPeriod = invoice.ExpiringPeriod,
                //StartPeriod = invoice.StartPeriod,
                //Description = invoice.Description,
                //LateFee = invoice.LateFee,
                //Quantity = invoice.Quantity,
                //Rate = invoice.Rate,
                //Status = invoice.Status,
                //TypeOfService = invoice.TypeOfService,

                InvoiceId = invoice.InvoiceId,
                Name      = invoice.Name,
                TaxTypes  = invoice.TaxTypes,
                Subtotal  = invoice.Subtotal,
                Total     = invoice.Total,
                Currency  = invoice.Currency,
                Tax       = invoice.Tax,
                //Comments = invoice.Comments,
                Recipients = invoice.Recipients,
                Services   = invoice.Services,
                SINo       = invoice.SINo,
                TIN        = invoice.TIN
            };

            return(returnEInvoice);
        }
Exemplo n.º 20
0
        private Invoice Invoice(EInvoice eInvoice)
        {
            Invoice returnInvoice = new Invoice
            {
                //GovernmentTax = eInvoice.GovernmentTax,
                //gtholder = eInvoice.gtholder,
                //lfholder = eInvoice.lfholder,
                //totalTax = eInvoice.totalTax,
                //whtholder = eInvoice.whtholder,
                //invIdholder = eInvoice.invIdholder,
                //Date = eInvoice.Date,
                //DueDate = eInvoice.DueDate,
                //ExpiringPeriod = eInvoice.ExpiringPeriod,
                //StartPeriod = eInvoice.StartPeriod,
                //Name = eInvoice.Name,
                //Description = eInvoice.Description,
                //LateFee = eInvoice.LateFee,
                //Quantity = eInvoice.Quantity,
                //Rate = eInvoice.Rate,
                //Status = eInvoice.Status,
                //TypeOfService = eInvoice.TypeOfService,

                InvoiceId  = eInvoice.InvoiceId,
                Name       = eInvoice.Name,
                Subtotal   = eInvoice.Subtotal,
                Total      = eInvoice.Total,
                Tax        = eInvoice.Tax,
                Currency   = eInvoice.Currency,
                Recipients = eInvoice.Recipients,
                Comments   = eInvoice.Comments,
                SINo       = eInvoice.SINo,
                TIN        = eInvoice.TIN
            };

            return(returnInvoice);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Code to save invoice
        /// </summary>
        /// <param name="ObjEInvoice"></param>
        /// <returns></returns>
        public EInvoice SaveInvoice(EInvoice ObjEInvoice)
        {
            DataSet dsInvoices = new DataSet();

            try
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = SQLCon.Sqlconn();
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "[P_Ins_Invoice]";
                    cmd.Parameters.AddWithValue("@InvoiceID", ObjEInvoice.InvoiceID);
                    cmd.Parameters.AddWithValue("@ProjectID", ObjEInvoice.ProjectID);
                    cmd.Parameters.AddWithValue("@InvoiceNumber", ObjEInvoice.InvoiceNumber);
                    cmd.Parameters.AddWithValue("@InvoiceDescription", ObjEInvoice.InvoiceDescription);
                    cmd.Parameters.AddWithValue("@InvoiceType", ObjEInvoice.InvoiceType);
                    cmd.Parameters.AddWithValue("@dtInvoice", ObjEInvoice.dtInvoice);
                    cmd.Parameters.AddWithValue("@IsFinalInvoice", ObjEInvoice.IsFinalInvoice);
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        da.Fill(dsInvoices);
                    }
                }
                if (dsInvoices != null && dsInvoices.Tables.Count > 0)
                {
                    if (dsInvoices.Tables[0].Rows.Count > 0)
                    {
                        int    iValue   = 0;
                        string strError = dsInvoices.Tables[0].Rows[0][0].ToString();
                        if (!int.TryParse(strError, out iValue))
                        {
                            throw new Exception(strError);
                        }
                        else
                        {
                            ObjEInvoice.InvoiceID      = iValue;
                            ObjEInvoice.dtBlattNumbers = dsInvoices.Tables[1];
                            if (dsInvoices.Tables.Count > 1)
                            {
                                ObjEInvoice.dtInvoices = dsInvoices.Tables[2];
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("Atleast"))
                {
                    throw new Exception("Bitte wählen Sie mindestens ein Aufmass");
                }
                else if (ex.Message.Contains("UNIQUE"))
                {
                    throw new Exception("Diese Rechnungsnummer wurde für dieses Projekt bereits vergeben");
                }
                else
                {
                    throw new Exception("Error While Saving the Invoice");
                }
            }
            finally
            {
                SQLCon.Close();
            }
            return(ObjEInvoice);
        }
Exemplo n.º 22
0
 public InvoicePair(EInvoice eInvoice, TradeInvoice tradeInvoice)
 {
     TradeInvoice = tradeInvoice;
     EInvoiceInfo = eInvoice;
 }
Exemplo n.º 23
0
        public Invoice Read(int invoiceId)
        {
            EInvoice eInvoice = _iDInvoice.Read <EInvoice>(a => a.InvoiceId == invoiceId);

            return(Invoice(eInvoice));
        }
Exemplo n.º 24
0
        public ActionResult EditInvoice([Bind(Include = "invoiceId,Date,DueDate,Quantity,Rate,Amount,Total,TypeOfService,CompanyName,Recipients,GovernmentTax,gtholder,WithholdingTax,ExpiringPeriod,whtholder,Signature,LateFee,lfholder,Address,Comments,Currency,StartPeriod,totalTax,invIdholder,Status,Deleted")] EInvoice invoice, string Submit, string Comments)
        {
            //DateTime date = DateTime.Today;
            //var seconddayofthemonth = new DateTime(date.Year, date.Month, 2);
            //var limited = invoice.ExpiringPeriod.AddMonths(1);

            //Converts everything from string to their definite var type
            var rateHldr = Convert.ToDecimal(invoice.Rate);
            var qtyHldr  = Convert.ToInt32(invoice.Quantity);
            var lfHldr   = Convert.ToDecimal(invoice.LateFee);

            //amount
            invoice.Amount = rateHldr * qtyHldr;
            //government tax


            //withholding tax
            //JEV WAS HERE NYAHAHA
            if (invoice.GovernmentTax == 12)
            {
                decimal x = invoice.Amount * invoice.GovernmentTax;
                invoice.gtholder = 12;
                decimal govtax = x / 100;
                invoice.GovernmentTax  = govtax;
                invoice.WithholdingTax = 0;
                decimal y = invoice.Amount * invoice.WithholdingTax;
                invoice.whtholder = invoice.WithholdingTax;
                decimal whtax = y / 100;
                invoice.WithholdingTax = whtax;
            }

            if (invoice.WithholdingTax == 1)
            {
                invoice.WithholdingTax = 1;
                decimal wttax = invoice.WithholdingTax / 100;
                invoice.whtholder = wttax;
                Convert.ToDouble(invoice.Amount);
                decimal y = invoice.Amount * wttax;
                invoice.WithholdingTax = y;
            }
            else if (invoice.WithholdingTax == 2)
            {
                invoice.WithholdingTax = 2;
                decimal wttax = invoice.WithholdingTax / 100;
                invoice.whtholder = invoice.WithholdingTax;
                decimal y = invoice.Amount * wttax;
                invoice.WithholdingTax = y;
            }
            else if (invoice.WithholdingTax == 5)
            {
                invoice.WithholdingTax = 5;
                decimal wttax = invoice.WithholdingTax / 100;
                invoice.whtholder = wttax;
                Convert.ToDouble(invoice.Amount);
                decimal y = invoice.Amount * wttax;
                invoice.WithholdingTax = y;
            }
            else
            {
                invoice.WithholdingTax = 0;
                decimal wttax = invoice.WithholdingTax / 100;
                invoice.whtholder = wttax;
                Convert.ToDouble(invoice.Amount);
                decimal y = invoice.Amount * wttax;
                invoice.WithholdingTax = y;
            }


            //latefee
            decimal q = invoice.Amount * lfHldr;

            invoice.lfholder = lfHldr;
            decimal latefee = q / 100;

            lfHldr          = latefee;
            invoice.LateFee = Convert.ToString(lfHldr);


            invoice.Comments = Comments;
            invoice.totalTax = invoice.gtholder + invoice.whtholder + invoice.lfholder;
            invoice.Total    = invoice.Amount + invoice.GovernmentTax + invoice.WithholdingTax + latefee;

            //if (date == seconddayofthemonth)
            //{
            //    invoice.Status = "Overdue";
            //}
            //if (invoice.ExpiringPeriod < DateTime.Today)
            //{
            //    invoice.Status = "Overdue";
            //}
            //else
            //{
            invoice.Status = "Pending";
            //}

            if (ModelState.IsValid)
            {
                switch (Submit)
                {
                case "Preview":
                    return(RedirectToAction("PreviewInvoice", invoice));

                default:
                    db.Entry(invoice).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("EmailRedirect", new { id = invoice.invoiceId }));
                }
            }
            ViewBag.CompanyName   = new SelectList(db.companies, "CompanyName", "CompanyName", invoice.CompanyName);
            ViewBag.TypeOfService = new SelectList(db.typeofservices, "typeofserviceId", "NameOfService", invoice.TypeOfService);
            return(View(invoice));
        }
Exemplo n.º 25
0
        //int? page: question mark means can be null. page = number of pages (Index line 174)
        public ActionResult Index(string sortBy, int?page, string filterBy, int?id, string status, string searchBy, string search)
        {
            //Search Function
            if (!String.IsNullOrEmpty(search))
            {
                return(View(db.invoices.Where(x => x.CompanyName.StartsWith(search) || search == null).ToList().ToPagedList(page ?? 1, 30)));
            }


            //db inculudes the company table in database
            var invoices = db.invoices.Include(i => i.Company);

            //line 29 - 50: All functions about Sorting data in View(Index).
            invoices                  = invoices.OrderByDescending(x => x.invoiceId);
            ViewBag.SortDateDesc      = "Date desc";
            ViewBag.SortDateAsc       = "Date";
            ViewBag.SortDueDateDesc   = "Due Date desc";
            ViewBag.SortDueDateAsc    = "Due Date";
            ViewBag.SortTotalDesc     = "Total desc";
            ViewBag.SortTotalAsc      = "Total";
            ViewBag.SortNameAsc       = "Name Asc";
            ViewBag.SortNameDsc       = "Name Dsc";
            ViewBag.SortDateToday     = "Today";
            ViewBag.SortDateThisWeek  = "This Week";
            ViewBag.SortDateThisMonth = "This Month";
            ViewBag.SortDateThisYear  = "This Year";
            //Declaration of Dateranges for Comparing
            DateTime FromDate = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy/MM/dd"));
            DateTime UptoDate = FromDate;
            // remove time from Today
            DateTime Today = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy/MM/dd"));

            ViewBag.Header = sortBy;
            if (sortBy != null)
            {
                ViewBag.Header = sortBy;
            }
            else if (filterBy != null)
            {
                ViewBag.Header = filterBy;
            }
            else
            {
                ViewBag.Header = "Invoices";
            }
            switch (sortBy)
            {
            case "Today":
                //return View(db.invoices.Where(x => x.Date == Today).ToList().ToPagedList(page ?? 1, 30));
                invoices = db.invoices.Where(x => x.Date == Today);
                break;

            case "This Week":
                //switch inside a switch, to improve the time of execution
                //Week Range Function
                switch (DateTime.Now.DayOfWeek.ToString())
                {
                case "Sunday":
                    UptoDate = UptoDate.AddDays(6);
                    break;

                case "Monday":
                    FromDate = FromDate.AddDays(-1);
                    UptoDate = UptoDate.AddDays(5);
                    break;

                case "Tuesday":
                    FromDate = FromDate.AddDays(-2);
                    UptoDate = UptoDate.AddDays(4);
                    break;

                case "Wednesday":
                    FromDate = FromDate.AddDays(-3);
                    UptoDate = UptoDate.AddDays(3);
                    break;

                case "Thursday":
                    FromDate = FromDate.AddDays(-4);
                    UptoDate = UptoDate.AddDays(2);
                    break;

                case "Friday":
                    FromDate = FromDate.AddDays(-5);
                    UptoDate = UptoDate.AddDays(1);
                    break;

                case "Saturday":
                    FromDate = FromDate.AddDays(-6);
                    break;
                }
                //Week Range Function End
                //return View(db.invoices.Where(x => x.Date >= FromDate && x.Date <= UptoDate).ToList().ToPagedList(page ?? 1, 30));
                invoices = invoices.Where(x => x.Date >= FromDate && x.Date <= UptoDate);
                break;

            case "This Month":
                Today    = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy/MM"));
                FromDate = Today;
                UptoDate = Convert.ToDateTime(Today.AddMonths(1).ToString("yyyy/MM"));
                invoices = db.invoices.Where(x => x.Date >= FromDate && x.Date < UptoDate);
                break;

            // return View(db.invoices.Where(x => x.Date >= FromDate && x.Date < UptoDate).ToList().ToPagedList(page ?? 1, 30));
            case "This Year":
                //return View(db.invoices.Where(x => x.Date.Year == DateTime.Now.Year).ToList().ToPagedList(page ?? 1, 30));
                invoices = db.invoices.Where(x => x.Date.Year == DateTime.Now.Year);
                break;

            case "Date desc":
                invoices = invoices.OrderByDescending(x => x.Date);
                break;

            case "Total desc":
                invoices = invoices.OrderByDescending(x => x.Total);
                break;

            case "Date":
                invoices = invoices.OrderBy(x => x.Date);
                break;

            case "Due Date":
                invoices = invoices.OrderBy(x => x.DueDate);
                break;

            case "Due Date desc":
                invoices = invoices.OrderByDescending(x => x.DueDate);
                break;

            case "Total":
                invoices = invoices.OrderBy(x => x.Total);
                break;

            case "Name Asc":
                invoices = invoices.OrderBy(x => x.CompanyName);
                break;

            case "Name Dsc":
                invoices = invoices.OrderByDescending(x => x.CompanyName);
                break;
            }

            ViewBag.StatusOverdue  = "Overdue";
            ViewBag.StatusPending  = "Pending";
            ViewBag.StatusOnHold   = "On Hold";
            ViewBag.StatusCanceled = "Canceled";
            ViewBag.StatusPaid     = "Paid";
            ViewBag.CurrencyPeso   = "Peso";
            ViewBag.CurrencyPeso   = "Dollar";
            ViewBag.CurrencyPeso   = "UK Pounds";


            switch (status)
            {
            case "Overdue":
                EInvoice invoiceod = db.invoices.Find(id);
                invoiceod.Status = "Overdue";
                db.SaveChanges();
                break;

            case "Pending":
                EInvoice invoicep = db.invoices.Find(id);
                invoicep.Status = "Pending";
                db.SaveChanges();
                break;

            case "On Hold":
                EInvoice invoiceoh = db.invoices.Find(id);
                invoiceoh.Status = "On Hold";
                db.SaveChanges();
                break;

            case "Canceled":
                EInvoice invoicec = db.invoices.Find(id);
                invoicec.Status = "Canceled";
                db.SaveChanges();
                break;

            case "Paid":
                EInvoice invoicepd = db.invoices.Find(id);
                invoicepd.Status = "Paid";
                db.SaveChanges();
                break;
            }


            //FILTER BY STATUS
            if (filterBy == "Pending")
            {
                //return View(db.invoices.Where(x => x.Status == "Pending").ToList().ToPagedList(page ?? 1, 30));
                invoices = db.invoices.Where(x => x.Status == "Pending");
            }
            else if (filterBy == "Overdue")
            {
                //return View(db.invoices.Where(x => x.Status == "Overdue").ToList().ToPagedList(page ?? 1, 30));
                invoices = db.invoices.Where(x => x.Status == "Overdue");
            }
            else if (filterBy == "Paid")
            {
                //return View(db.invoices.Where(x => x.Status == "Paid").ToList().ToPagedList(page ?? 1, 30));
                invoices = db.invoices.Where(x => x.Status == "Paid");
            }
            else if (filterBy == "On Hold")
            {
                //return View(db.invoices.Where(x => x.Status == "On Hold").ToList().ToPagedList(page ?? 1, 30));
                invoices = db.invoices.Where(x => x.Status == "On Hold");
            }
            else if (filterBy == "Canceled")
            {
                //return View(db.invoices.Where(x => x.Status == "Canceled").ToList().ToPagedList(page ?? 1, 30));
                invoices = db.invoices.Where(x => x.Status == "Canceled");
            }

            //FILTER BY CURRENCY
            else if (filterBy == "Peso")
            {
                //return View(db.invoices.Where(c => c.Currency == "Peso").ToList().ToPagedList(page ?? 1, 15));
                invoices = db.invoices.Where(x => x.Currency == "Peso");
            }
            else if (filterBy == "Dollar")
            {
                invoices = db.invoices.Where(x => x.Currency == "Dollar");
                //return View(db.invoices.Where(c => c.Currency == "Dollar").ToList().ToPagedList(page ?? 1, 15));
            }
            else if (filterBy == "UK Pounds")
            {
                invoices = db.invoices.Where(x => x.Currency == "UK Pounds");
                // return View(db.invoices.Where(c => c.Currency == "UK Pounds").ToList().ToPagedList(page ?? 1, 15));
            }
            //else
            //{
            //    //invoices are in list. Kaya mag kaka error sa Index pag hindi @foreach ung ginamit.
            //    //return View(invoices.ToList().ToPagedList(page ?? 1, 30));
            //    return View(invoices.ToList());
            //}
            if (db.invoices.Count() == 0)
            {
                return(View(invoices.ToList().ToPagedList(page ?? 1, 1)));
            }
            else
            {
                return(View(invoices.ToList().ToPagedList(page ?? 1, db.invoices.Count())));
            }
        }
Exemplo n.º 26
0
        //This will print PDF
        public ActionResult PrintPDF(int?id)
        {
            EInvoice invoice = db.invoices.Find(id);

            return(View(invoice));
        }
Exemplo n.º 27
0
        public ActionResult CreateInvoice(string Submit, string Comments, EInvoice invoice, EMultipleService multipleServices)
        {
            multipleServices.invoiceId     = invoice.invoiceId;
            invoice.Multiple               = true;
            invoice.TypeOfService          = "Multiple";
            invoice.Description            = "Multiple Services";
            invoice.Amount                 = multipleServices.SubTotal;
            multipleServices.NameOfService = invoice.TypeOfService;

            //Converts everything from string to their definite var type
            var lfHldr = Convert.ToDecimal(invoice.LateFee);

            //amount
            //invoice.Amount = rateHldr * qtyHldr;
            //government tax


            //withholding tax
            //JEV WAS HERE NYAHAHA
            if (invoice.GovernmentTax == 12)
            {
                decimal x = multipleServices.SubTotal * invoice.GovernmentTax;
                invoice.gtholder = 12;
                decimal govtax = x / 100;
                invoice.GovernmentTax  = govtax;
                invoice.WithholdingTax = 0;
                decimal y = invoice.Amount * invoice.WithholdingTax;
                invoice.whtholder = invoice.WithholdingTax;
                decimal whtax = y / 100;
                invoice.WithholdingTax = whtax;
            }

            if (invoice.WithholdingTax == 1)
            {
                invoice.WithholdingTax = 1;
                decimal wttax = invoice.WithholdingTax / 100;
                invoice.whtholder = wttax;
                Convert.ToDouble(invoice.Amount);
                decimal y = multipleServices.SubTotal * wttax;
                invoice.WithholdingTax = y;
            }
            else if (invoice.WithholdingTax == 2)
            {
                invoice.WithholdingTax = 2;
                decimal wttax = invoice.WithholdingTax / 100;
                invoice.whtholder = invoice.WithholdingTax;
                decimal y = invoice.Amount * wttax;
                invoice.WithholdingTax = y;
            }
            else if (invoice.WithholdingTax == 5)
            {
                invoice.WithholdingTax = 5;
                decimal wttax = invoice.WithholdingTax / 100;
                invoice.whtholder = wttax;
                Convert.ToDouble(invoice.Amount);
                decimal y = invoice.Amount * wttax;
                invoice.WithholdingTax = y;
            }


            //latefee
            decimal q = invoice.Amount * lfHldr;

            invoice.lfholder = lfHldr;
            decimal latefee = q / 100;

            lfHldr           = latefee;
            invoice.LateFee  = Convert.ToString(lfHldr);
            invoice.Comments = Comments;

            invoice.totalTax = invoice.gtholder + invoice.whtholder + invoice.lfholder;

            invoice.Status = "Pending";

            if (invoice.TypeOfService != null && invoice.Quantity != null && invoice.Rate != null)
            {
                if (ModelState.IsValid)
                {
                    switch (Submit)
                    {
                    case "Preview":
                        return(RedirectToAction("PreviewInvoice", invoice));

                    default:
                        db.invoices.Add(invoice);
                        db.SaveChanges();
                        if (invoice.TypeOfService == "Multiple")
                        {
                            return(RedirectToAction("Submit"));
                        }
                        return(RedirectToAction("EmailRedirect", new { id = invoice.invoiceId }));
                    }
                }
            }
            ViewBag.CompanyName      = new SelectList(db.companies, "CompanyName", "CompanyName", invoice.CompanyName);
            ViewBag.TypeOfService    = new SelectList(db.typeofservices, "typeofserviceId", "NameOfService", invoice.TypeOfService);
            ViewBag.MultipleServices = new SelectList(db.MultipleServices, "typeofserviceId", "NameOfService", invoice.multipleServices);
            //return View(invoice);
            return(Json(invoice));
        }
Exemplo n.º 28
0
 public ActionResult PreviewInvoice(EInvoice invoice)
 {
     return(View(invoice));
 }
Exemplo n.º 29
0
        public ActionResult PreviewInvoice(EInvoice invoice, int?id, string Preview, EMultipleService multipleServices)
        {
            multipleServices.invoiceId     = invoice.invoiceId;
            invoice.Multiple               = true;
            invoice.TypeOfService          = "Multiple";
            invoice.Description            = "MultipleServices";
            invoice.Amount                 = multipleServices.SubTotal;
            multipleServices.NameOfService = invoice.TypeOfService;
            var lfHldr = Convert.ToDecimal(invoice.LateFee);


            //government tax


            //withholding tax
            //JEV WAS HERE NYAHAHA
            if (invoice.GovernmentTax == 12)
            {
                decimal x = multipleServices.SubTotal * invoice.GovernmentTax;
                invoice.gtholder = 12;
                decimal govtax = x / 100;
                invoice.GovernmentTax  = govtax;
                invoice.WithholdingTax = 0;
                decimal y = invoice.Amount * invoice.WithholdingTax;
                invoice.whtholder = invoice.WithholdingTax;
                decimal whtax = y / 100;
                invoice.WithholdingTax = whtax;
            }

            if (invoice.WithholdingTax == 1)
            {
                invoice.WithholdingTax = 1;
                decimal wttax = invoice.WithholdingTax / 100;
                invoice.whtholder = wttax;
                Convert.ToDouble(invoice.Amount);
                decimal y = multipleServices.SubTotal * wttax;
                invoice.WithholdingTax = y;
            }
            else if (invoice.WithholdingTax == 2)
            {
                invoice.WithholdingTax = 2;
                decimal wttax = invoice.WithholdingTax / 100;
                invoice.whtholder = invoice.WithholdingTax;
                decimal y = invoice.Amount * wttax;
                invoice.WithholdingTax = y;
            }
            else if (invoice.WithholdingTax == 5)
            {
                invoice.WithholdingTax = 5;
                decimal wttax = invoice.WithholdingTax / 100;
                invoice.whtholder = wttax;
                Convert.ToDouble(invoice.Amount);
                decimal y = invoice.Amount * wttax;
                invoice.WithholdingTax = y;
            }
            else
            {
                invoice.WithholdingTax = 0;
                decimal wttax = invoice.WithholdingTax / 100;
                invoice.whtholder = wttax;
                Convert.ToDouble(invoice.Amount);
                decimal y = invoice.Amount * wttax;
                invoice.WithholdingTax = y;
            }


            //latefee
            decimal q = invoice.Amount * lfHldr;

            invoice.lfholder = lfHldr;
            decimal latefee = q / 100;

            lfHldr          = latefee;
            invoice.LateFee = Convert.ToString(lfHldr);



            invoice.totalTax = invoice.gtholder + invoice.whtholder + invoice.lfholder;
            invoice.Total    = invoice.Amount + invoice.GovernmentTax + invoice.WithholdingTax + latefee;
            invoice.Status   = "Pending";

            if (ModelState.IsValid)
            {
                switch (Preview)
                {
                case "Preview":
                    return(RedirectToAction("PreviewInvoice", invoice));

                default:
                    db.invoices.Add(invoice);
                    db.SaveChanges();
                    db.invoices.Find(id);
                    return(RedirectToAction("EmailRedirect", new { id = invoice.invoiceId }));
                }
            }
            //return View(invoice);
            return(Json(invoice));
        }
Exemplo n.º 30
0
        // --------------- //


        // Preview Modal View //
        public ActionResult PreviewModal(int?id)
        {
            EInvoice invoice = db.invoices.Find(id);

            return(View(invoice));
        }