Add create voucher receipt channel

This commit is contained in:
oscar alvarez 2022-07-22 10:36:13 -05:00
parent ea9fd1b5b0
commit 55177b9622
7 changed files with 120 additions and 19 deletions

View File

@ -108,8 +108,7 @@ class Booking(Workflow, ModelSQL, ModelView):
help="Plans offered by hotel and selected by guest for booking.")
plan_string = plan.translated('plan')
comments = fields.Text('Comments', states=STATES_CHECKIN)
reason = fields.Selection(REASON, 'Tourism Segment',
states=STATES_CHECKIN)
reason = fields.Selection(REASON, 'Tourism Segment', states=STATES_CHECKIN)
reason_string = reason.translated('segment')
guarantee = fields.Selection(GUARANTEE, 'Guarantee', states=STATES_CHECKIN)
guarantee_string = guarantee.translated('guarantee')
@ -119,12 +118,13 @@ class Booking(Workflow, ModelSQL, ModelView):
digits=(16, 2), depends=['lines']), 'get_tax_amount')
total_amount = fields.Function(fields.Numeric('Total Amount',
digits=(16, 2), depends=['lines']), 'get_total_amount')
collect_amount = fields.Function(fields.Numeric('Collect Amount',
digits=(16, 2), depends=['lines']), 'get_collect_amount')
code = fields.Char('Code', states={'readonly': True})
booker = fields.Many2One('party.party', 'Booker', states={'readonly': True})
created_channel = fields.DateTime('Created Channel', states={'readonly': True})
vouchers = fields.Many2Many('hotel.booking-account.voucher', 'booking',
'voucher', 'Vouchers', states=STATES_CHECKIN, domain=[
], depends=['party'])
'voucher', 'Vouchers', states={'readonly': False})
vip = fields.Boolean('V.I.P. Customer', states=STATES)
ota_booking_code = fields.Char('OTA Code', select=True,
states={'invisible': Eval('media') != 'ota'}
@ -134,7 +134,6 @@ class Booking(Workflow, ModelSQL, ModelView):
depends=['party'])
vehicles_num = fields.Integer('Vehicles Number', states=STATES,
help="Number of vehicles that bring with guests.")
vehicle_plate = fields.Char('Vehicle Plate', states=STATES)
travel_cause = fields.Char('Travel Cause', states=STATES)
taxes_exception = fields.Boolean('Taxes Exception', states=STATES)
total_advance = fields.Function(fields.Numeric('Total Advance',
@ -373,6 +372,7 @@ class Booking(Workflow, ModelSQL, ModelView):
for rec in records:
# FIXME check if does not exist previous occupancy if exist update state
rec.update_folio('pending')
cls.create_channel_voucher(rec)
@classmethod
@ModelView.button
@ -397,6 +397,42 @@ class Booking(Workflow, ModelSQL, ModelView):
# rec.add_payments_invoice()
cls.check_finished(records)
@classmethod
def create_channel_voucher(cls, bk):
Voucher = Pool().get('account.voucher')
# If ota_collect is paymode for folios
if not bk.channel or bk.channel_paymode != 'ota_collect':
return
payment_mode = bk.channel.payment_mode
party = bk.channel.agent.party
account_id = Voucher.get_account('receipt', payment_mode)
amount = bk.collect_amount - bk.channel_commission
lines = [{
'detail': f'OTA Code {bk.ota_booking_code}',
'amount': amount,
'amount_original': amount,
'account': party.account_receivable.id,
}]
to_create = {
'party': party.id,
'voucher_type': 'receipt',
'date': date.today(),
'description': f'Booking {bk.number}',
'payment_mode': payment_mode.id,
'account': account_id,
'journal': payment_mode.journal.id,
'lines': [('create', lines)],
'amount_to_pay': amount,
'method_counterpart': 'one_line',
# 'state': 'draft',
}
voucher, = Voucher.create([to_create])
Voucher.process([voucher])
cls.write([bk], {'vouchers': [('add', [voucher])]})
@classmethod
def bill_to_channel(cls, records):
for rec in records:
@ -818,6 +854,9 @@ class Booking(Workflow, ModelSQL, ModelView):
company_id = Transaction().context.get('company')
party = data['party']
# party is instance or id fixme
if type(party) == int:
party = Party(party)
ota_code = data.get('ota_booking_code', '')
if data.get('description'):
description = data['description']
@ -893,18 +932,19 @@ class Booking(Workflow, ModelSQL, ModelView):
def get_total_advance(self, name):
Advance = Pool().get('hotel.booking-account.voucher')
Payments = Pool().get('hotel.booking-statement.line')
vouchers = Advance.search([('booking', '=', self.id)])
# payments = Payments.search([('booking', '=', self.id)])
res = sum([voucher.voucher.amount_to_pay for voucher in vouchers])
advances = Advance.search([('booking', '=', self.id)])
res = sum([ad.voucher.amount_to_pay for ad in advances])
payments = sum([pay.amount for pay in self.payments])
return res + payments
return res + payments + self.channel_commission
def get_pending_to_pay(self, name):
if self.total_amount:
return self.total_amount - (self.total_advance or 0)
return 0
def get_collect_amount(self, name):
return sum(folio.room_amount for folio in self.lines)
def get_total_amount(self, name):
res = 0
if self.tax_amount or self.untaxed_amount:

View File

@ -21,7 +21,12 @@ class SaleChannel(ModelSQL, ModelView):
'Sale Channel'
__name__ = 'hotel.channel'
name = fields.Char('Name', required=True)
code = fields.Char('Code', required=True)
code = fields.Selection([
('', ''),
('booking', 'Booking'),
('despegar', 'Despegar'),
('expedia', 'Expedia'),
], 'Code', required=False)
agent = fields.Many2One('commission.agent', 'Agent', required=True)
type_commission = fields.Selection([
('percentage', 'Percentage'),
@ -57,6 +62,10 @@ class SaleChannel(ModelSQL, ModelView):
currency = fields.Many2One('currency.currency', 'Currency',
required=True)
price_list = fields.Many2One('product.price_list', 'Price List')
payment_mode = fields.Many2One('account.voucher.paymode',
'Receipt - Payment Mode', domain=[
('company', 'in', [Eval('company', -1), None]),
])
payment_method = fields.Selection(PAYMENT_METHOD_CHANNEL, 'Payment Method')
collection_mode = fields.Selection([
('', ''),

View File

@ -46,6 +46,10 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">hotel-guests</field>
<field name="path">icons/guests.svg</field>
</record>
<record model="ir.ui.icon" id="hotel_maintenance_icon">
<field name="name">hotel-maintenance</field>
<field name="path">icons/maintenance.svg</field>
</record>
<menuitem name="Hotel" sequence="10" id="menu_hotel"
icon="tryton-hotel"/>

50
icons/maintenance.svg Normal file
View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 293.129 293.129" style="enable-background:new 0 0 293.129 293.129;" xml:space="preserve">
<g>
<path d="M162.179,140.514c3.377-1.727,7.139-2.64,11.042-2.64c6.468,0,12.549,2.511,17.133,7.071l9.868-9.867
c24.42,8.56,52.664,3.08,72.186-16.441c16.426-16.426,22.904-39.026,19.446-60.329c-0.381-2.346-2.042-4.281-4.303-5.011
c-2.261-0.731-4.743-0.137-6.423,1.544l-14.652,14.652c-11.932,11.932-31.279,11.932-43.211,0
c-11.933-11.932-11.933-31.279,0-43.211l14.652-14.652c1.681-1.681,2.28-4.163,1.548-6.425c-0.731-2.263-2.669-3.92-5.016-4.301
c-21.302-3.458-43.903,3.02-60.328,19.446c-19.812,19.812-25.144,48.604-16.032,73.269l-21.402,21.402L162.179,140.514z"/>
<path d="M123.179,179.296l-25.385-25.385L9.029,242.675c-11.542,11.542-11.542,30.255,0,41.797
c11.542,11.542,30.255,11.542,41.797,0l76.521-76.52C119.629,200.193,118.238,188.479,123.179,179.296z"/>
<path d="M179.795,155.597c-1.815-1.815-4.195-2.723-6.574-2.723s-4.759,0.908-6.574,2.723l-5.299,5.299L66.956,66.504l4.412-4.412
c4.02-4.019,3.521-10.686-1.061-14.06L31.795,19.669c-3.701-2.725-8.837-2.338-12.087,0.912L3.356,36.934
c-3.25,3.25-3.637,8.387-0.912,12.087l28.362,38.512c3.374,4.581,10.037,5.085,14.06,1.061l4.412-4.413l94.392,94.392l-5.672,5.672
c-3.631,3.631-3.631,9.517,0,13.148l87.079,87.079c11.542,11.542,30.255,11.542,41.797,0c11.542-11.542,11.542-30.255,0-41.797
L179.795,155.597z"/>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -61,8 +61,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="domain" eval="[]" pyson="1"/>
<field name="act_window" ref="act_hotel_maintenance_form"/>
</record>
<menuitem name="Maintenance" parent="hotel.menu_hotel"
sequence="20" action="act_hotel_maintenance_form"
<menuitem name="Maintenance" parent="hotel.menu_hotel" sequence="110"
action="act_hotel_maintenance_form" icon="hotel-maintenance"
id="menu_hotel_maintenance"/>
<!-- Model Access -->

View File

@ -38,12 +38,10 @@ this repository contains the full copyright notices and license terms. -->
<field name="lines" colspan="4"
view_ids="hotel.booking_folio_view_tree"/>
</page>
<page string="Payments" id="payments">
<page string="Payments and Invoices" id="invoices_vouchers">
<field name="payments" colspan="4"/>
</page>
<page string="Advances and Invoices" id="invoices_vouchers">
<field name="vouchers" colspan="4"/>
<field name="invoices" colspan="4"/>
<field name="vouchers" colspan="4"/>
</page>
<page string="Stock" id="stock_moves">
<field name="stock_moves" colspan="4"/>
@ -65,8 +63,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="cancellation_policy" widget="selection"/>
<label name="vehicles_num"/>
<field name="vehicles_num"/>
<label name="vehicle_plate"/>
<field name="vehicle_plate"/>
<label name="vip"/>
<field name="vip"/>
<label name="group"/>

View File

@ -16,6 +16,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="type_commission"/>
<label name="commission"/>
<field name="commission"/>
<label name="payment_mode"/>
<field name="payment_mode" widget="selection"/>
<label name="debit_account"/>
<field name="debit_account"/>
<label name="credit_account"/>