Se añade rango de resolución, formato de moneda
This commit is contained in:
@@ -18,9 +18,23 @@ class ReportCloseStatementStart(ModelView):
|
||||
"Vista inicial de reporte de extracto"
|
||||
__name__ = 'sale.print_cash_register.start'
|
||||
|
||||
company = fields.Many2One(
|
||||
'company.company', "Company", readonly=True, required=True)
|
||||
currency = fields.Many2One('currency.currency', 'Currency', required=True)
|
||||
date = fields.Date('Date', required=True)
|
||||
shop = fields.Many2One('sale.shop', 'Shop', required=True)
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
return Transaction().context.get('company')
|
||||
|
||||
@staticmethod
|
||||
def default_currency():
|
||||
Company = Pool().get('company.company')
|
||||
if Transaction().context.get('company'):
|
||||
company = Company(Transaction().context['company'])
|
||||
return company.currency.id
|
||||
|
||||
@classmethod
|
||||
def default_date(cls):
|
||||
return date.today()
|
||||
@@ -49,8 +63,10 @@ class PrintReportCloseStatement(Wizard):
|
||||
|
||||
def do_print_cash_register(self, action):
|
||||
data = {
|
||||
'lang': self.start.company.party.lang,
|
||||
'date': self.start.date,
|
||||
'shop': self.start.shop.id
|
||||
'shop': self.start.shop.id,
|
||||
'currency': self.start.currency.id,
|
||||
}
|
||||
|
||||
return action, data
|
||||
@@ -97,16 +113,44 @@ class CashRegister(Report):
|
||||
])
|
||||
return statements
|
||||
|
||||
def _get_invoices_by_subtype(date, shop):
|
||||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
Shop = pool.get('sale.shop')
|
||||
fe_pos_subtype = Shop(shop).fe_pos_subtype.id
|
||||
pos_subtype = Shop(shop).pos_subtype.id
|
||||
ranges = {}
|
||||
invoices_fe = Invoice.search([('invoice_date', '=', date),
|
||||
('subtype', '=', fe_pos_subtype)])
|
||||
|
||||
if invoices_fe:
|
||||
ranges['range_fe'] = \
|
||||
[invoices_fe[0].number, invoices_fe[-1].number]
|
||||
|
||||
invoices_pos = Invoice.search([('invoice_date', '=', date),
|
||||
('subtype', '=', pos_subtype)])
|
||||
|
||||
if invoices_pos:
|
||||
ranges['range_pos'] = \
|
||||
[invoices_pos[0].number, invoices_pos[-1].number]
|
||||
|
||||
return ranges
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super(
|
||||
CashRegister, cls).get_context(records, header, data)
|
||||
|
||||
pool = Pool()
|
||||
Shop = pool.get('sale.shop')
|
||||
Sale = pool.get('sale.sale')
|
||||
Currency = pool.get('currency.currency')
|
||||
currency = Currency(data['currency'])
|
||||
date = data['date']
|
||||
shop = data['shop']
|
||||
today_sales_domain = [('state', 'in', ['processing', 'done']),
|
||||
('sale_date', '=', data['date']),
|
||||
('shop', '=', data['shop'])]
|
||||
('sale_date', '=', date),
|
||||
('shop', '=', shop)]
|
||||
today_sales = Sale.search(today_sales_domain,
|
||||
order=[('id', 'ASC')])
|
||||
|
||||
@@ -141,6 +185,20 @@ class CashRegister(Report):
|
||||
report_context['total_statements'] = sum(
|
||||
[s['total_amount'] for s in report_context['statements']])
|
||||
|
||||
ranges = cls._get_invoices_by_subtype(date, shop)
|
||||
ranges_keys = ranges.keys()
|
||||
if 'range_fe' in ranges_keys:
|
||||
report_context['range_fe'] = ranges['range_fe']
|
||||
else:
|
||||
report_context['range_fe'] = []
|
||||
if 'range_pos' in ranges:
|
||||
report_context['range_pos'] = ranges['range_pos']
|
||||
else:
|
||||
report_context['range_pos'] = []
|
||||
|
||||
report_context['shop'] = Shop(shop).name
|
||||
report_context['date'] = date
|
||||
report_context['currency'] = currency
|
||||
report_context['amount_w_tax_pizzas'] = sum(amount_w_tax_pizzas)
|
||||
report_context['tips'] = sum(amount_tips)
|
||||
report_context['untaxed_amount'] = untaxed_amount
|
||||
|
||||
Reference in New Issue
Block a user