diff --git a/report/close_statement.fodt b/report/close_statement.fodt index 5869ea6..e52df94 100644 --- a/report/close_statement.fodt +++ b/report/close_statement.fodt @@ -1,29 +1,30 @@ - - LibreOffice/7.0.4.2$Linux_X86_64 LibreOffice_project/00$Build-22008-06-07T15:28:222009-01-10T16:03:331PT0S + + LibreOffice/7.4.7.2$Linux_X86_64 LibreOffice_project/40$Build-22008-06-07T15:28:222009-01-10T16:03:331PT0S - 9620 + 1152 0 - 15843 - 7410 + 22274 + 10453 true false view2 - 5671 - 11726 + 6115 + 5258 0 - 9620 - 15841 - 17029 + 1152 + 22273 + 11603 0 0 false - 310 + 220 false + false false @@ -47,12 +48,14 @@ true false false + false false false true true true false + false false false false @@ -70,6 +73,7 @@ 0 1 true + false high-resolution false @@ -79,16 +83,18 @@ false true false + false true true false true true - 2365837 + 2765799 true false + true true 0 @@ -98,12 +104,15 @@ false false true + 0 false false false false true + false false + false false false @@ -137,17 +146,19 @@ - - - - - - - - - + + + + + + + + + + + @@ -157,11 +168,11 @@ - + - + @@ -170,15 +181,15 @@ - + - + - - + + @@ -200,7 +211,7 @@ - + @@ -249,6 +260,10 @@ + + + + @@ -259,34 +274,34 @@ - + - + - + - + - + - + - + - + - + - + @@ -306,63 +321,59 @@ - - + + - - + + - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + - + - + - - + + - - + + + + + + + + + + + @@ -376,84 +387,228 @@ - - - - - + - + - - + + - + - - + + - - - - - + - + + + + + + + + + - + - + + + + + - - - - - + + - + + + - - - + + + + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -468,46 +623,58 @@ - + - + - + - + - + - + - + + + + + + + + + + - - + + - + - + + + + - + @@ -526,8 +693,8 @@ - - + + /9j/4AAQSkZJRgABAQEAYABgAAD/4S6eRXhpZgAATU0AKgAAAAgABgALAAIAAAAmAAAIYgES AAMAAAABAAEAAAExAAIAAAAmAAAIiAEyAAIAAAAUAAAIrodpAAQAAAABAAAIwuocAAcAAAgM AAAAVgAAEUYc6gAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA @@ -1674,91 +1841,137 @@ - - NIT: 901575528 - Regimen Común - TRANSV 46 E 42 ESTE 789 32667 - SANTA ELENA - Cel: 3014287624 + NIT: 901575528 + Regimen Común + TRANSV 46 E 42 ESTE 789 32667 + SANTA ELENA + Cel: 3014287624 - - - - - - Base + + + + + + + + Declaración Diaria: - - Impuestos + + + + + + + Nombre - - Total + + Inicio + + + Saldo + + + Final - - - <untaxed_amount> + + + <for each="statement in statements"> - - <tax_amount> + + + + + + + <statement['name']> - - <total_amount> + + <statement['start_balance']> + + <statement['total_amount']> + + + <statement['end_balance']> + + + + + </for> + + + + + + + + Total: + + + + <total_statements> + + - - - - - - - Pizzas vendidas - - - <number_pizzas_sold> - - - - - + Ventas Diarias - - - Extractos del día + + + Base - - - - - - <for each="statement in statements"> + + Impuestos - - - - - - <statement['name']> - - - <statement['total_amount']> - - - + + Total - - - </for> + + + <untaxed_amount> + + + <tax_amount> + + + <total_amount> - - - + + Venta de Pizzas + + + + + + + Pizzas vendidas + + + Total x Pizzas + + + Propinas + + + + + <number_pizzas_sold> + + + <amount_w_tax_pizzas> + + + <tips> + + + + \ No newline at end of file diff --git a/report_close_statement.py b/report_close_statement.py index f5ab2e5..ce6613c 100644 --- a/report_close_statement.py +++ b/report_close_statement.py @@ -1,13 +1,18 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from trytond.model import ModelSQL, ModelView, fields -from trytond.wizard import Wizard, StateView, Button, StateTransition, StateReport +from trytond.model import ModelView, fields +from trytond.wizard import Wizard, StateView, Button, StateReport from trytond.transaction import Transaction from trytond.pool import Pool from trytond.report import Report +from decimal import Decimal + from datetime import date -__all__ = ['ReportCloseStatementStart', 'PrintReportCloseStatement', 'CashRegister'] + +__all__ = ['ReportCloseStatementStart', 'PrintReportCloseStatement', + 'CashRegister'] + class ReportCloseStatementStart(ModelView): "Vista inicial de reporte de extracto" @@ -35,10 +40,10 @@ class PrintReportCloseStatement(Wizard): start = StateView( 'sale.print_cash_register.start', - 'sale_fast_food.print_cash_register_start_view_form',[ + 'sale_fast_food.print_cash_register_start_view_form', [ Button("Cancel", 'end', 'tryton-cancel'), Button("Print Cash Register", - 'print_cash_register', 'tryton-ok', default=True)]) + 'print_cash_register', 'tryton-ok', default=True)]) print_cash_register = StateReport('sale.cash_register') @@ -52,17 +57,27 @@ class PrintReportCloseStatement(Wizard): def transition_print_cash_register(self): return 'end' - + + class CashRegister(Report): "Extracto" __name__ = 'sale.cash_register' - def _get_number_pizzas_sold(lines): + def _get_info_pizzas_sold(lines): pizzas = 0 - for line in lines: + amount_w_tax = 0 + amount_tip = 0 + for line in lines: if line.bought_pizza: pizzas += line.quantity - return pizzas + amount_w_tax += line.amount_w_tax + if line.product and line.product.template.tip: + amount_tip += line.amount + return { + 'amount_tip': amount_tip, + 'amount_w_tax': amount_w_tax, + 'pizzas': pizzas, + } def _get_statements_by_date(date): pool = Pool() @@ -73,7 +88,7 @@ class CashRegister(Report): device = user.sale_device if not device: - return + return journals = [j.id for j in device.journals] statements = Statement.search([ ('journal', 'in', journals), @@ -92,7 +107,7 @@ class CashRegister(Report): today_sales_domain = [('state', 'in', ['processing', 'done']), ('sale_date', '=', data['date']), ('shop', '=', data['shop'])] - today_sales = Sale.search(today_sales_domain, + today_sales = Sale.search(today_sales_domain, order=[('id', 'ASC')]) if not today_sales: @@ -100,23 +115,36 @@ class CashRegister(Report): untaxed_amount = 0 tax_amount = 0 total_amount = 0 - number_pizzas_sold = 0 + total_pizzas = 0 + amount_w_tax_pizzas = [] + amount_tips = [] for sale in today_sales: untaxed_amount += sale.untaxed_amount tax_amount += sale.tax_amount - number_pizzas_sold += cls._get_number_pizzas_sold(sale.lines) - total_amount+=sale.total_amount + info_pizzas_sold = cls._get_info_pizzas_sold(sale.lines) + total_pizzas += info_pizzas_sold['pizzas'] + amount_w_tax_pizzas.append(info_pizzas_sold['amount_w_tax']) + amount_tips.append(info_pizzas_sold['amount_tip']) + total_amount += sale.total_amount statements = cls._get_statements_by_date(data['date']) if statements: report_context['statements'] = [{ 'name': statement.journal.name, - 'total_amount':statement.total_amount + 'start_balance': statement.start_balance, + 'end_balance': statement.end_balance, + 'total_amount': sum( + (line.amount for line in statement.lines + if line.description), Decimal(0)) } for statement in statements] + report_context['total_statements'] = sum( + [s['total_amount'] for s in report_context['statements']]) + report_context['amount_w_tax_pizzas'] = sum(amount_w_tax_pizzas) + report_context['tips'] = sum(amount_tips) report_context['untaxed_amount'] = untaxed_amount report_context['tax_amount'] = tax_amount report_context['total_amount'] = total_amount - report_context['number_pizzas_sold'] = number_pizzas_sold + report_context['number_pizzas_sold'] = total_pizzas return report_context