public static async Task<Invoice> AddAndGetInvoice(Dinero dinero)
        {
            Console.WriteLine("\nBefore creating a invoice we need a contact...");
            var contact = await ContactDemo.AddEanContact(dinero);
            var invoice = await AddNewInvoice(dinero, contact.ContactGuid);
            if (invoice != null)
                return await GetInvoice(dinero, invoice.Guid);

            return null;
        }
Example #2
0
        public async Task <ActionResult <Dinero> > PostDinero(Dinero dinero)
        {
            _context.Dinero.Add(dinero);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDinero", new { id = dinero.IdDinero }, dinero));
        }
        public void DebeDevolverClp1200AlSumarChf10()
        {
            var chf10 = new Dinero(Divisa.Chf, 10);
            var clp1200 = new Dinero(Divisa.Clp, 1200);

            Assert.AreEqual(clp1200, _clp200.Sumar(chf10));
        }
Example #4
0
        private Dinero CalcularValorAPagar(int cantidadDias, Dinero salarioBase, decimal porcentajeReconocimiento)
        {
            decimal valorAPagarDiario = salarioBase.Cantidad * porcentajeReconocimiento;
            decimal valorAPagarTotal  = valorAPagarDiario * cantidadDias;

            return(new Dinero(valorAPagarTotal, salarioBase.Moneda));
        }
        public static void AuthorizeUsingRefreshToken(Dinero dinero, string clientId, string clientSecret)
        {
            //Calling authorize against the api
            var token = dinero.Authorize();
            //Get refresh token
            var refreshtoken = token.RefreshToken;

            if (refreshtoken == null)
            {
                Console.WriteLine("You do not have permission to use access tokens.");
                return;
            }

            Console.WriteLine("Refreshtoken obtained.");
            //TODO: persist the refresh token in db for later use

            Console.WriteLine("Instantiate new Dinero object using refresh token.");

            var client = new ClientCredentials(clientId, clientSecret);
            //instantiate using refresh token
            var dinero2 = new Dinero(client, new RefreshToken(refreshtoken));

            //Calling authorize against the api
            dinero2.Authorize();

            Console.WriteLine("Authorization successfull.");
        }
        public static async Task AddGetUpdateTradeOffer(Dinero dinero)
        {
            var tradeoffer = await AddAndGetNewTradeOffer(dinero);
            var productLines = new List<TradeOfferLineCreate>();
            foreach (var line in tradeoffer.ProductLines)
            {
                productLines.Add(new TradeOfferLineCreate()
                {
                    Description = line.Description,
                    BaseAmountValue = line.BaseAmountValue,
                    AccountNumber = line.AccountNumber,
                    Unit = line.Unit,
                    Quantity = line.Quantity,
                    Comments = line.Comments
                });
            }
            var updateObj = new TradeOfferUpdate()
            {
                Timestamp = tradeoffer.TimeStamp,
                ContactGuid = tradeoffer.ContactGuid,
                ExternalReference = "I've updated this invoice!",
                ProductLines = productLines
            };

            await dinero.TradeOffers.UpdateAsync(tradeoffer.Guid, updateObj);
            Console.WriteLine("Trade offer updated.");
        }
 public static async Task AddGetUpdateCreditNote(Dinero dinero)
 {
     var creditNote = await AddAndGetCreditNote(dinero);
     var productLines = new List<InvoiceLineCreate>();
     foreach (var line in creditNote.ProductLines)
     {
         productLines.Add(new InvoiceLineCreate()
         {
             Description = line.Description,
             BaseAmountValue = line.BaseAmountValue,
             AccountNumber = line.AccountNumber,
             Unit = line.Unit,
             Quantity = line.Quantity,
             Comments = line.Comments
         });
     }
     var updateObj = new SalesCreditNoteUpdate()
     {
         CreditNoteFor = creditNote.CreditNoteFor,
         Timestamp = creditNote.TimeStamp,
         ContactGuid =  creditNote.ContactGuid,
         ExternalReference = "I've updated this credit note!",
         ProductLines = productLines
     };
     await dinero.Sales.CreditNotes.UpdateAsync(creditNote.Guid, updateObj);
     Console.WriteLine("CreditNote updated.");
 }
 public static async Task<InvoiceFetch> FetchInvoice(Dinero dinero)
 {
     Console.WriteLine("\nWe need a contact...");
     var contact = await ContactDemo.AddEanContact(dinero);
     var invoice = await FetchInvoice(dinero, contact.ContactGuid);
     return invoice;
 }
 public void Inicializar()
 {
     _clp200 = new Dinero(new StubCurrencyService())
     {
         Monto = 200, Moneda = Divisa.Clp
     };
 }
 public static async Task UploadSampleImage(Dinero dinero)
 {
     var currentdir = Directory.GetCurrentDirectory();
     var path = Path.Combine(currentdir, "sample-invoice.jpg");
     var result = await dinero.FileUpload.AddImageAsync(path);
     Console.WriteLine("Image uploaded. FileGuid: " + result.FileGuid);
 }
Example #11
0
        public async Task <IActionResult> PutDinero(int id, Dinero dinero)
        {
            if (id != dinero.IdDinero)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #12
0
 public DetalleReconocimientoEconomico(int idIncapacidad, string fechaInicial, string fechaFinal, Dinero valorAPagar, string responsablePago)
 {
     IdIncapacidad   = idIncapacidad;
     FechaInicial    = fechaInicial;
     FechaFinal      = fechaFinal;
     ValorAPagar     = valorAPagar;
     ResponsablePago = responsablePago;
 }
        private static async Task<Product> AddNewProduct(Dinero dinero, ProductCreateModel model)
        {
            var productCreatedResult = await dinero.Products.AddAsync(model);

            var guid = productCreatedResult.ProductGuid;
            Console.WriteLine("product created. Name: " + model.Name + " (" + guid + ")");

            return await Getproduct(dinero, guid);
        }
        public static async Task GenerateInvoice(Dinero dinero)
        {
            var tradeoffer = await AddAndGetNewTradeOffer(dinero);
            var createdResult = await dinero.TradeOffers.GenerateInvoiceAsync(tradeoffer.Guid, 
                tradeoffer.TimeStamp); // timestamp is optional, use it to verify you got the latest version of the trade offer

            Console.WriteLine("Invoice generated from trade offer");
            var generatedInvoice = await InvoiceDemo.GetInvoice(dinero, createdResult.Guid);
        }
        private static async Task<Contact> AddNewContact(Dinero dinero, ContactCreate model)
        {
            var contactCreatedResult = await dinero.Contacts.AddAsync(model);
            
            var guid = contactCreatedResult.ContactGuid;
            Console.WriteLine("Contact created. Name: " + model.Name + " (" + guid + ")");

            return await GetContact(dinero, guid);
        }
        public void DebeDevolverClp1200AlSumarChf10()
        {
            var chf10   = new Dinero(Divisa.Chf, 10);
            var clp1200 = new Dinero(Divisa.Clp, 1200);



            Assert.AreEqual(clp1200, _clp200.Sumar(chf10));
        }
        public static async Task ListAllproducts(Dinero dinero, string filter = null, DateTime? changedSince = null, bool? includeDeleted = null)
        {
            var collectionResult = await dinero.Products.GetListAsync("Name,Quantity,Unit,BaseamountValue,CreatedAt,UpdatedAt,DeletedAt", filter, changedSince);

            foreach (var product in collectionResult.Collection)
            {
                Console.WriteLine(ProductToPrintableString(product));
            }
            Console.WriteLine("\nFound {0} products", collectionResult.Collection.Count);
        }
        public static async Task GetList(Dinero dinero, string freeTextSearch = null, string statusFilter = null, DateTime? changedSince = null, bool? includeDeleted = null)
        {
            SalesVoucherCollection collectionResult = await dinero.Sales.GetListAsync(null, null, "Number,ContactName,Date,Description,Status,Type,TotalInclVat,UpdatedAt,DeletedAt", freeTextSearch, statusFilter, changedSince, includeDeleted);

            foreach (var creditNote in collectionResult.Collection)
            {
                Console.WriteLine(CreditNoteToPrintableString(creditNote));
            }
            Console.WriteLine("\nFound {0} sales vouchers", collectionResult.Collection.Count);
        }
        public static async Task<TradeOffer> AddAndGetNewTradeOffer(Dinero dinero)
        {
            Console.WriteLine("\nBefore creating a tradeoffer we need a contact...");
            var contact = await ContactDemo.AddNewContact(dinero);
            var tradeoffer = await AddNewTradeOffer(dinero, contact.ContactGuid);
            if (tradeoffer != null)
                return await GetTradeOffer(dinero, tradeoffer.Guid);

            return null;
        }
 public static async Task<Contact> AddNewContact(Dinero dinero)
 {
     //initalize ContactCreated with min required properties
     var model = new ContactCreate()
     {
         Name = GetRandomName(),
         CountryKey = "DK"
     };
     return await AddNewContact(dinero, model);
 }
 public static async Task<Invoice> AddAndBookInvoice(Dinero dinero)
 {
     var invoice = await AddAndGetInvoice(dinero);
     if (invoice != null)
     {
         var bookedResponse = await BookInvoice(dinero, invoice.Guid, invoice.TimeStamp);
         //update with latest timestamp
         invoice.TimeStamp = bookedResponse.TimeStamp;
     }
     return invoice;
 }
 public static async Task<SalesCreditNote> AddAndBookCreditNote(Dinero dinero)
 {
     var CreditNote = await AddAndGetCreditNote(dinero);
     if (CreditNote != null)
     {
         var bookedResponse = await BookCreditNote(dinero, CreditNote.Guid, CreditNote.TimeStamp);
         //update with latest timestamp
         CreditNote.TimeStamp = bookedResponse.TimeStamp;
     }
     return CreditNote;
 }
        public static async Task AddNewPurchaseVoucher(Dinero dinero)
        {
            var model = new PurchaseVoucherCreate
            {
                VoucherDate = "2015-12-02",
                Notes = "Some very important notes!"
            };

            var createdResult = await dinero.PurchaseVouchers.AddAsync(model);
            Console.WriteLine("Voucher created. New voucher id: " + createdResult.VoucherGuid);
        } 
Example #24
0
 public Empleado(int id, string nombres, string apellidos, Dinero salario, TipoSalario tipoSalario)
 {
     Id            = id;
     Nombres       = nombres;
     Apellidos     = apellidos;
     Salario       = salario;
     SalarioDiario = new Dinero(salario.Cantidad / 30, salario.Moneda);
     SalarioDiarioPorPorcentajeSalario      = new Dinero(SalarioDiario.Cantidad * tipoSalario.PorcentajeSalario, salario.Moneda);
     SalarioDiarioPorPorcentajeCompensacion = new Dinero(SalarioDiario.Cantidad * tipoSalario.PorcentajeCompensacion, salario.Moneda);
     TipoSalario = tipoSalario;
 }
        public static async Task<SalesCreditNote> AddAndGetCreditNote(Dinero dinero)
        {
            //Console.WriteLine("\nBefore creating a CreditNote we need a contact...");
            //var contact = await ContactDemo.AddEanContact(dinero);
            var invoice =await InvoiceDemo.AddAndBookInvoice(dinero);

            var CreditNote = await AddNewCreditNote(dinero, invoice.Guid, invoice.ContactGuid);
            if (CreditNote != null)
                return await GetCreditNote(dinero, CreditNote.Guid);

            return null;
        }
Example #26
0
 public bool Equals(Dinero other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other._convertCurrencyService, _convertCurrencyService) && other.Monto == Monto && Equals(other.Moneda, Moneda));
 }
Example #27
0
        private void Button1_Click(object sender, EventArgs e)
        {
            // Declaraciones que no entiendo bien pero son nnecesarias
            Dinero d = new Dinero();
            int    Billete;
            int    cambio;


            // Asumo que el sensor detecta un billete de 10 sopes
            Billete = d.Identificar(Convert.ToInt32(dato));

            // Genero un valor random para el total de caja chica hasta el momento
            Interfaz compra        = new Interfaz();
            int      total_general = total.TotalContabilidad;

            label4.Text = Convert.ToString(total_general);  //Muestro el valor para debuggear


            // Genero un valor random para el total que debe pagar el usuario
            Contabilidad T_U           = new Contabilidad();
            int          total_usuario = T_U.GenerarTotal();

            label5.Text = Convert.ToString(total_usuario); //Muestro el valor para debuggear

            // Asumir que billete es el valor total de plata que paga el cliente
            // En realidad se deberia usar otra varable que sume todas las entradas por si se ingresa mas de un billete
            // compra.Entrada(Billete, ref total_general);

            //Calcula el cambio que se le debe dar al usuario basado en lo que tiene que pagar y la plata con la que pago
            cambio = compra.Cambio(total_usuario, Billete);
            if (cambio < 0)
            {
                MessageBox.Show("El cambio no es el correcto", "Error Cambio", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                label6.Text = Convert.ToString(cambio);
            }                                                //Muestra el valor para debuggear

            // AQUI notifiquen cuanto es el cambio

            // Registra cuanta plata saca el cajero para dar el cambio
            compra.Salida(Billete, ref total_general);
            if (label9.Text == dato)
            {
                MessageBox.Show("La caja cuadra", "Arqueo Exitoso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                MessageBox.Show("La caja NO cuadra", "ALERTA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        public static async Task ListAllOrganizations(Dinero dinero)
        {
            Console.Write("Getting your organizations - please wait...");
            Console.WriteLine();

            var collection = await dinero.Organizations.GetListAsync("name,id,ispro,ispayingpro");

            foreach (var organization in collection)
            {
                Console.WriteLine("{0} - {1} - Dinero Pro: {2}", organization.Id, organization.Name, organization.IsPro ? "Yes!" : "No :(");                
            }
            Console.WriteLine("\nFound {0} organizations", collection.Count);
        }
 public static async Task<Contact> AddEanContact(Dinero dinero)
 {
     //initalize ContactCreated with min required properties
     var model = new ContactCreate()
     {
         Name = GetRandomName() + " Company",
         CountryKey = "DK",
         VatNumber = "12345678",
         EanNumber = "1234567890000",
         AttPerson = GetRandomName(),
     };
     return await AddNewContact(dinero, model);
 }
 /// <summary>
 /// Performs an asynchronous POST request to the Dinero API with the given binary body.
 /// </summary>
 /// <param name="dinero">An instance of the Dinero class. This is needed since it know about the user, the app and their credentials.</param>
 /// <param name="baseUri">The base URI to Dineo API. This is the URL without the path, but only the domain and API version.</param>
 /// <param name="requestParameters">Parameters to be used for generating the URL. Should contain the endpoint, the post body and any needed query parameters.</param>
 /// <param name="httpType">The type to determind if to use, get, post, delete or put</param>
 /// <param name="body">The body</param>
 internal async static Task<string> PerformAsync(Dinero dinero, Uri baseUri, Dictionary<string, string> requestParameters, HttpType httpType, byte[] body)
 {
     var url = BuildUri(dinero, baseUri, requestParameters).AbsoluteUri;
     var fileName = requestParameters[DineroApiParameterName.FileName];
     using (var content = new MultipartFormDataContent("-------abcdefg1234"))
     {
         var byteContent = new ByteArrayContent(body);
         var fileExtension = Path.GetExtension(fileName);
         byteContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MimeTypeMap.GetMimeType(fileExtension));
         content.Add(byteContent, MimeTypeMap.GetMimeTypeType(fileExtension), fileName);
         return await WorkAsync(dinero, httpType, url, content);
     }
 }
 public static async Task<Product> AddNewProduct(Dinero dinero)
 {
     var model = new ProductCreateModel
     {
         AccountNumber = 55000,
         Quantity = 20,
         Unit = "metre",
         Name = "test",
         //ProductNumber = "QXA",
         BaseAmountValue = 200,
     };
     return await AddNewProduct(dinero, model);
 }
        public static async Task ListAllEntryAccounts(Dinero dinero, string categoryFilter = null)
        {
            Console.WriteLine("Getting your entry accounts - please wait...");
            Console.WriteLine();

            var result = await dinero.Accounts.EntryAccountsGetListAsync(categoryFilter);

            foreach (var account in result)
            {
                Console.WriteLine("{0} - {1} - {2} - {3}", account.AccountNumber, account.Name, account.VatCode, account.Category);
            }
            Console.WriteLine("\nFound {0} accounts", result.Count);
        }
        private static async Task UpdateProduct(Dinero dinero, Product product)
        {
            var model = new ProductUpdateModel
            {
                AccountNumber = 1000,
                Quantity = 30,
                Unit = "km",
                Name = product.Name + " Updated",
                BaseAmountValue = 300,
            };

            await dinero.Products.UpdateAsync(product.ProductGuid, model);

            Console.WriteLine("Product updated");
        }
        public static async Task GetDashboard(Dinero dinero,DateTime? startDate = null, DateTime? endDate = null)
        {
            Console.WriteLine("Getting your dashboard data - please wait...");
            Console.WriteLine();

            var result = await dinero.Dashboard.GetDashboardAsync(startDate, endDate);

            Console.WriteLine("Periode: {0} - {1} Income: {2} Expenses: {3}", result.StartDate, result.EndDate, result.IncomeForPeriode, result.ExpenseForPeriode);
            Console.WriteLine("\nNumber of monthly results returned: {0}", result.MonthlyResults.Count);
            Console.WriteLine();

            foreach (var monthResult in result.MonthlyResults)
            {
                Console.WriteLine("Year: {0} Month: {1} Income: {2} Expenses: {3}", monthResult.Year, monthResult.Month, monthResult.Income, monthResult.Expense);
            }
        }
        public static async Task SendEmail(Dinero dinero, string receiverEmail)
        {
            //Creating the tradeoffer
            var tradeoffer = await AddAndGetNewTradeOffer(dinero);

            //Creating mailout model. None of the properties are mandatory.
            var mailoutModel = new MailOut()
            {
                //Timestamp = tradeoffer.TimeStamp,     //Defaults to latest version, but you can use this to ensure the offer has not been changed
                Sender = "*****@*****.**",           //Defaults to organization email
                Receiver = receiverEmail,               //Defaults to contact email. Make sure the contact has an email if you leave this empty.
                Message = "This is a test email from the demo API. To use the default logic for generating email,"      //Defaults to standard message
                          + " just leave this property empty. Here is a downlaod link to your tradeoffer: [link-to-pdf]"
            };

            await dinero.TradeOffers.SendEmailAsync(tradeoffer.Guid, mailoutModel);
            Console.WriteLine("Email was send to: " + receiverEmail);
        }
        public static async Task<Invoice> AddInvoiceAndPayment(Dinero dinero)
        {
            var invoice = await AddAndBookInvoice(dinero);
            var paymentResponse = await dinero.Sales.Invoices.AddPaymentAsync(invoice.Guid,new PaymentCreate()
            {
                Amount = 100,
                DepositAccountNumber = 55000,
                Description = "Payment of invoice test",
                Timestamp = invoice.TimeStamp
            });

            var invoicePayments = await dinero.Sales.Invoices.GetPaymentsAsync(invoice.Guid);
            Console.WriteLine("Invoice payments from server: \n[Invoice total incl. reminder: {0}] [Paid amount: {1}] [Remaining amount: {2}]", invoicePayments.InvoiceTotalIncludingReminderExpenses, invoicePayments.PaidAmount, invoicePayments.RemainingAmount);
            Console.WriteLine("Individual payments:");
            foreach (var payment in invoicePayments.Payments)
            {
                Console.WriteLine("{0} - {1} - {2}", payment.Description, payment.DepositAccountNumber, payment.Amount);
            }

            return null;
        }
        private const string PathToSavePdfsTo = null; // <- Replace with path

        static int Main()
        {
            var client = new ClientCredentials(ClientId, ClientSecret);
            var apiKey = new ApiKey(ApiKey);
            var dinero = new Dinero(client, apiKey, OrganizationId);

            //Calling authorize against the api
            dinero.Authorize();

            while (true)
            {
                PrintMenu();
                var userChoice = GetInput();
                if (userChoice.Equals("q", StringComparison.InvariantCultureIgnoreCase))
                {
                    return 0;
                }

                PerformAction(dinero, userChoice).ContinueWith(t => Pause()).Wait();
            }
        }
        public static async Task AddLedgerItems(Dinero dinero)
        {
            Console.WriteLine("Lets get you next voucher number first...");
            var nextVoucherNumberResult = await dinero.Ledgers.GetNextVoucherNumberForLedger();

            Console.WriteLine("The next voucher number is: {0}", nextVoucherNumberResult.NextVoucherNumber);
            Console.WriteLine("Now we are gonna make some ledger items. In a real app you would enter them in here...");
            var ledgerItemA = new CreateLedgerItem
            {
                AccountNumber = 1000,
                AccountVatCode = "I25",
                Amount = -175m,
                Description = "Momsfrit salg af spartelmasse",
                VoucherDate = "2015-02-07",
                VoucherNumber = nextVoucherNumberResult.NextVoucherNumber
            };
            var ledgerItemB = new CreateLedgerItem
            {
                AccountNumber = 55000,
                AccountVatCode = "none",
                Amount = 175m,
                Description = "Indsat på bank",
                VoucherDate = "2015-02-07",
                VoucherNumber = nextVoucherNumberResult.NextVoucherNumber
            };

            var ledgerItemCollection = new CreateLedgerItemCollection { ledgerItemA, ledgerItemB };

            Console.WriteLine("Now we'll add these two items:.");
            Console.WriteLine();
            foreach (var item in ledgerItemCollection)
            {
                Console.WriteLine("{0} Beløb: {1} Konto: {2}", item.Description, item.Amount, item.AccountNumber);
            }

            await dinero.Ledgers.AddAsync(ledgerItemCollection);

            Console.WriteLine();
            Console.WriteLine("Items added. Jubii!");
        }
        public static async Task SendECreditNote(Dinero dinero)
        {
            Console.WriteLine("We do not want to send a real E-CreditNote, so we send it to a fake EAN number.");
            Console.WriteLine("Therefor our goal is for the E-CreditNote service to reply that we gave it an invalid EAN number.\n");
            Console.WriteLine("To create the e-CreditNote we need a booked CreditNote...");

            //The CreditNote need to be booked
            var creditNote = await AddAndBookCreditNote(dinero);
            try
            {
                await dinero.Sales.CreditNotes.SendECreditNoteAsync(creditNote.Guid, creditNote.TimeStamp);
            }
            catch (DineroApiException e)
            {
                if (e.ResponseBody.Code == 57)
                {
                    Console.WriteLine("******* SUCCESS! *******");
                    Console.WriteLine("We reached the E-CreditNote service! (No E-CreditNote was send since we gave it a fake ean number.)");
                }
                else
                    throw;
            }
        }
Example #40
0
 public EntidadConValueObject(Dinero dinero, Dinero dinero2)
 {
     Dinero  = dinero;
     Dinero2 = dinero2;
 }
Example #41
0
        public Dinero Sumar(Dinero aSumar)
        {
            var monedaLocal = !Moneda.Equals(aSumar.Moneda) ? _convertCurrencyService.Convert(aSumar, Moneda) : aSumar;

            return(new Dinero(Moneda, Monto + monedaLocal.Monto));
        }
 public Dinero Convert(Dinero divisa, Divisa moneda)
 {
     return(new Dinero(moneda, divisa.Monto * 100));
 }
Example #43
0
        private void btnCaja_Click(object sender, EventArgs e)
        {
            //Se guarda el codigo del trabajador que esta logueado
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            config.AppSettings.Settings.Remove("codigo_caja");
            config.AppSettings.Settings.Add("codigo_caja", "");

            config.AppSettings.Settings.Remove("codigo_dinero");
            config.AppSettings.Settings.Add("codigo_dinero", "");

            config.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("appSettings");

            int idTienda = Convert.ToInt32(ConfigurationManager.AppSettings["id_tienda"], CultureInfo.InvariantCulture);


            Dinero dinero = new Dinero(idTienda)
            {
                billetes20        = billetes20,
                billetes50        = billetes50,
                billetes100       = billetes100,
                billetes200       = billetes200,
                billetes500       = billetes500,
                monedas1          = monedas1,
                monedas10         = monedas10,
                monedas2          = monedas2,
                monedas5          = monedas5,
                monedas50centavos = monedas50c
            };



            int codigoEmpleado = Convert.ToInt32(ConfigurationManager.AppSettings["codigo_trabajador"], CultureInfo.InvariantCulture);
            int dineroEnCaja   = Convert.ToInt32(Convert.ToDecimal(txboxCantidad.Text, CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);

            Caja caja        = new Caja(codigoEmpleado, idTienda, dineroEnCaja, dinero);
            Caja cajaMaestra = cnn.abrirCajaMaestra();

            if (cnn.iniciarElDia(caja, cajaMaestra))
            {
                config.AppSettings.Settings.Remove("codigo_caja");
                config.AppSettings.Settings.Add("codigo_caja", caja.idCaja.ToString());

                config.AppSettings.Settings.Remove("codigo_dinero");
                config.AppSettings.Settings.Add("codigo_dinero", caja.dinero.idDinero.ToString());

                config.AppSettings.Settings.Remove("caja_cerrada");
                config.AppSettings.Settings.Add("caja_cerrada", "cerrada");


                config.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("appSettings");

                string cajaCerrada = ConfigurationManager.AppSettings["caja_cerrada"];

                FormTomaOrden pantallaTomaOrden = new FormTomaOrden();
                pantallaTomaOrden.Show();
                this.Hide();
            }
        }
Example #44
0
 public ReconocimientoEconomico(int idEmpleado, DateTime fechaInicial, int cantidadDias, Dinero salarioBase, decimal porcentajeReconocimiento, Entidad responsablePago)
 {
     IdEmpleado      = idEmpleado;
     FechaInicial    = fechaInicial;
     FechaFinal      = fechaInicial.AddDays(cantidadDias - 1);
     ValorAPagar     = CalcularValorAPagar(cantidadDias, salarioBase, porcentajeReconocimiento);
     ResponsablePago = responsablePago;
 }
Example #45
0
        private void cerrarCaja(string idDineroCaja, string idCaja)
        {
            Dinero dineroEnCaja = cnn.consultarDineroEnCaja(idDineroCaja);

            string titulo = "Corte de caja";
            string turno  = string.Empty;

            string hora           = cnn.consultarFechaHoraInicioCaja(idCaja).Value.Hour.ToString();
            string horaMatutina   = ConfigurationManager.AppSettings["turno matutino"];
            string horaVespertina = ConfigurationManager.AppSettings["turno vespertino"];

            if (int.Parse(hora) >= int.Parse(horaMatutina) && int.Parse(hora) < int.Parse(horaVespertina))
            {
                turno = "M";
            }
            else
            {
                turno = "V";
            }

            Impresora ticket = new Impresora();
            string    fecha  = DateTime.Now.ToString("yyyy-dd-MM HH:MM:ss");

            ticket.AbreCajon();
            ticket.TextoIzquierda(titulo);
            ticket.TextoIzquierda("FECHA:" + fecha);
            ticket.TextoIzquierda("SUCURSAL:" + ConfigurationManager.AppSettings["nombre sucursal"]);
            ticket.TextoIzquierda("CAJERO DE CORTE:" + ConfigurationManager.AppSettings["codigo_trabajador"]);

            ticket.TextoIzquierda("");

            decimal dineroEfectivo = 0;
            decimal dineroTarjeta  = 0;

            if (turno == "M")
            {
                dineroEfectivo = Convert.ToDecimal(cnn.consultarGanaciasCaja("efectivo", idCaja), CultureInfo.InvariantCulture);
                dineroTarjeta  = Convert.ToDecimal(cnn.consultarGanaciasCaja("tarjeta", idCaja), CultureInfo.InvariantCulture);

                ticket.TextoIzquierda("T. Matutino");
                ticket.TextoIzquierda("EFECTIVO: $" + dineroEfectivo);
                ticket.TextoIzquierda("TARJETA: $" + dineroTarjeta);
                ticket.TextoIzquierda("TOTAL: " + (dineroEfectivo + dineroTarjeta));
            }
            else
            {
                dineroEfectivo = Convert.ToDecimal(cnn.consultarGanaciasCaja("efectivo", idCaja), CultureInfo.InvariantCulture);
                dineroTarjeta  = Convert.ToDecimal(cnn.consultarGanaciasCaja("tarjeta", idCaja), CultureInfo.InvariantCulture);

                ticket.TextoIzquierda("T.vespertino");
                ticket.TextoIzquierda("EFECTIVO: $" + dineroEfectivo);
                ticket.TextoIzquierda("TARJETA: $" + dineroTarjeta);
                ticket.TextoIzquierda("TOTAL: " + (dineroEfectivo + dineroTarjeta));
            }
            ticket.TextoIzquierda("VENTA TOTAL");
            ticket.TextoIzquierda("");
            ticket.TextoExtremos("$500.00", dineroEnCaja.billetes500.ToString());
            ticket.TextoExtremos("$200.00", dineroEnCaja.billetes200.ToString());
            ticket.TextoExtremos("$100.00", dineroEnCaja.billetes100.ToString());
            ticket.TextoExtremos("$50.00", dineroEnCaja.billetes50.ToString());
            ticket.TextoExtremos("$20.00", dineroEnCaja.billetes20.ToString());
            ticket.TextoExtremos("$10.00", dineroEnCaja.monedas10.ToString());
            ticket.TextoExtremos("$5.00", dineroEnCaja.monedas5.ToString());
            ticket.TextoExtremos("$2.00", dineroEnCaja.monedas2.ToString());
            ticket.TextoExtremos("$1.00", dineroEnCaja.monedas1.ToString());
            ticket.TextoExtremos("$0.50", dineroEnCaja.monedas50centavos.ToString());
            ticket.TextoExtremos("TOTAL: $", dineroEnCaja.cantidad.ToString());
            ticket.TextoIzquierda("Firma Cajero 1_____________");
            ticket.TextoDerecha("Firma Encargado ______________");
            ticket.TextoIzquierda("Firma Cajero 2_____________");
            ticket.CortaTicket();

            PrinterSettings settings = new PrinterSettings();

            ticket.ImprimirTicket(settings.PrinterName);


            cnn.cerrarCaja(fecha, idCaja, dineroEnCaja.cantidad, 0);
            MessageBox.Show("Caja cerrada");
        }