Fix
This commit is contained in:
parent
1893f6b751
commit
028aa49e0a
|
@ -64,6 +64,7 @@ def register():
|
||||||
dash.DashApp,
|
dash.DashApp,
|
||||||
dash.AppHotelPlanner,
|
dash.AppHotelPlanner,
|
||||||
invoice.InvoiceLine,
|
invoice.InvoiceLine,
|
||||||
|
invoice.Invoice,
|
||||||
# folio.TransferfolioStart,
|
# folio.TransferfolioStart,
|
||||||
# folio.TransferChargeStart,
|
# folio.TransferChargeStart,
|
||||||
# folio.CheckOutfolioFailed,
|
# folio.CheckOutfolioFailed,
|
||||||
|
|
30
booking.py
30
booking.py
|
@ -64,6 +64,7 @@ class Booking(Workflow, ModelSQL, ModelView):
|
||||||
'invisible': ~Bool(Eval('complementary')),
|
'invisible': ~Bool(Eval('complementary')),
|
||||||
'required': Bool(Eval('complementary')),
|
'required': Bool(Eval('complementary')),
|
||||||
})
|
})
|
||||||
|
# rename to channel
|
||||||
party_seller = fields.Many2One('hotel.channel', 'Channel',
|
party_seller = fields.Many2One('hotel.channel', 'Channel',
|
||||||
states=STATES_CHECKIN, help="Agency or channel that do reservation.")
|
states=STATES_CHECKIN, help="Agency or channel that do reservation.")
|
||||||
state = fields.Selection(STATE_BOOKING, 'State', readonly=True,
|
state = fields.Selection(STATE_BOOKING, 'State', readonly=True,
|
||||||
|
@ -132,6 +133,8 @@ class Booking(Workflow, ModelSQL, ModelView):
|
||||||
pending_to_pay = fields.Function(fields.Numeric('Pending to Pay',
|
pending_to_pay = fields.Function(fields.Numeric('Pending to Pay',
|
||||||
digits=(16, 2)), 'get_pending_to_pay')
|
digits=(16, 2)), 'get_pending_to_pay')
|
||||||
breakfast_included = fields.Boolean('Breakfast Included')
|
breakfast_included = fields.Boolean('Breakfast Included')
|
||||||
|
channel_commission = fields.Function(fields.Numeric('Channel Commission',
|
||||||
|
digits=(16, 2), depends=['lines']), 'get_channel_commission')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
|
@ -512,14 +515,6 @@ class Booking(Workflow, ModelSQL, ModelView):
|
||||||
invoice.on_change_invoice_type()
|
invoice.on_change_invoice_type()
|
||||||
invoice.save()
|
invoice.save()
|
||||||
|
|
||||||
# Here add payments to invoice
|
|
||||||
# if rec.get('vouchers'):
|
|
||||||
# for v in rec['vouchers']:
|
|
||||||
# SaleVoucher.create([{
|
|
||||||
# 'voucher': v.id,
|
|
||||||
# 'sale': sale.id
|
|
||||||
# }])
|
|
||||||
|
|
||||||
# Add and create default charges lines if exists
|
# Add and create default charges lines if exists
|
||||||
if rec.get('guests_qty') and rec.get('add_default_charges'):
|
if rec.get('guests_qty') and rec.get('add_default_charges'):
|
||||||
for product in config.default_charges:
|
for product in config.default_charges:
|
||||||
|
@ -556,8 +551,6 @@ class Booking(Workflow, ModelSQL, ModelView):
|
||||||
})
|
})
|
||||||
invoice.save()
|
invoice.save()
|
||||||
invoice.update_taxes([invoice])
|
invoice.update_taxes([invoice])
|
||||||
# for payment in self.payments:
|
|
||||||
# pass
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_new_invoice(cls, data):
|
def _get_new_invoice(cls, data):
|
||||||
|
@ -700,12 +693,17 @@ class Booking(Workflow, ModelSQL, ModelView):
|
||||||
res += line.total_amount
|
res += line.total_amount
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_occupancies(self, name):
|
# def get_occupancies(self, name):
|
||||||
occupancies = set()
|
# occupancies = set()
|
||||||
for line in self.lines:
|
# for line in self.lines:
|
||||||
if line.occupancy_line:
|
# if line.occupancy_line:
|
||||||
occupancies.add(line.occupancy_line.id)
|
# occupancies.add(line.occupancy_line.id)
|
||||||
return list(occupancies)
|
# return list(occupancies)
|
||||||
|
|
||||||
|
def get_channel_commission(self, name):
|
||||||
|
res = sum(line.commission_amount for line in self.lines if
|
||||||
|
line.commission_amount)
|
||||||
|
return res
|
||||||
|
|
||||||
def send_email_to(self):
|
def send_email_to(self):
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
|
|
14
channel.py
14
channel.py
|
@ -1,5 +1,6 @@
|
||||||
# This file is part of Presik. The COPYRIGHT file at the top level of
|
# This file is part of Presik. The COPYRIGHT file at the top level of
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
|
from decimal import Decimal
|
||||||
from trytond.model import ModelView, ModelSQL, fields
|
from trytond.model import ModelView, ModelSQL, fields
|
||||||
from trytond.pyson import Eval, If
|
from trytond.pyson import Eval, If
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
|
@ -14,24 +15,25 @@ class SaleChannel(ModelSQL, ModelView):
|
||||||
type_commission = fields.Selection([
|
type_commission = fields.Selection([
|
||||||
('percentage', 'Percentage'),
|
('percentage', 'Percentage'),
|
||||||
('fixed', 'Fixed'),
|
('fixed', 'Fixed'),
|
||||||
], 'Type Commission', required=True)
|
], 'Type Commission', required=True)
|
||||||
|
# Remove this field
|
||||||
company = fields.Many2One('company.company', 'Company', required=True,
|
company = fields.Many2One('company.company', 'Company', required=True,
|
||||||
domain=[
|
domain=[
|
||||||
('id', If(Eval('context', {}).contains('company'), '=', '!='),
|
('id', If(Eval('context', {}).contains('company'), '=', '!='),
|
||||||
Eval('context', {}).get('company', 0)),
|
Eval('context', {}).get('company', 0)),
|
||||||
], select=True)
|
], select=True)
|
||||||
commission = fields.Numeric('Commission', required=True, digits=(16, 2))
|
commission = fields.Float('Commission', required=True, digits=(4, 2))
|
||||||
debit_account = fields.Many2One('account.account', 'Debit Account',
|
debit_account = fields.Many2One('account.account', 'Debit Account',
|
||||||
domain=[
|
domain=[
|
||||||
('company', '=', Eval('company')),
|
('company', '=', Eval('company')),
|
||||||
('kind', 'not in', ['view']),
|
('kind', 'not in', ['view']),
|
||||||
],
|
],
|
||||||
depends=['company', 'type_commission'])
|
depends=['company', 'type_commission'])
|
||||||
credit_account = fields.Many2One('account.account', 'Credit Account',
|
credit_account = fields.Many2One('account.account', 'Credit Account',
|
||||||
domain=[
|
domain=[
|
||||||
('company', '=', Eval('company')),
|
('company', '=', Eval('company')),
|
||||||
('kind', 'not in', ['view']),
|
('kind', 'not in', ['view']),
|
||||||
],
|
],
|
||||||
depends=['company', 'type_commission'])
|
depends=['company', 'type_commission'])
|
||||||
taxes = fields.Many2Many('hotel.channel-account.tax',
|
taxes = fields.Many2Many('hotel.channel-account.tax',
|
||||||
'channel', 'tax', 'Channel Taxes',
|
'channel', 'tax', 'Channel Taxes',
|
||||||
|
@ -69,6 +71,10 @@ class SaleChannel(ModelSQL, ModelView):
|
||||||
if company:
|
if company:
|
||||||
return Company(company).currency.id
|
return Company(company).currency.id
|
||||||
|
|
||||||
|
def compute(self, amount):
|
||||||
|
res = Decimal(round(float(amount) * self.commission / 100, 2))
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
class ChannelTax(ModelSQL):
|
class ChannelTax(ModelSQL):
|
||||||
'Channel - Tax'
|
'Channel - Tax'
|
||||||
|
|
62
folio.py
62
folio.py
|
@ -92,14 +92,15 @@ class Folio(ModelSQL, ModelView):
|
||||||
num_children = fields.Function(fields.Integer('No. Children'),
|
num_children = fields.Function(fields.Integer('No. Children'),
|
||||||
'get_num_children')
|
'get_num_children')
|
||||||
nights_quantity = fields.Function(fields.Integer('Nights'),
|
nights_quantity = fields.Function(fields.Integer('Nights'),
|
||||||
'get_nights_quantity')
|
'on_change_with_nights_quantity')
|
||||||
host_quantity = fields.Integer('Host', states=STATES_CHECKIN)
|
host_quantity = fields.Integer('Host', states=STATES_CHECKIN)
|
||||||
unit_digits = fields.Function(fields.Integer('Unit Digits'), 'get_unit_digits')
|
unit_digits = fields.Function(fields.Integer('Unit Digits'), 'get_unit_digits')
|
||||||
notes = fields.Text('Notes')
|
notes = fields.Text('Notes')
|
||||||
total_amount = fields.Function(fields.Numeric('Total Amount',
|
total_amount = fields.Function(fields.Numeric('Total Amount',
|
||||||
digits=(16, 2)), 'get_total_amount')
|
digits=(16, 2)), 'get_total_amount')
|
||||||
total_commission = fields.Function(fields.Numeric('Channel Commission',
|
commission_amount = fields.Numeric('Commission Amount', digits=(16, 2),
|
||||||
digits=(16, 2)), 'get_channel_commission')
|
depends=['product', 'departure_date', 'arrival_date']
|
||||||
|
)
|
||||||
guests = fields.One2Many('hotel.folio.guest', 'folio', 'Guests',
|
guests = fields.One2Many('hotel.folio.guest', 'folio', 'Guests',
|
||||||
states={'readonly': Eval('registration_state').in_(['check_out'])})
|
states={'readonly': Eval('registration_state').in_(['check_out'])})
|
||||||
nationality = fields.Many2One('party.nationality', 'Nationality',
|
nationality = fields.Many2One('party.nationality', 'Nationality',
|
||||||
|
@ -135,7 +136,7 @@ class Folio(ModelSQL, ModelView):
|
||||||
'readonly': Eval('registration_state') != 'check_in',
|
'readonly': Eval('registration_state') != 'check_in',
|
||||||
})
|
})
|
||||||
room_amount = fields.Function(fields.Numeric('Room Amount',
|
room_amount = fields.Function(fields.Numeric('Room Amount',
|
||||||
digits=(16, 2)), 'get_room_amount')
|
digits=(16, 2)), 'get_change_with_room_amount')
|
||||||
stock_moves = fields.Many2Many('hotel.folio-stock.move', 'folio',
|
stock_moves = fields.Many2Many('hotel.folio-stock.move', 'folio',
|
||||||
'move', 'Stock Moves', states={'readonly': True})
|
'move', 'Stock Moves', states={'readonly': True})
|
||||||
|
|
||||||
|
@ -276,7 +277,8 @@ class Folio(ModelSQL, ModelView):
|
||||||
res = value['base'] + value['amount']
|
res = value['base'] + value['amount']
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_room_amount(self, name=None):
|
@fields.depends('unit_price_w_tax', 'nights_quantity')
|
||||||
|
def get_change_with_room_amount(self, name=None):
|
||||||
res = 0
|
res = 0
|
||||||
Date = Pool().get('ir.date')
|
Date = Pool().get('ir.date')
|
||||||
if self.unit_price_w_tax and self.nights_quantity:
|
if self.unit_price_w_tax and self.nights_quantity:
|
||||||
|
@ -365,39 +367,6 @@ class Folio(ModelSQL, ModelView):
|
||||||
raise UserError(gettext('hotel.msg_invalid_arrival_date'))
|
raise UserError(gettext('hotel.msg_invalid_arrival_date'))
|
||||||
if self.arrival_date >= self.departure_date:
|
if self.arrival_date >= self.departure_date:
|
||||||
raise UserError(gettext('hotel.msg_invalid_date'))
|
raise UserError(gettext('hotel.msg_invalid_date'))
|
||||||
# Operation = Pool().get('hotel.operation')
|
|
||||||
# operations = Operation.search([
|
|
||||||
# ('room', '=', self.room.id),
|
|
||||||
# ['AND',
|
|
||||||
# ['OR', [
|
|
||||||
# ('start_date', '>=', self.arrival_date),
|
|
||||||
# ('end_date', '<=', self.arrival_date),
|
|
||||||
# ], [
|
|
||||||
# ('start_date', '>=', self.departure_date),
|
|
||||||
# ('end_date', '<=', self.departure_date),
|
|
||||||
# ]]
|
|
||||||
# ]
|
|
||||||
# ])
|
|
||||||
# if operations:
|
|
||||||
# raise AccessError(gettext('hotel.msg_occupied_room', s=self.departure_date))
|
|
||||||
# config = Pool().get('hotel.configuration')(1)
|
|
||||||
# quarantine_days = config.quarantine_rooms
|
|
||||||
# room_id = self.room.id
|
|
||||||
# if quarantine_days:
|
|
||||||
# delta = timedelta(days=int(quarantine_days))
|
|
||||||
# _date = self.arrival_date - delta
|
|
||||||
# operations = Operation.search([
|
|
||||||
# ['AND',
|
|
||||||
# ['OR', [
|
|
||||||
# ('room', '=', room_id),
|
|
||||||
# ('end_date', '=', _date)
|
|
||||||
# ],
|
|
||||||
# [
|
|
||||||
# ('room', '=', room_id),
|
|
||||||
# ('end_date', '=', self.arrival_date)
|
|
||||||
# ]]]])
|
|
||||||
# if operations:
|
|
||||||
# raise AccessError(gettext('hotel.msg_restring_room', s=self.room.name))
|
|
||||||
|
|
||||||
def get_state(self, name):
|
def get_state(self, name):
|
||||||
if self.booking:
|
if self.booking:
|
||||||
|
@ -460,7 +429,7 @@ class Folio(ModelSQL, ModelView):
|
||||||
return list(rooms_available_ids)
|
return list(rooms_available_ids)
|
||||||
|
|
||||||
@fields.depends('arrival_date', 'departure_date')
|
@fields.depends('arrival_date', 'departure_date')
|
||||||
def get_nights_quantity(self, name=None):
|
def on_change_with_nights_quantity(self, name=None):
|
||||||
"""
|
"""
|
||||||
Compute nights between start and end
|
Compute nights between start and end
|
||||||
return a integer the mean days of occupancy.
|
return a integer the mean days of occupancy.
|
||||||
|
@ -485,15 +454,18 @@ class Folio(ModelSQL, ModelView):
|
||||||
res = round(sum(res), Folio.total_amount.digits[1])
|
res = round(sum(res), Folio.total_amount.digits[1])
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_channel_commission(self, name):
|
@fields.depends('arrival_date', 'departure_date', 'product')
|
||||||
|
def on_change_with_commission_amount(self):
|
||||||
"""
|
"""
|
||||||
Calculation of sale commission for channel based on booking total amount
|
Calculation of commission amount for channel based on booking
|
||||||
"""
|
"""
|
||||||
|
print(' - - - - >', self.arrival_date, self.product, self.departure_date)
|
||||||
res = Decimal(0)
|
res = Decimal(0)
|
||||||
# if self.total_amount and self.booking.party_seller and \
|
if all([self.arrival_date, self.product, self.departure_date]):
|
||||||
# self.booking.party_seller.agent.sale_commission:
|
if self.booking.party_seller:
|
||||||
# res = self.total_amount * self.booking.party_seller.sale_commission / 100
|
print(self.room_amount)
|
||||||
return res
|
res = self.booking.party_seller.compute(self.room_amount)
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
class FolioGuest(ModelSQL, ModelView):
|
class FolioGuest(ModelSQL, ModelView):
|
||||||
|
|
17
invoice.py
17
invoice.py
|
@ -18,10 +18,21 @@ class Invoice(metaclass=PoolMeta):
|
||||||
# if self.purchase.invoice_method != 'manual':
|
# if self.purchase.invoice_method != 'manual':
|
||||||
# print(' qty ', qty)
|
# print(' qty ', qty)
|
||||||
for invoice in invoices:
|
for invoice in invoices:
|
||||||
invoice.set_advances_from_booking()
|
if invoice.type == 'out':
|
||||||
|
cls.set_advances_from_origin(invoice)
|
||||||
|
|
||||||
def set_advances_from_booking(self):
|
@classmethod
|
||||||
pass
|
def set_advances_from_origin(cls, invoice):
|
||||||
|
advances_to_add = []
|
||||||
|
vouchers = []
|
||||||
|
for line in invoice.lines:
|
||||||
|
if line.origin and line.origin.__name__ == 'hotel.booking':
|
||||||
|
booking = line.origin
|
||||||
|
if not booking.vouchers:
|
||||||
|
continue
|
||||||
|
vouchers.extend(booking.vouchers)
|
||||||
|
if vouchers:
|
||||||
|
invoice.create_move_advance(set(vouchers))
|
||||||
|
|
||||||
|
|
||||||
class InvoiceLine(metaclass=PoolMeta):
|
class InvoiceLine(metaclass=PoolMeta):
|
||||||
|
|
|
@ -36,6 +36,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<field name="guests" colspan="4"/>
|
<field name="guests" colspan="4"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="Additional Info" id="folio_additional_info">
|
<page string="Additional Info" id="folio_additional_info">
|
||||||
|
<label name="commission_amount"/>
|
||||||
|
<field name="commission_amount"/>
|
||||||
<separator name="notes" colspan="4"/>
|
<separator name="notes" colspan="4"/>
|
||||||
<field name="notes" colspan="4"/>
|
<field name="notes" colspan="4"/>
|
||||||
</page>
|
</page>
|
||||||
|
|
|
@ -72,6 +72,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
<label name="created_channel"/>
|
<label name="created_channel"/>
|
||||||
<field name="created_channel"/>
|
<field name="created_channel"/>
|
||||||
|
<label name="channel_commission"/>
|
||||||
|
<field name="channel_commission"/>
|
||||||
</page>
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
<group col="4" colspan="4" id="buttons">
|
<group col="4" colspan="4" id="buttons">
|
||||||
|
|
Loading…
Reference in New Issue