Пример #1
0
        /// <summary>
        /// Crea una nota de crédito por el monto especificado.
        /// </summary>
        /// <param name="creditNoteTS"></param>
        /// <param name="amount"></param>
        /// <returns></returns>
        private bool SaveCreditNote(CreditNote creditNoteTS, double amount)
        {
            CreditNoteManager creditNoteManager = new CreditNoteManager();

            CreditNote creditNote = new CreditNote();

            creditNote.Amount      = amount * -1;
            creditNote.Date        = DateTime.Now;
            creditNote.Status      = CreditNote.StatusType.Aprobada;
            creditNote.Observation = "Remanente de pago: " + creditNoteTS.Id + " (monto original: " + creditNote.Amount + ")";
            creditNote.User        = creditNoteTS.User;
            creditNote.InvoiceId   = creditNoteTS.InvoiceId;
            return(creditNoteManager.Save(creditNote));
        }
Пример #2
0
        /// <summary>
        /// Genera el PDF para la descarga de la factura
        /// </summary>
        public string DownloadInvoice(int id)
        {
            AddressManager    addressManager    = new AddressManager();
            UserManager       userManager       = new UserManager();
            CreditNoteManager creditNoteManager = new CreditNoteManager();
            CreditCardManager creditCardmanager = new CreditCardManager();
            InvoiceItemMapper invoiceItemMapper = new InvoiceItemMapper();
            InvoiceMapper     invoiceMapper     = new InvoiceMapper();

            Invoice invoice = invoiceMapper.Get(id);

            invoice.BillingAddress = addressManager.Get(invoice.BillingAddress.Id);
            invoice.User           = userManager.Get(invoice.User.Id);
            invoice.InvoiceItems   = invoiceItemMapper.Get(invoice);

            foreach (InvoiceItem invoiceItem in invoice.InvoiceItems)
            {
                invoiceItem.Resource = new MapManager().Get(invoiceItem.Resource.Id);
            }

            invoice.CreditNotes = creditNoteManager.GetUsedByInvoice(invoice);
            invoice.CreditCard  = creditCardmanager.Get(invoice);

            if (invoice.CreditCard != null)
            {
                invoice.CreditCard.Field1 = SecurityHelper.RDesencrypt(invoice.CreditCard.Field1);
                invoice.CreditCard.Field4 = SecurityHelper.RDesencrypt(invoice.CreditCard.Field4);
            }

            string fullPath = PDFHelper.CreateInvoice(invoice);

            if (String.IsNullOrEmpty(fullPath))
            {
                string errorDescription = "Se ha producido un error al generar el archivo de la factura.";
                log.AddLogCritical("DownloadInvoice", errorDescription, this);
                AddError(new ResultBE(ResultBE.Type.FAIL, errorDescription));
            }

            return(fullPath);
        }
Пример #3
0
        /// <summary>
        /// Actualiza el estado de las notas para marcarlas como usadas.
        /// </summary>
        /// <param name="usedCreditNotes"></param>
        /// <returns></returns>
        private bool ChangeStateToUsed(List <CreditNote> usedCreditNotes)
        {
            CreditNoteManager creditNoteManager = new CreditNoteManager();

            return(creditNoteManager.ChangeStateToUsed(usedCreditNotes));
        }