Documentos de Académico
Documentos de Profesional
Documentos de Cultura
ArchivetempMiTienda CPP
ArchivetempMiTienda CPP
//
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
#include <string>
#include <ctime>
#include <iomanip>
struct Comprador {
string nombre;
string apellidos;
string direccion;
};
struct Producto {
string codigo;
string descripcion;
double precio;
};
struct Fecha {
int dia;
int mes;
int anho;
int hor;
int min;
};
struct Detalle {
Producto prod;
int cantidad;
double costo;
};
struct Venta {
Fecha f;
Comprador comp;
double total;
double igv;
int nProds = 0;
Detalle prod[128];
int tipoMoneda = 0;
};
Venta venta[128];
int nVentas = 0;
Producto prod[128];
int nProds = 0;
string verFecha(Fecha f) {
return "" + to_string(f.dia) + "-" + to_string(f.mes) + "-" + to_string(f.anho) + " "
+ to_string(f.hor) + ":" + to_string(f.min);
}
localtime_s(&now, &t);
venta[idx].f.min = now.tm_min;
venta[idx].f.hor = now.tm_hour;
venta[idx].f.dia = now.tm_mday;
venta[idx].f.mes = now.tm_mon + 1;
venta[idx].f.anho = now.tm_year + 1900;
}
char menu() {
system("CLS");
char op;
cout << " MENU PRINCIPAL" << endl;
cout << " IGV: " << IGV << "%" << endl;
cout << " Ganancias: S/. " << ganancia << endl << endl;
if (!hayVenta)
cout << " 1. Nueva venta." << endl;
else
cout << " 1. Ver venta actual." << endl;
cout << " 2. Historial de Ventas." << endl;
cout << " 3. Nuevo producto." << endl;
cout << " 4. Ver productos." << endl;
cout << " 5. Cambiar IGV." << endl;
cout << " 6. Salir." << endl << endl;
return op;
}
int op;
cout << "Codigo \t Descripcion \t Precio U. (S/.) \t Cantidad \t SubTotal (S/.)" << endl;
double total = 0;
for (int i = 0; i < venta[idx].nProds; i++) {
Detalle d = venta[idx].prod[i];
Producto p = d.prod;
total += d.costo;
cout << p.codigo << "\t" << p.descripcion << "\t" << p.precio << "\t" << d.cantidad
<< "\t" << d.costo << endl;
}
cout << endl << "Total: " << total << endl;
cout << "Total con IGV: " << venta[idx].total << endl;
void verVentas() {
system("CLS");
int op, nro;
cout << "Nro \t Comprador \t Fecha \t Cant. Productos \t Moneda \t Costo Total (S/.)" <<
endl;
for (int i = 0; i < nVentas; i++) {
cout << i + 1 << "\t" << verComprador(venta[i].comp) << "\t" <<
verFecha(venta[i].f) << "\t"
<< venta[i].nProds << "\t" << moneda[venta[i].tipoMoneda] << "\t" <<
venta[i].total << endl;
}
void nuevoProducto() {
system("CLS");
cin.ignore();
cout << " Descripcion: ";
getline(cin, prod[nProds].descripcion);
nProds++;
}
void nuevaVenta() {
system("CLS");
cin.ignore();
cout << "Datos del Comprador: " << endl;
cout << " Apellidos: ";
getline(cin, venta[nVentas].comp.apellidos);
venta[nVentas].total = 0;
venta[nVentas].igv = IGV;
nVentas++;
hayVenta = true;
void verProductos() {
system("CLS");
if (hayVenta) {
cout << endl << " Deseas seleccionar producto? (SI = 1 / No = 0) : ";
cin >> op;
if (op) {
cout << " Ingrese codigo: ";
cin >> codigo;
int idx = buscarProducto(codigo);
if (idx != -1) {
cout << " Ingrese cantidad: ";
cin >> cant;
int i = buscarProducto(nVentas - 1, codigo);
double v = cant * prod[idx].precio;
if (i == -1) {
venta[nVentas - 1].prod[venta[nVentas - 1].nProds].prod =
prod[idx];
venta[nVentas - 1].prod[venta[nVentas -
1].nProds].cantidad = cant;
venta[nVentas - 1].prod[venta[nVentas - 1].nProds].costo =
v;
venta[nVentas - 1].nProds++;
}
else {
venta[nVentas - 1].prod[i].cantidad += cant;
venta[nVentas - 1].prod[i].costo += v;
}
venta[nVentas - 1].total += (1.0 + venta[nVentas - 1].igv / 100.0) *
v;
}
}
}
cout << endl;
system("PAUSE");
}
void cambiarIGV() {
system("CLS");
cout << " Valor IGV actual: " << IGV << "%" << endl;
cout << " Nuevo valor (%) : ";
cin >> IGV;
}
int main() {
char op;
return 0;
}