Fix compute taxes
This commit is contained in:
parent
dd72e5defa
commit
1acfc8c901
19
booking.py
19
booking.py
|
@ -348,13 +348,9 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
def _get_taxes(self):
|
||||
pool = Pool()
|
||||
Tax = pool.get('account.tax')
|
||||
Configuration = pool.get('account.configuration')
|
||||
|
||||
taxes = {}
|
||||
with Transaction().set_context({}):
|
||||
config = Configuration(1)
|
||||
tax_rounding = config.get_multivalue('tax_rounding')
|
||||
|
||||
def compute(_taxes, unit_price, quantity):
|
||||
l_taxes = Tax.compute(list(_taxes), unit_price, quantity)
|
||||
for tax in l_taxes:
|
||||
|
@ -368,22 +364,17 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
else:
|
||||
taxes[taxline]['base'] += taxline['base']
|
||||
taxes[taxline]['amount'] += taxline['amount']
|
||||
# if tax_rounding == 'line':
|
||||
# self._round_taxes(taxes)
|
||||
|
||||
for folio in self.lines:
|
||||
if folio.taxes_exception:
|
||||
continue
|
||||
_taxes = folio.product.customer_taxes_used
|
||||
if folio.registration_state in ('check_in', 'check_out'):
|
||||
for occ in folio.occupancy:
|
||||
if not occ.charge:
|
||||
compute(_taxes, occ.unit_price, 1)
|
||||
for occ in folio.occupancy:
|
||||
if not occ.charge:
|
||||
compute(_taxes, occ.unit_price, 1)
|
||||
|
||||
for charge in folio.charges:
|
||||
compute(charge.taxes, charge.unit_price, charge.quantity)
|
||||
else:
|
||||
compute(_taxes, folio.unit_price, folio.nights_quantity)
|
||||
for charge in folio.charges:
|
||||
compute(charge.taxes, charge.unit_price, charge.quantity)
|
||||
|
||||
return taxes
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class ChannelCommission(ModelSQL, ModelView):
|
|||
'Channel Commission Extra'
|
||||
__name__ = 'hotel.channel.commission'
|
||||
channel = fields.Many2One('hotel.channel', 'Sale Channel',
|
||||
ondelete='CASCADE', select=True, required=True)
|
||||
ondelete='CASCADE', required=True)
|
||||
name = fields.Char('Name', required=True)
|
||||
commission = fields.Float('Commission', required=True, digits=(4, 2))
|
||||
|
||||
|
@ -105,6 +105,6 @@ class ChannelTax(ModelSQL):
|
|||
__name__ = 'hotel.channel-account.tax'
|
||||
_table = 'hotel_channel_taxes_rel'
|
||||
channel = fields.Many2One('hotel.channel', 'Sale Channel',
|
||||
ondelete='CASCADE', select=True, required=True)
|
||||
ondelete='CASCADE', required=True)
|
||||
tax = fields.Many2One('account.tax', 'Tax', ondelete='RESTRICT',
|
||||
required=True)
|
||||
|
|
5
folio.py
5
folio.py
|
@ -70,7 +70,7 @@ class Folio(ModelSQL, ModelView):
|
|||
domain=[
|
||||
('template.type', '=', 'service'),
|
||||
('template.kind', '=', 'accommodation'),
|
||||
], required=True, states=_CHECKOUT)
|
||||
], required=True, states={'readonly': True})
|
||||
unit_price = fields.Numeric('Unit Price', digits=(16, 2),
|
||||
states={
|
||||
'required': Bool(Eval('product')),
|
||||
|
@ -574,7 +574,7 @@ class Folio(ModelSQL, ModelView):
|
|||
return description
|
||||
|
||||
@fields.depends('product', 'unit_price', 'uom', 'booking',
|
||||
'nights_quantity', 'commission_amount')
|
||||
'nights_quantity', 'commission_amount', 'occupancy')
|
||||
def on_change_product(self):
|
||||
Product = Pool().get('product.product')
|
||||
unit_price = None
|
||||
|
@ -1021,7 +1021,6 @@ class Folio(ModelSQL, ModelView):
|
|||
arr_date = arr_date or self.arrival_date
|
||||
dep_date = dep_date or self.departure_date
|
||||
if dep_date or arr_date:
|
||||
print(type(arr_date), type(dep_date))
|
||||
self.update_nights(arr_date, dep_date)
|
||||
delta = (dep_date - arr_date).days
|
||||
current_dates = {occ.occupancy_date: occ for occ in self.occupancy}
|
||||
|
|
|
@ -10,7 +10,7 @@ STATES = {'invisible': (Eval('type') != 'service')}
|
|||
class RoomCleaningType(ModelSQL, ModelView):
|
||||
"Room Cleaning Type"
|
||||
__name__ = "hotel.housekeeping.cleaning_type"
|
||||
name = fields.Char('Name', required=True, select=True)
|
||||
name = fields.Char('Name', required=True)
|
||||
description = fields.Text('Description')
|
||||
kind = fields.Selection([
|
||||
('tweak', 'Tweak'),
|
||||
|
|
|
@ -7,7 +7,7 @@ class HotelLocation(ModelSQL, ModelView):
|
|||
"Hotel Location"
|
||||
__name__ = "hotel.location"
|
||||
name = fields.Char('Name', required=True, translate=True)
|
||||
parent = fields.Many2One('hotel.location', 'Parent', select=True)
|
||||
parent = fields.Many2One('hotel.location', 'Parent')
|
||||
childs = fields.One2Many('hotel.location', 'parent', string='Children')
|
||||
|
||||
def get_rec_name(self, name):
|
||||
|
|
|
@ -44,7 +44,7 @@ class Maintenance(Workflow, ModelSQL, ModelView):
|
|||
('in_progress', 'In progress'),
|
||||
('finished', 'Finished'),
|
||||
('cancelled', 'Canceled'),
|
||||
], 'State', readonly=True, select=True)
|
||||
], 'State', readonly=True)
|
||||
criticality = fields.Selection([
|
||||
('low', 'Low'),
|
||||
('important', 'Important'),
|
||||
|
|
|
@ -16,7 +16,7 @@ class HotelPriceList(ModelSQL, ModelView):
|
|||
domain=[
|
||||
('id', If(Eval('context', {}).contains('company'), '=', '!='),
|
||||
Eval('context', {}).get('company', 0)),
|
||||
], select=True)
|
||||
])
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
|
|
2
room.py
2
room.py
|
@ -21,7 +21,7 @@ ROOM_STATUS = [
|
|||
class CleaningType(ModelSQL, ModelView):
|
||||
"Room Cleaning Type"
|
||||
__name__ = "hotel.room.cleaning_type"
|
||||
name = fields.Char('Name', required=True, select=True)
|
||||
name = fields.Char('Name', required=True)
|
||||
description = fields.Text('Description')
|
||||
kind = fields.Selection([
|
||||
('tweak', 'Tweak'),
|
||||
|
|
6
sale.py
6
sale.py
|
@ -85,7 +85,7 @@ class InvoiceIncomeDailyReport(Report):
|
|||
total_statements = []
|
||||
|
||||
for statement in statements:
|
||||
st_amount = sum(l.amount for l in statement.lines)
|
||||
st_amount = sum(li.amount for li in statement.lines)
|
||||
statements_.append({
|
||||
'id': statement.id,
|
||||
'sale_device': statement.sale_device.name,
|
||||
|
@ -96,8 +96,8 @@ class InvoiceIncomeDailyReport(Report):
|
|||
})
|
||||
total_statements.append(st_amount)
|
||||
|
||||
for l in statement.lines:
|
||||
sale = l.sale
|
||||
for li in statement.lines:
|
||||
sale = li.sale
|
||||
cash = 0
|
||||
electronic = 0
|
||||
if sale and not sale.invoice_number:
|
||||
|
|
25
service.py
25
service.py
|
@ -1,6 +1,7 @@
|
|||
# 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 datetime import datetime
|
||||
|
||||
from trytond.model import ModelView, Workflow, ModelSQL, fields
|
||||
from trytond.pool import Pool
|
||||
from trytond.pyson import Eval, In, If, Get
|
||||
|
@ -21,7 +22,7 @@ STATES_LINE = {
|
|||
class ServiceKind(ModelSQL, ModelView):
|
||||
'Service Kind'
|
||||
__name__ = 'hotel.service.kind'
|
||||
name = fields.Char('Name', select=True, required=True)
|
||||
name = fields.Char('Name', required=True)
|
||||
product = fields.Many2One('product.product', 'Product')
|
||||
salable = fields.Boolean('Salable')
|
||||
category = fields.Selection([
|
||||
|
@ -38,7 +39,7 @@ class Service(Workflow, ModelSQL, ModelView):
|
|||
'Service'
|
||||
__name__ = 'hotel.service'
|
||||
_rec_name = 'kind.name'
|
||||
number = fields.Char('Number', select=True, required=False)
|
||||
number = fields.Char('Number', required=False)
|
||||
kind = fields.Many2One('hotel.service.kind', 'Kind', required=True,
|
||||
states={
|
||||
'readonly': Eval('state').in_(['confirmed', 'checked'])
|
||||
|
@ -57,9 +58,9 @@ class Service(Workflow, ModelSQL, ModelView):
|
|||
], 'State', readonly=True, states=STATES)
|
||||
state_string = state.translated('state')
|
||||
space = fields.Many2One('analytic_account.space', 'Space', required=False)
|
||||
description = fields.Char('Description', select=True, states=STATES)
|
||||
count_services = fields.Function(fields.Integer('Count Services',
|
||||
select=True), 'get_count_services')
|
||||
description = fields.Char('Description', states=STATES)
|
||||
count_services = fields.Function(fields.Integer('Count Services'),
|
||||
'get_count_services')
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
states=STATES, domain=[
|
||||
('id', If(In('company', Eval('context', {})), '=', '!='),
|
||||
|
@ -145,9 +146,9 @@ class ServiceLine(Workflow, ModelSQL, ModelView):
|
|||
'Service Line'
|
||||
__name__ = 'hotel.service.line'
|
||||
service = fields.Many2One('hotel.service', 'Service', required=True)
|
||||
room = fields.Many2One('hotel.room', 'Room', select=True, required=True,
|
||||
room = fields.Many2One('hotel.room', 'Room', required=True,
|
||||
states=STATES_LINE)
|
||||
time_service = fields.Time('Time Service', select=True, states=STATES_LINE)
|
||||
time_service = fields.Time('Time Service', states=STATES_LINE)
|
||||
product = fields.Many2One('product.product', 'Product',
|
||||
domain=[
|
||||
('salable', '=', True),
|
||||
|
@ -155,7 +156,7 @@ class ServiceLine(Workflow, ModelSQL, ModelView):
|
|||
], required=True)
|
||||
quantity = fields.Integer('Quantity', required=True, states=STATES_LINE)
|
||||
description = fields.Char('Description', states=STATES_LINE)
|
||||
order = fields.Char('Order', select=True, states=STATES_LINE)
|
||||
order = fields.Char('Order', states=STATES_LINE)
|
||||
folio_line = fields.Many2One('hotel.folio', 'Folio Line',
|
||||
states={'readonly': True})
|
||||
guest = fields.Char('Guest', states=STATES_LINE)
|
||||
|
@ -291,10 +292,10 @@ class ServiceLine(Workflow, ModelSQL, ModelView):
|
|||
class ServiceReport(CompanyReport):
|
||||
__name__ = 'hotel.service'
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
return report_context
|
||||
# @classmethod
|
||||
# def get_context(cls, records, header, data):
|
||||
# report_context = super().get_context(records, header, data)
|
||||
# return report_context
|
||||
|
||||
|
||||
class CreateDailyServicesStart(ModelView):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=6.0.103
|
||||
version=6.0.104
|
||||
depends:
|
||||
party
|
||||
company
|
||||
|
|
Loading…
Reference in New Issue