Improvement report

This commit is contained in:
Oscar Alvarez 2021-02-15 23:21:40 -05:00
parent 6ec3a1f2b9
commit f16818d2ab
3 changed files with 40 additions and 14 deletions

View file

@ -0,0 +1 @@
,psk,local.melhous.com,15.02.2021 23:21,file:///home/psk/.config/libreoffice/4;

53
sale.py
View file

@ -1464,14 +1464,14 @@ class SaleIncomeDailyReport(Report):
pool = Pool()
Invoice = pool.get('account.invoice')
Voucher = pool.get('account.voucher')
Sale = pool.get('sale.sale')
Company = pool.get('company.company')
company = Company(data['company'])
Statement = pool.get('account.statement')
Shop = pool.get('sale.shop')
User = pool.get('res.user')
records = []
statements_ = []
devices = []
statements_ = {}
advances = []
total_advances = []
advances_cash = []
@ -1497,14 +1497,23 @@ class SaleIncomeDailyReport(Report):
for statement in statements:
st_amount = sum(l.amount for l in statement.lines)
statements_.append({
'id': statement.id,
'sale_device': statement.sale_device.name,
'journal': statement.journal.name,
'turn': statement.turn,
'total_amount': st_amount,
'state': statement.state,
})
if statement.sale_device.id not in statements_.keys():
statements_[statement.sale_device.id] = [{
'name': statement.sale_device.name,
'total': [st_amount],
'records': [{
'journal': statement.journal.name,
'turn': statement.turn,
'total_amount': st_amount,
}]
}]
else:
statements_[statement.sale_device.id]['total'].append(st_amount)
statements_[statement.sale_device.id]['records'].append({
'journal': statement.journal.name,
'turn': statement.turn,
'total_amount': st_amount,
})
total_statements.append(st_amount)
for l in statement.lines:
@ -1568,7 +1577,7 @@ class SaleIncomeDailyReport(Report):
('company', '=', data['company']),
('invoice_date', '=', data['date']),
('number', '!=', None),
('state', 'in', ['posted', 'paid', 'canceled']),
('state', 'in', ['posted', 'paid', 'canceled', 'validated']),
]
shop_names = ''
if data['shop']:
@ -1587,7 +1596,7 @@ class SaleIncomeDailyReport(Report):
total_invoices_electronic = []
total_invoices_credit = []
total_invoices_paid = []
devices = {}
total_invoices_amount = []
for invoice in invoices:
invoices_number.append(invoice.number)
@ -1596,6 +1605,7 @@ class SaleIncomeDailyReport(Report):
credit = 0
total_invoices_amount.append(invoice.total_amount)
sale = invoice.sales[0]
device_id = sale.sale_device.id
if not sale.payments:
total_invoices_credit.append(invoice.amount_to_pay)
credit = invoice.amount_to_pay
@ -1609,7 +1619,7 @@ class SaleIncomeDailyReport(Report):
electronic += p.amount
total_invoices_electronic.append(p.amount)
total_invoices_paid.append(p.amount)
paid = cash + electronic
inv = {
'number': invoice.number,
'reference': invoice.reference,
@ -1618,11 +1628,25 @@ class SaleIncomeDailyReport(Report):
'credit': credit,
'cash': cash,
'electronic': electronic,
'paid': cash + electronic,
'paid': paid,
'state': invoice.state_string,
'sale_device': sale.sale_device.name,
}
records.append(inv)
try:
devices[device_id]['total'].append(invoice.total_amount)
devices[device_id]['cash'].append(cash)
devices[device_id]['electronic'].append(electronic)
devices[device_id]['paid'].append(paid)
except:
devices[device_id] = {
'name': sale.sale_device.name,
'total': [invoice.total_amount],
'credit': [credit],
'cash': [cash],
'electronic': [electronic],
'paid': [paid],
}
advances_cash_ = sum(advances_cash)
advances_electronic_ = sum(advances_electronic)
@ -1632,6 +1656,7 @@ class SaleIncomeDailyReport(Report):
payments_electronic_ = sum(payments_electronic)
report_context['records'] = records
report_context['devices'] = devices.values()
report_context['advances'] = advances
report_context['statements'] = statements_
report_context['date'] = data['date']

Binary file not shown.