示例#1
0
def create():
    configuration = config.Config()
    if request.method == 'POST':
        client = Client(request.form)
        if client.is_valid_create():
            client.create_client()
            Alert.raise_success_alert('Client Created')

    return render_template('clients/create.html', configuration=configuration)
示例#2
0
def search():
    configuration = config.Config()
    if request.method == 'POST':
        clients = Client.get_filtered_clients(request.form)
    else:
        clients = Client.get_all_clients()

    return render_template('clients/search.html',
                           clients=clients,
                           configuration=configuration)
示例#3
0
文件: cart.py 项目: gadc1996/cali
def checkout():
    sale = Sale(request.form)
    configuration = config.Config()
    cart = ShoppingCart()
    cart_items = cart.cart_items
    clients = Client.get_all_clients()
    branchId = sale.branchId
    if request.form['Discount'] is not '':
        sale.apply_discount()

    if sale.is_valid(branchId):
        sale.create_sale(cart_items, branchId)
        cart.update_cart_items_stock(branchId)
        cart.clear_cart()
        sale.save_sale_ticket(cart_items)
        sale.print_sale_ticket(cart_items)
        Alert.raise_success_alert('Sale Created')
        return render_template('cart/checkout.html',
                               sale=sale,
                               configuration=configuration)

    return render_template('cart/info.html',
                           cart=cart,
                           cart_items=cart_items,
                           clients=clients,
                           configuration=configuration)
示例#4
0
文件: cart.py 项目: gadc1996/cali
def info():
    configuration = config.Config()
    cart = ShoppingCart()
    clients = Client.get_all_clients()
    cart_items = cart.cart_items
    return render_template('cart/info.html',
                           cart=cart,
                           cart_items=cart_items,
                           clients=clients,
                           configuration=configuration)
示例#5
0
def update(id):
    configuration = config.Config()
    if request.method == 'POST':
        client = Client(request.form)
        if client.is_valid_update():
            client.update_client(id)
            Alert.raise_success_alert('Client Updated')
    else:
        client = Client.get_client_by_id(id)

    return render_template('clients/update.html',
                           client=client,
                           configuration=configuration)
示例#6
0
    def __init__(self, iterable):
        self.userId = iterable['user_id']
        self.clientId = iterable['client_id']
        self.discount = iterable['Discount']
        self.totalArticles = iterable['total_articles']
        self.operationType = iterable['operation_type']
        self.creditTime = iterable['creditTime']

        self.total = Sale._get_total(iterable)
        self.branchId = Sale._get_branch_id(iterable)
        self.recivedCash = Sale._get_recived_cash(iterable)
        self.payMethodId = Sale._get_pay_method_id(iterable)

        self.id = self._get_id()
        self.date = self._get_date()
        self.payMethod = self._get_pay_method()
        self.change = self._get_change()

        self.user = User.get_username_by_id(self.userId)
        self.client = Client.get_name_by_id(self.clientId)
示例#7
0
    def create_txt_report(salesList, salesInformation):
        with open(f'cali/static/reports/sale_report.txt', 'w+') as ticket:
            ticket.write('\n\n     Cali Boutique \n')
            ticket.write('Ave. de la Cantera 9119 \n')
            ticket.write('Plaza Poniente 2do piso. \n')
            ticket.write('(614)184-1424 \n')
            ticket.write('Reporte de Ventas \n')
            ticket.write('------------------------- \n')

            ticket.write(f'Fecha: {salesInformation["date"]} \n')
            ticket.write(
                f'Ventas Totales: {salesInformation["total sales"]} \n')
            ticket.write(f'Ingreso Total: {salesInformation["total"]} \n')
            ticket.write(
                f'Ventas en Efectivo: {salesInformation["cash sales"]} \n')
            ticket.write(
                f'Total Ventas En Efectivo: {salesInformation["total cash sales"]} \n'
            )
            ticket.write(
                f'Ventas Con Tarjeta: {salesInformation["credit card sales"]} \n'
            )
            ticket.write(
                f'Total Ventas Con Tarjeta: {salesInformation["total credit card sales"]} \n'
            )

            ticket.write('------------------------- \n')
            ticket.write('Ventas \n')
            ticket.write('Id|Usuario|Cliente|Fecha|Total \n')

            for sale in salesList:
                user = User.get_user_by_id(sale['user_id'])
                client = Client.get_client_by_id(sale['client_id'])
                ticket.write(
                    f'{sale["id"]}|{user["username"]}|{client["name"]}|{sale["date"]}|{sale["total"]} \n'
                )

            ticket.write('\n\n\n\n')
            return
示例#8
0
    def create_report(salesList, salesInformation):
        pageHeight = (len(salesList) * 10) + 250
        pageWidth = 200
        padding = 20

        c = canvas.Canvas(f'cali/static/reports/sale_report.pdf',
                          pagesize=(pageWidth, pageHeight),
                          bottomup=0)

        c.translate(pageWidth / 2, 20)
        c.setFont('Helvetica-Bold', 8)
        c.drawCentredString(0, 0, 'Cali Boutique')
        c.drawCentredString(0, 10, 'Ave. de la Cantera 9119')
        c.drawCentredString(0, 20, 'Plaza Poniente 2do piso.')
        c.drawCentredString(0, 30, '(614)184-1424')
        c.translate(0, 50)

        c.drawCentredString(0, 0, 'Reporte de Ventas')
        c.drawCentredString(
            0, 10,
            '------------------------------------------------------------')

        c.translate(padding - pageWidth / 2, 20)
        c.drawString(0, 0, f'Fecha: {salesInformation["date"]}')
        c.drawString(0, 10,
                     f'Ventas Totales: {salesInformation["total sales"]}')
        c.drawString(0, 20, f'Ingreso Total: {salesInformation["total"]}')
        c.drawString(0, 30,
                     f'Ventas en Efectivo: {salesInformation["cash sales"]}')
        c.drawString(
            0, 40,
            f'Total Ventas En Efectivo: {salesInformation["total cash sales"]}'
        )
        c.drawString(
            0, 50,
            f'Ventas Con Tarjeta: {salesInformation["credit card sales"]}')
        c.drawString(
            0, 60,
            f'Total Ventas Con Tarjeta: {salesInformation["total credit card sales"]}'
        )

        c.translate(-padding + pageWidth / 2, 80)
        c.drawCentredString(0, 0, 'Ventas')
        c.drawCentredString(
            0, 10,
            '------------------------------------------------------------')

        c.translate(+padding - pageWidth / 2, 20)
        c.drawString(0, 0, 'Id')
        c.drawString(10, 0, f'| Usuario')
        c.drawString(50, 0, f'| Cliente')
        c.drawString(90, 0, f'| Fecha')
        c.drawString(140, 0, f'|  Total')

        for sale in salesList:
            user = User.get_user_by_id(sale['user_id'])
            client = Client.get_client_by_id(sale['client_id'])

            c.translate(0, 10)
            c.drawString(0, 0, f'{sale["id"]}')
            c.drawString(10, 0, f'| {user["username"]} ')
            c.drawString(50, 0, f'| {client["name"]}')
            c.drawString(90, 0, f'| {sale["date"]}')
            c.drawString(140, 0, f'| ${sale["total"]}')

        c.translate(-padding + pageWidth / 2, 0)
        c.drawCentredString(
            0, 10,
            '------------------------------------------------------------')
        c.showPage()
        c.save()
        return
示例#9
0
def delete(id):
    Client.delete_client(id)
    return redirect(url_for('clients.search'))