public string UpdateInvoiceAndPayment(string invoiceNo, DateTime invoiceDate, DateTime date, List <InvoiceDetailViewModel> invoiceDetail, List <PaymentDetailViewModel> paymentDetail)
    {
        PaymentProvider payment = new PaymentProvider(ctx);
        InvoiceHeader   invoice = ctx.InvoiceHeaders.SingleOrDefault(inv => inv.InvoiceNo == invoiceNo);

        invoice.Date = invoiceDate;
        string paymentNo = String.Empty;

        if (invoice != null)
        {
            ctx.InvoiceDetails.DeleteAllOnSubmit(invoice.InvoiceDetails.AsEnumerable());
            foreach (var model in invoiceDetail)
            {
                InvoiceDetail d = new InvoiceDetail();
                d.InvoiceID = invoice.ID;
                d.ItemID    = model.ItemID;
                d.Quantity  = model.Quantity;
                d.UnitPrice = model.UnitPrice;
                d.Discount  = model.Discount;
                d.IsTaxable = model.IsTaxable;
                invoice.InvoiceDetails.Add(d);
                ctx.InvoiceDetails.InsertOnSubmit(d);
            }
            paymentNo = payment.Create(date, invoiceNo, paymentDetail);
            ctx.SubmitChanges();
        }

        return(paymentNo);
    }
        public async Task <IHttpActionResult> PutInvoiceHeader(int id, InvoiceHeader invoiceHeader)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != invoiceHeader.InvoiceHeaderId)
            {
                return(BadRequest());
            }

            db.Entry(invoiceHeader).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InvoiceHeaderExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
        public string UpdateInvoiceAndPayment(string invoiceNo, DateTime invoiceDate, DateTime date, List <InvoiceDetailViewModel> invoiceDetail, List <PaymentDetailViewModel> paymentDetail)
        {
            //PaymentProvider payment = new PaymentProvider(context);
            string        paymentNo = String.Empty;
            InvoiceHeader invoice   = context.InvoiceHeaders.SingleOrDefault(inv => inv.InvoiceNo == invoiceNo);

            if (invoice != null)
            {
                invoice.Date = invoiceDate;

                context.Delete(invoice.InvoiceDetails.AsEnumerable());
                foreach (var model in invoiceDetail)
                {
                    var d = new InvoiceDetail();
                    d.InvoiceID     = invoice.ID;
                    d.ItemID        = model.ItemID;
                    d.Quantity      = model.Quantity;
                    d.UnitPrice     = model.UnitPrice;
                    d.Discount      = model.Discount;
                    d.IsTaxable     = model.IsTaxable;
                    d.InvoiceHeader = invoice;
                    context.Add(d);

                    if (invoice.CustomerID.HasValue)
                    {
                        CreateTrainingSession(invoice.BranchID, d.ItemID, invoice.CustomerID.Value, invoice, d);
                    }
                }
                paymentNo = paymentProvider.Create(date, invoiceNo, paymentDetail);
                context.SaveChanges();
            }

            return(paymentNo);
        }
Exemple #4
0
        public async Task <IActionResult> PutInvoiceHeader(int id, InvoiceHeader invoiceHeader)
        {
            if (id != invoiceHeader.Id)
            {
                return(BadRequest());
            }

            _context.Entry(invoiceHeader).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InvoiceHeaderExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #5
0
        public async Task <ActionResult <InvoiceHeader> > PostInvoiceHeader(InvoiceHeader invoiceHeader)
        {
            _context.InvoiceHeader.Add(invoiceHeader);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetInvoiceHeader", new { id = invoiceHeader.Id }, invoiceHeader));
        }
Exemple #6
0
    protected void btnProcessVoid_Click(object sender, EventArgs e)
    {
        MonthlyClosingProvider monthlyClosingProvider = UnityContainerHelper.Container.Resolve <MonthlyClosingProvider>();
        InvoiceProvider        invoiceProvider        = UnityContainerHelper.Container.Resolve <InvoiceProvider>();

        var query = from row in gvwData.Rows.Cast <GridViewRow>()
                    where (row.FindControl("chkVoid") as CheckBox).Checked
                    select new {
            InvoiceNo = row.Cells[1].Text
        };

        foreach (var invoice in query)
        {
            InvoiceHeader currentInvoice = invoiceProvider.GetInvoice(invoice.InvoiceNo);
            if (currentInvoice != null)
            {
                if (!monthlyClosingProvider.IsClosed(currentInvoice.BranchID, currentInvoice.Date.Month, currentInvoice.Date.Year))
                {
                    invoiceProvider.ProcessVoid(invoice.InvoiceNo, txtNotes.Text, chkVoidPaymentOnly.Checked);
                    lblStatus.Text += String.Format("Invoice <b>{0}</b> has been marked as void <br/>", currentInvoice.InvoiceNo);
                }
                else
                {
                    lblStatus.Text += String.Format("Invoice <b>{0}</b> cannot be marked as void because of monthly closing <br/>", currentInvoice.InvoiceNo);
                }
            }
        }

        txtNotes.Text = String.Empty;
        gvwData.DataBind();
    }
Exemple #7
0
    protected void gvwData_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string invoiceNo   = Convert.ToString((e.Row.DataItem as System.Data.DataRowView)["InvoiceNo"]);
            string invoiceType = Convert.ToString((e.Row.DataItem as System.Data.DataRowView)["InvoiceType"]);
            if (invoiceType == "Membership Invoicing")
            {
                InvoiceHeader invoice = invoiceProvider.GetInvoice(invoiceNo);
                if (invoice != null)
                {
                    //if (customerStatusProvider.GetStatusHistory(invoice.Customer.Barcode).ToList().Count > 0)
                    //{
                    //    e.Row.Enabled = false;
                    //    e.Row.ToolTip = "Cannot void this invoice because status for this customer has been changed";
                    //    //e.Row.BackColor = Color.Red   ;
                    //}
                    //if(customerStatus invoice.Customer.Barcode
                }
            }

            //    string hyperlinkOnClick = invoiceType == "Fresh Member" ?
            //                                String.Format("window.open('FreshMemberCompleted.aspx?InvoiceNo={0}&HidePrint=1', 'invoice', 'alwaysRaised=yes,modal=1,dialog=yes,minimizable=no,location=no,resizable=yes,width=1000,height=600,scrollbars=yes,toolbar=no,status=no')", invoiceNo) :
            //                                String.Format("window.open('ExistingMemberCompleted.aspx?InvoiceNo={0}&HidePrint=1', 'invoice', 'alwaysRaised=yes,modal=1,dialog=yes,minimizable=no,location=no,resizable=yes,width=1000,height=600,scrollbars=yes,toolbar=no,status=no')", invoiceNo);
            //    (e.Row.FindControl("hypViewDetail") as HyperLink).Attributes.Add("onclick", hyperlinkOnClick);
        }
    }
Exemple #8
0
        public ActionResult SaveVendorInvoice(InvoiceHeader invoiceHeader)
        {
            string       nzTimeZoneKey = "SE Asia Standard Time";
            TimeZoneInfo nzTimeZone    = TimeZoneInfo.FindSystemTimeZoneById(nzTimeZoneKey);


            //string formattedDate = invoiceHeader.InvoiceDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
            //DateTime invoiceDate = DateTime.ParseExact(invoiceHeader.InvoiceDate.ToString(), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
            invoiceHeader.InvoiceDate = invoiceHeader.InvoiceDate;//UTILITY.SINGAPORETIME;
            invoiceHeader.InvoiceType = UTILITY.CONFIG_INVOICETYPE_VENDOR;
            invoiceHeader.Status      = true;
            invoiceHeader.CreatedBy   = USER_ID;
            invoiceHeader.ModifiedBy  = USER_ID;
            invoiceHeader.BranchID    = BRANCH_ID;
            var warrantyexpirydate = invoiceHeader.InvoiceDate.AddMonths(invoiceHeader.WarrantyPeriod);

            invoiceHeader.InvoiceDetailItems.ForEach(dt =>
            {
                dt.InvoiceNo  = invoiceHeader.InvoiceNo;
                dt.ModelNo    = invoiceHeader.ModelNo;
                dt.Make       = "";
                dt.ExpiryDate = warrantyexpirydate;
            });
            invoiceHeader.InvoiceDetailItems = invoiceHeader.InvoiceDetailItems.Where(x => x.SerialNo != "*********").ToList();
            var result = new InvoiceHeaderBO().SaveInvoiceHeader(invoiceHeader);

            return(RedirectToAction("VendorInvoiceList"));
        }
        public string GenerateBillingUnpaidInvoice(int branchID, string[] invoicesNo, string path)
        {
            var    list   = new List <BillingViewModel>();
            Branch branch = context.Branches.SingleOrDefault(b => b.ID == branchID);

            if (branch != null)
            {
                foreach (string invoiceNo in invoicesNo)
                {
                    InvoiceHeader invoice = context.InvoiceHeaders.SingleOrDefault(inv => inv.InvoiceNo == invoiceNo);
                    if (invoice != null)
                    {
                        var billing = new BillingViewModel();
                        billing.MerchantCode          = branch.MerchantCode;
                        billing.CustomerBarcode       = invoice.Customer.Barcode;
                        billing.CreditCardNo          = invoice.Customer.CardNo;
                        billing.CreditCardExpiredDate = invoice.Customer.ExpiredDate.Value;
                        billing.DuesAmount            = invoice.InvoiceDetails.Sum(inv => (inv.Quantity * inv.UnitPrice) - (inv.Discount / 100 * inv.Quantity * inv.UnitPrice));
                        billing.CreditCardName        = invoice.Customer.CardHolderName;
                        billing.Note = "THE GYM MONTHLY PAYMENT," + invoice.InvoiceNo;
                        list.Add(billing);
                    }
                }
            }
            string fileName = CreateBillingFile(branchID, list, DateTime.Today, path, true);

            return(fileName);
        }
Exemple #10
0
        public void MapFromDomainEntity_ValidEntity_ReturnDTOEntity()
        {
            //Arrange
            var invoiceHeader = new InvoiceHeaderDTO
            {
                Id                      = new Guid("110a0a30-3097-471b-962b-1d690c2ea8c6"),
                ProjectId               = new Guid("b58b6a58-2064-4c71-9b3d-c8c4514159a9"),
                InvoiceNumber           = "5555",
                AccountingTotalCurrency = "USD",
                Billing                 = "802-001-5415610-502025-PS-00000-000-000",
                Currency                = "INR",
                InvoiceDate             = new DateTime(2019, 4, 1),
                Status                  = "Approved",
                Supplier                = "ABC CORPORATION"
            };

            //Act
            var response = InvoiceHeader.MapFromDomainEntity(invoiceHeader);

            //Assert
            Assert.IsNotNull(response);
            Assert.AreEqual(invoiceHeader.Id, response.Id);
            Assert.AreEqual(invoiceHeader.ProjectId, response.ProjectId);
            Assert.AreEqual(invoiceHeader.InvoiceNumber, response.InvoiceNumber);
            Assert.AreEqual(invoiceHeader.AccountingTotalCurrency, response.AccountingTotalCurrency);
            Assert.AreEqual(invoiceHeader.Billing, response.Billing);
            Assert.AreEqual(invoiceHeader.Currency, response.Currency);
            Assert.AreEqual(invoiceHeader.InvoiceDate, response.InvoiceDate);
            Assert.AreEqual(invoiceHeader.Status, response.Status);
            Assert.AreEqual(invoiceHeader.InvoiceDate, response.InvoiceDate);
            Assert.AreEqual(invoiceHeader.Supplier, response.Supplier);
        }
Exemple #11
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Number,IssueDate,DueDate,InversTaxing,VatCollecting,Description,Currecy,VAT,Weight,TotalValue,TotalVat,TotalAmount,Observations,ClientSoldInfo,PaymentMethod")] InvoiceHeader invoiceHeader)
        {
            if (id != invoiceHeader.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(invoiceHeader);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InvoiceHeaderExists(invoiceHeader.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(invoiceHeader));
        }
Exemple #12
0
    private void LoadInvoice(string invoiceNo)
    {
        InvoiceHeader invoiceHeader = invoiceProvider.GetInvoice(invoiceNo);
        IEnumerable <InvoiceDetailViewModel> invoiceDetail = null;

        if (invoiceHeader != null)
        {
            lblInvoiceNo.Text           = invoiceHeader.InvoiceNo;
            lblCustomer.Text            = String.Format("{0} - {1} {2}", invoiceHeader.Customer.Barcode, invoiceHeader.Customer.FirstName, invoiceHeader.Customer.LastName);
            lblNotes.Text               = invoiceHeader.Notes;
            calInvoiceDate.SelectedDate = invoiceHeader.Date;
            calPaymentDate.SelectedDate = DateTime.Today;
            lblEmployee.Text            = String.Format("{0} - {1} {2}", invoiceHeader.Employee.Barcode, invoiceHeader.Employee.FirstName, invoiceHeader.Employee.LastName);
            lblNotes.Text               = invoiceHeader.Notes;
            //lblDiscountValue.Text = invoiceHeader.DiscountValue.ToString("###,##0.00");
            invoiceDetail         = _InvoiceDetail = invoiceProvider.GetDetail(invoiceNo).ToList();
            gvwInvoice.DataSource = _InvoiceDetail;
            gvwInvoice.DataBind();

            decimal totalAfterTax  = invoiceDetail.Any() ? invoiceDetail.Sum(inv => inv.Total) - invoiceHeader.DiscountValue : 0M;
            decimal totalBeforeTax = invoiceDetail.Any() ? invoiceDetail.Sum(i => ((i.UnitPrice * i.Quantity) - (i.Discount / 100 * (i.UnitPrice * i.Quantity))) / (i.IsTaxable ? 1.1M : 1M)) - invoiceHeader.DiscountValue : 0;
            lblTotalBeforeTax.Text = totalBeforeTax.ToString("###,##0.00");
            lblTotalInvoice.Text   = totalAfterTax.ToString("###,##0.00");
            lblTotalTax.Text       = (totalAfterTax - totalBeforeTax).ToString("###,##0.00");

            ViewState["_totalInvoice"] = totalAfterTax;
        }
    }
Exemple #13
0
        private void btnInvoiceAdd_Click(object sender, EventArgs e)
        {
            if (!ProductInputControl())
            {
                return;
            }

            InvoiceHeader invoiceHeader = new InvoiceHeader()
            {
                InvoiceID      = invoiceID,
                invoiceDetails = invoiceDetails,
                InvoiceDate    = DateTime.Now,
                DeliveryNote   = Convert.ToInt32(tbWaybillNumber.Text),
                CustomerID     = selectedCustomer.CustomerID,
                PaymentDate    = dtpPaymentDate.Value
            };
            // invoiceHeader.
            DbContextTransaction transaction = db.Database.BeginTransaction();

            try
            {
                db.InvoiceHeaders.Add(invoiceHeader);
                db.SaveChanges();
                ProductInputClear();
                transaction.Commit();
            }
            catch (Exception)
            {
                transaction.Rollback();
                MessageBox.Show("Beklenmeyen bir hata oluştu.");
            }
        }
        public int ProcessBillingResult(string batchNo, string fileName)
        {
            List <BillingRejectionViewModel> rejections = ReadBillingResultFile(fileName).ToList();

            foreach (BillingRejectionViewModel rejection in rejections)
            {
                InvoiceHeader invoice = context.InvoiceHeaders.SingleOrDefault(ih => ih.InvoiceNo == rejection.InvoiceNo && !ih.VoidDate.HasValue);
                if (invoice != null)
                {
                    var payments = invoice.PaymentHeaders.Where(ph => !ph.VoidDate.HasValue);
                    foreach (var payment in payments)
                    {
                        payment.VoidDate   = DateTime.Today;
                        payment.VoidReason = "AUTO PAY DECLINED: " + rejection.DeclineCode;
                    }

                    var status = new CustomerStatusHistory();
                    status.Customer         = invoice.Customer;
                    status.Date             = DateTime.Today;
                    status.CustomerStatusID = 4; // billing problem
                    status.Notes            = "AUTO PAY DECLINED OF INVOICE " + invoice.InvoiceNo + ", REJECTION CODE: " + rejection.DeclineCode;
                    status.StartDate        = DateTime.Today;
                    EntityHelper.SetAuditFieldForInsert(status, principal.Identity.Name);
                }
            }

            BillingHeader billing = context.BillingHeaders.SingleOrDefault(b => b.BatchNo == batchNo);

            if (billing != null)
            {
                billing.ResultProcessDate = DateTime.Now;
                foreach (var detail in billing.BillingDetails)
                {
                    var rejection =
                        rejections.SingleOrDefault(reject => reject.InvoiceNo == detail.InvoiceHeader.InvoiceNo);
                    if (rejection != null)
                    {
                        detail.BillingResult = rejection.DeclineCode;
                    }
                }
            }

            context.SaveChanges();

            return(rejections.Count);

            //foreach (var billingDetail in billing.BillingDetails)
            //{
            //    InvoiceHeader invoice = billingDetail.InvoiceHeader;
            //    if (invoice != null)
            //    {
            //        PaymentHeader payment = invoice.PaymentHeaders.SingleOrDefault(ph => !ph.VoidDate.HasValue);
            //        if (payment != null)
            //        {
            //            payment.VoidDate = DateTime.Today;
            //            payment.VoidReason = "AUTO PAY DECLINED: " + rejection.DeclineCode;
            //        }
            //    }
            //}
        }
Exemple #15
0
        public async Task <IActionResult> PutVat([FromRoute] int id, [FromBody] InvoiceHeader Vat)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != Vat.ID)
            {
                return(BadRequest());
            }

            _context.Entry(Vat).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InvoiceHeaderExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #16
0
    protected void btnPopupOK_Click(object sender, EventArgs e)
    {
        InvoiceHeader invoiceHeader = invoiceProvider.GetInvoice(lblInvoiceNo.Text);

        _InvoiceDetail.Add(new InvoiceDetailViewModel()
        {
            ID              = 0,
            InvoiceID       = invoiceHeader.ID,
            ItemID          = Convert.ToInt32(ddlItem.SelectedValue),
            ItemBarcode     = itemProvider.Get(Convert.ToInt32(ddlItem.SelectedValue)).Barcode,
            ItemDescription = itemProvider.Get(Convert.ToInt32(ddlItem.SelectedValue)).Description,
            Quantity        = Convert.ToInt32(txtQuantity.Text),
            UnitPrice       = Convert.ToInt32(txtUnitPrice.Text),
            IsTaxable       = true,
            Discount        = 0,
            NetAmount       = (Convert.ToInt32(txtQuantity.Text) * Convert.ToInt32(txtUnitPrice.Text)) / 1.1M,
            Total           = (Convert.ToInt32(txtQuantity.Text) * Convert.ToInt32(txtUnitPrice.Text))
        });
        decimal totalAfterTax  = _InvoiceDetail.Any() ? _InvoiceDetail.Sum(inv => inv.Total) - invoiceHeader.DiscountValue : 0M;
        decimal totalBeforeTax = _InvoiceDetail.Any() ? _InvoiceDetail.Sum(i => ((i.UnitPrice * i.Quantity) - (i.Discount / 100 * (i.UnitPrice * i.Quantity))) / (i.IsTaxable ? 1.1M : 1M)) - invoiceHeader.DiscountValue : 0;

        lblTotalBeforeTax.Text = totalBeforeTax.ToString("###,##0.00");
        lblTotalInvoice.Text   = totalAfterTax.ToString("###,##0.00");
        lblTotalTax.Text       = (totalAfterTax - totalBeforeTax).ToString("###,##0.00");

        ViewState["_totalInvoice"] = totalAfterTax;
        CalculateTotalPayment();

        gvwInvoice.DataSource = _InvoiceDetail;
        gvwInvoice.DataBind();
    }
        protected void btnPopupOK_Click(object sender, EventArgs e)
        {
            if (SecurityService.ValidateLogin(txtUserName.Text, txtPassword.Text) &&
                EmployeeService.CanReprintInvoice(txtUserName.Text))
            {
                InvoiceHeader invoice = InvoiceService.GetInvoice(txtInvoiceNo.Text);

                //TODO
                //mopAuth.Hide();
                switch (invoice.InvoiceType)
                {
                case 'F':
                    Response.Redirect(String.Format("FreshMemberCompleted.aspx?InvoiceNo={0}", invoice.InvoiceNo));
                    break;

                case 'X':
                    Response.Redirect(String.Format("ExistingMemberCompleted.aspx?InvoiceNo={0}", invoice.InvoiceNo));
                    break;
                }
            }
            else
            {
                //TODO
                //mopAuth.Hide();
                WebFormHelper.SetLabelTextWithCssClass(lblStatus0,
                                                       "Invalid user name/password, or user does not have permission to reprint invoice.",
                                                       LabelStyleNames.ErrorMessage);
            }
        }
        private InvoiceHeader GetHead()
        {
            var header = new InvoiceHeader
            {
                TipoDocumento                = _tipoDoc == "03" ? TipoDocumentoElectronico.Boleta : TipoDocumentoElectronico.Factura,
                SerieDocumento               = GetSerie(),
                CorrelativoDocumento         = GenCorrelativo(),
                FechaEmision                 = DateTime.Now.Date,
                RucEmisor                    = _company.Ruc,
                NombreRazonSocialEmisor      = _company.RazonSocial,
                NombreComercialEmisor        = _company.NombreComercial,
                TipoDocumentoIdentidadEmisor = TipoDocumentoIdentidad.RegistroUnicoContribuyentes,
                CodigoMoneda                 = _grupo == GrupoPrueba.OtrasMonedas ? "USD" : "PEN",
                DetallesDocumento            = new List <InvoiceDetail>(_lines),
                Impuesto        = new List <TotalImpuestosType>(),
                DireccionEmisor = GetDireccion(),
                Compra          = "000023",
                CorreoCliente   = "*****@*****.**"
            };

            SetCustomBodyByGroup(header);

            foreach (var item in Enumerable.Range(1, _lines))
            {
                header.DetallesDocumento.Add(new InvoiceDetail
                {
                    CodigoProducto      = "PROD00" + item,
                    Cantidad            = 1,
                    DescripcionProducto = "PRODUCTO PRUEBA " + item,
                    PrecioUnitario      = 100,
                    UnidadMedida        = "NIU"
                });
            }
            return(header);
        }
        private void SetCustomBodyByGroup(InvoiceHeader head)
        {
            switch (_grupo)
            {
            case GrupoPrueba.Anticipos:
                head.TipoOperacion = TipoOperacion.VentaInternaAnticipos;
                break;

            case GrupoPrueba.EmisorItinerante:
                head.TipoOperacion          = TipoOperacion.VentaItinerante;
                head.GuiaRemisionReferencia = new List <GuiaRemisionType>
                {
                    new GuiaRemisionType
                    {
                        IdTipoGuiaRemision = "09",
                        NumeroGuiaRemision = "T001-1"
                    }
                };
                break;

            case GrupoPrueba.RegulacionAnticipos:
                head.TotalAnticipos = 10;
                head.Anticipos      = new List <AnticipoType>
                {
                    new AnticipoType
                    {
                        MontoAnticipo  = head.TotalAnticipos.Value,
                        NroDocumentRel = "F001-1",
                        RucEmisorDoc   = head.RucEmisor,
                        TipoDocRel     = DocRelTributario.FacturaAnticipos
                    }
                };
                break;
            }
        }
Exemple #20
0
        public ActionResult DeleteConfirmed(int id)
        {
            InvoiceHeader invoiceHeader = db.InvoiceHeaders.Find(id);

            db.InvoiceHeaders.Remove(invoiceHeader);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #21
0
        public void MapFromDomainEntity_NullContent_ReturnNull()
        {
            //Act
            var response = InvoiceHeader.MapFromDomainEntity(null);

            //Assert
            Assert.IsNull(response);
        }
        private void Calculator(InvoiceHeader header)
        {
            var tipIgv = GetTipoIgv();
            var sum    = 0M;

            foreach (var detail in header.DetallesDocumento)
            {
                detail.ValorVenta = detail.Cantidad * detail.PrecioUnitario;
                var isc = 0M;

                detail.Impuesto = new List <TotalImpuestosType>();
                if (_grupo == GrupoPrueba.ConIsc)
                {
                    isc = 0.17M * detail.PrecioUnitario * detail.Cantidad;
                    detail.Impuesto.Add(new TotalImpuestosType
                    {
                        TipoIsc     = TipoSistemaIsc.SistemValor,
                        TipoTributo = TipoTributo.ISC_EXC,
                        Monto       = isc// 17% ISC
                    });
                }


                detail.Impuesto.Add(new TotalImpuestosType
                {
                    Monto          = tipIgv == TipoAfectacionIgv.GravadoOperacionOnerosa ? (detail.ValorVenta + isc) * 0.18M : 0,
                    TipoAfectacion = tipIgv,
                    TipoTributo    = TipoTributo.IGV_VAT
                });

                detail.PrecioAlternativos = new List <PrecioItemType>
                {
                    new PrecioItemType
                    {
                        Monto        = _grupo == GrupoPrueba.Gratuita ? 0 : detail.PrecioUnitario * 1.18M,
                        TipoDePrecio = TipoPrecioVenta.PrecioUnitario
                    }
                };

                if (_grupo == GrupoPrueba.Gratuita)
                {
                    detail.PrecioAlternativos.Add(new PrecioItemType
                    {
                        Monto        = detail.PrecioUnitario,
                        TipoDePrecio = TipoPrecioVenta.ValorReferencial
                    });
                }
                sum += detail.ValorVenta;
            }
            header.TotalTributosAdicionales = new List <TotalTributosType>
            {
                new TotalTributosType
                {
                    Id           = GetOtrosConceptos(tipIgv),
                    MontoPagable = sum
                }
            };
        }
Exemple #23
0
    protected void btnReprint_Click(object sender, EventArgs e)
    {
        InvoiceHeader invoice = invoiceProvider.GetInvoice(txtInvoiceNo.Text);

        if (invoice != null)
        {
            mopAuth.Show();
        }
    }
Exemple #24
0
 public ActionResult Edit([Bind(Include = "InvoiceNo,AccountCode,Date,Vat,TotalSellexclVat,TotalCost")] InvoiceHeader invoiceHeader)
 {
     if (ModelState.IsValid)
     {
         db.Entry(invoiceHeader).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(invoiceHeader));
 }
Exemple #25
0
        private void updateInvoice(int invoiceID)
        {
            using (ClubDBEntities club = new ClubDBEntities())
            {
                InvoiceHeader result = (from o in club.InvoiceHeaders
                                        where o.InvID == invoiceID
                                        select o).First();
                decimal total = Convert.ToDecimal(tbTotal.Text);
                int     dis   = (string.IsNullOrEmpty(tbDis.Text)) ? 0 : Convert.ToInt32(tbDis.Text);
                decimal final = Convert.ToDecimal(tbFinal.Text);
                //decimal paid = Convert.ToDecimal(tbPaid.Text);
                //decimal rem = string.IsNullOrEmpty(tbRemain.Text) ? 0 : Convert.ToDecimal(tbRemain.Text);
                result.TotalAmount = total;
                result.Discount    = dis;
                result.FinalAmount = final;
                // result.PaidAmount = paid;
                // result.RemainAmount = rem;
                result.Notes  = tbNotes.Text;
                result.Status = InvoiceStatus.Complete.ToString();
                result.Type   = rbType.SelectedValue;
                club.SaveChanges();
                // create deposit
                Deposit deposit = new Deposit();
                deposit.InvID      = invoiceID;
                deposit.Notes      = tbNotes.Text;
                deposit.Date       = DateTime.Now.Date;
                deposit.Employee   = club.Employees.Where(a => a.UserName == User.Identity.Name).Select(o => o.Name).First();
                deposit.FromPerson = club.Clients.Where(a => a.ClientID == result.ClientID).First().FullName();

                switch (rbType.SelectedIndex)
                {
                case 0:
                    deposit.CheckNum = Convert.ToInt64(tbCheck.Text);
                    deposit.Bank     = tbBank.Text;

                    break;

                case 1:
                    decimal paid = Convert.ToDecimal(tbPaid.Text);
                    deposit.Amount = paid;

                    break;

                case 2:
                    decimal amount = Convert.ToDecimal(tbFinal.Text);
                    deposit.Amount = amount;
                    break;
                }
                club.Deposits.AddObject(deposit);
                club.SaveChanges();
                VoucherID = deposit.ID;
                InvID     = invoiceID;
            }
        }
Exemple #26
0
 public ActionResult InvoiceEdit(InvoiceHeaderViewModel invoiceHeader)
 {
     if (ModelState.IsValid)
     {
         InvoiceHeader IH = FromViewToModelHeader(invoiceHeader);
         db.Entry(IH).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("InvoiceList"));
     }
     return(View(invoiceHeader));
 }
Exemple #27
0
        public ActionResult Create([Bind(Include = "InvoiceNo,AccountCode,Date,Vat,TotalSellexclVat,TotalCost")] InvoiceHeader invoiceHeader)
        {
            if (ModelState.IsValid)
            {
                db.InvoiceHeaders.Add(invoiceHeader);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(invoiceHeader));
        }
        private void LoadTotal(InvoiceHeader head)
        {
            var subTotal = 0M;
            var mtoGrav  = 0M;

            foreach (var adicional in head.TotalTributosAdicionales)
            {
                switch (adicional.Id)
                {
                case OtrosConceptosTributarios.TotalVentaOperacionesGravadas:
                    mtoGrav += adicional.MontoPagable;
                    goto case OtrosConceptosTributarios.TotalVentaOperacionesExoneradas;

                case OtrosConceptosTributarios.TotalVentaOperacionesExoneradas:
                case OtrosConceptosTributarios.TotalVentaOperacionesInafectas:
                    subTotal += adicional.MontoPagable;
                    break;
                }
            }
            if (_grupo == GrupoPrueba.DescuentoGlobal)
            {
                head.DescuentoGlobal = 5; //TODO:  Se aplica a los Grav,Inaf,Exon.
            }

            var isc = 0M;

            if (_grupo == GrupoPrueba.ConIsc)
            {
                isc = subTotal * 0.17M;
                head.Impuesto.Add(new TotalImpuestosType
                {
                    TipoTributo = TipoTributo.ISC_EXC,
                    Monto       = isc
                });
            }

            var igv = (mtoGrav + isc - head.DescuentoGlobal) * 0.18M;

            head.Impuesto.Add(new TotalImpuestosType
            {
                TipoTributo = TipoTributo.IGV_VAT,
                Monto       = Math.Round(igv, 2, MidpointRounding.AwayFromZero)
            });

            head.TotalVenta     = Math.Round(subTotal + igv + isc, 2, MidpointRounding.AwayFromZero);
            head.InfoAddicional = new List <AdditionalPropertyType>
            {
                new AdditionalPropertyType
                {
                    ID    = "1000",
                    Value = "MONTO EN LETRAS"
                }
            };
        }
Exemple #29
0
        public async Task <IActionResult> Create([Bind("Id,Number,IssueDate,DueDate,InversTaxing,VatCollecting,Description,Currecy,VAT,Weight,TotalValue,TotalVat,TotalAmount,Observations,ClientSoldInfo,PaymentMethod")] InvoiceHeader invoiceHeader)
        {
            if (ModelState.IsValid)
            {
                _context.Add(invoiceHeader);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(invoiceHeader));
        }
        public static void DataBase(DataTable dataTable)
        {
            try
            {
                using (var dbContext = new ApplicationDBContext())
                {
                    List <InvoiceHeader> invoiceHeaderList = new List <InvoiceHeader>();

                    foreach (DataRow row in dataTable.Rows)
                    {
                        //define header line
                        InvoiceHeader invoiceHeader = new InvoiceHeader
                        {
                            InvoiceNumber = row["Invoice Number"].ToString(),
                            InvoiceDate   = Convert.ToDateTime(row["Invoice Date"].ToString(), CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat),
                            Address       = row["Address"].ToString(),
                            InvoiceTotal  = Single.Parse(row["Invoice Total Ex VAT"].ToString(), CultureInfo.InvariantCulture.NumberFormat)
                        };

                        //check for duplications
                        if (!(invoiceHeaderList.Any(x => x.InvoiceNumber == invoiceHeader.InvoiceNumber)))
                        {
                            //add headerline to database
                            dbContext.InvoiceHeaders.Add(invoiceHeader);
                            dbContext.SaveChanges();
                        }

                        //A list of all invoiceHeaders
                        invoiceHeaderList.Add(invoiceHeader);
                    }

                    foreach (DataRow row in dataTable.Rows)
                    {
                        //define new invoice line
                        InvoiceLine invoiceLine = new InvoiceLine
                        {
                            InvoiceNumber         = row["Invoice Number"].ToString(),
                            Description           = row["Line description"].ToString(),
                            Quantity              = Single.Parse(row["Invoice Quantity"].ToString(), CultureInfo.InvariantCulture.NumberFormat),
                            UnitSellingPriceExVAT = Single.Parse(row["Unit selling price ex VAT"].ToString(), CultureInfo.InvariantCulture.NumberFormat)
                        };

                        //Add line to data base
                        dbContext.InvoiceLines.Add(invoiceLine);
                        dbContext.SaveChanges();
                    }
                }
            }
            catch (Exception)
            {
                //throw exeption to the calling function
                throw;
            }
        }
        public void AddInvoiceHeader()
        {
            var testDbSet = new TestDbSet<InvoiceHeader>(_dataCollection);
            var testInvoiceHeaderDao = new TestInvoiceHeaderDao(testDbSet);

            var invoiceHeaderToAdd = new InvoiceHeader
            {
                Id = 4,
                Customer = "TestCustomer3",
                InvoiceDateTime = DateTime.MinValue,
                InvoiceNumber = 5,
                Supplier = "TestSupplier3",
                Tax = 80,
                Total = 9000
            };

            testInvoiceHeaderDao.Write(invoiceHeaderToAdd);

            Assert.IsTrue(testDbSet.DataCollection.Contains(invoiceHeaderToAdd));
        }
 public void Write(InvoiceHeader entity)
 {
     _testDbSet.DataCollection.Add(entity);
 }
        /// <summary>
        /// Returns the invoice header - this is currently used only by rejection invoices.
        /// </summary>
        /// <param name="headerData"></param>
        /// <returns></returns>
        private InvoiceHeader GetInvoiceHeader(FlatRejectionRecord headerData)
        {
            InvoiceHeader invoiceHeader = new InvoiceHeader();
            invoiceHeader.InvoiceNumber = headerData.InvoiceNumber;
            invoiceHeader.InvoiceDate = string.Format("{0:yyyy-MM-dd}", headerData.InvoiceDate);
            invoiceHeader.InvoiceType = InvoiceType.Invoice;
            invoiceHeader.ChargeCategory = Constants.ChargeCategory;
            //Seller Organization
            SellerOrganization sellerOrganization = new SellerOrganization();
            sellerOrganization.OrganizationID = Constants.SellerOrganizationID;
            invoiceHeader.SellerOrganization = sellerOrganization;
            //Buyer Organization
            BuyerOrganization buyerOrganization = new BuyerOrganization();
            buyerOrganization.OrganizationID = headerData.BuyerOrganizationID;
            invoiceHeader.BuyerOrganization = buyerOrganization;
            //Payment Terms
            PaymentTerms paymentTerms = new PaymentTerms();
            paymentTerms.CurrencyCode = string.IsNullOrWhiteSpace(headerData.CurrencyCode) ? Constants.ClearanceCurrency : headerData.CurrencyCode;
            paymentTerms.ClearanceCurrencyCode = Constants.ClearanceCurrency;
            paymentTerms.ExchangeRate = paymentTerms.CurrencyCode == Constants.ClearanceCurrency ? 1.00000m : headerData.ExchangeRate;
            paymentTerms.ExchangeRateSpecified = true;
            paymentTerms.SettlementMethod = SettlementMethod.I;
            paymentTerms.SettlementMethodSpecified = true;

            paymentTerms.SettlementMonthPeriod = IATAPeriodHelper.GetIATAPeriodForXML(_iATAPeriod);
            invoiceHeader.PaymentTerms = paymentTerms;
            //ISDetails
            ISDetails isDetails = new ISDetails();
            isDetails.DigitalSignatureFlag = DigitalSignatureFlag.Y;
            invoiceHeader.ISDetails = isDetails;
            return invoiceHeader;
        }
        public void DeleteInvoiceHeader()
        {
            var testDbSet = new TestDbSet<InvoiceHeader>(_dataCollection);
            var testInvoiceHeaderDao = new TestInvoiceHeaderDao(testDbSet);

            var invoiceHeaderToRemove = new InvoiceHeader
            {
                Id = 1,
                Customer = "TestCustomer",
                InvoiceDateTime = DateTime.MinValue,
                InvoiceNumber = 1,
                Supplier = "TestSupplier",
                Tax = 0,
                Total = 100
            };

            testInvoiceHeaderDao.Delete(invoiceHeaderToRemove);

            Assert.IsFalse(testDbSet.DataCollection.Contains(invoiceHeaderToRemove));
        }
 public void Delete(InvoiceHeader entity)
 {
     _testDbSet.DataCollection.Remove(entity);
 }