Fix reports
This commit is contained in:
parent
06a9844579
commit
68da5f3b88
22
__init__.py
22
__init__.py
|
@ -48,11 +48,6 @@ def register():
|
|||
booking.BookingForecastStart,
|
||||
folio.FolioGuest,
|
||||
folio.GuestsListStart,
|
||||
# folio.TransferfolioStart,
|
||||
# folio.TransferChargeStart,
|
||||
# folio.CheckOutfolioFailed,
|
||||
# folio.ChangeRoomStart,
|
||||
# folio.folioVoucher,
|
||||
folio.StatisticsByMonthStart,
|
||||
sale.InvoiceIncomeDailyStart,
|
||||
service.Service,
|
||||
|
@ -64,6 +59,10 @@ def register():
|
|||
housekeeping.HotelTask,
|
||||
housekeeping.HousekeepingServiceStart,
|
||||
room.CleanningDays,
|
||||
# folio.TransferfolioStart,
|
||||
# folio.TransferChargeStart,
|
||||
# folio.CheckOutfolioFailed,
|
||||
# folio.ChangeRoomStart,
|
||||
module='hotel', type_='model')
|
||||
Pool.register(
|
||||
booking.BookingReport,
|
||||
|
@ -73,13 +72,13 @@ def register():
|
|||
folio.Migration,
|
||||
folio.GuestsListReport,
|
||||
folio.RegistrationCardReport,
|
||||
# folio.folioReport,
|
||||
# folio.folioByConsumerReport,
|
||||
folio.StatisticsByMonthReport,
|
||||
sale.InvoiceIncomeDailyReport,
|
||||
sale.InvoiceSimplifiedReport,
|
||||
service.ServiceReport,
|
||||
housekeeping.HousekeepingServiceReport,
|
||||
# folio.folioReport,
|
||||
# folio.folioByConsumerReport,
|
||||
module='hotel', type_='report')
|
||||
Pool.register(
|
||||
booking.SelectRooms,
|
||||
|
@ -88,14 +87,13 @@ def register():
|
|||
booking.BookingDaily,
|
||||
folio.OpenMigration,
|
||||
folio.GuestsList,
|
||||
# folio.CheckOutfolio,
|
||||
# folio.folioBill,
|
||||
# folio.ChangeRoom,
|
||||
# folio.Transferfolio,
|
||||
# folio.TransferCharge,
|
||||
folio.StatisticsByMonth,
|
||||
service.CreateDailyServices,
|
||||
housekeeping.HousekeepingService,
|
||||
sale.InvoiceIncomeDaily,
|
||||
party.CreateGuest,
|
||||
# folio.CheckOutfolio,
|
||||
# folio.ChangeRoom,
|
||||
# folio.Transferfolio,
|
||||
# folio.TransferCharge,
|
||||
module='hotel', type_='wizard')
|
||||
|
|
156
booking.py
156
booking.py
|
@ -1046,9 +1046,6 @@ class RoomsOccupancyReport(Report):
|
|||
else:
|
||||
occupancy_rate = 0
|
||||
|
||||
# recs = rooms_map.values()
|
||||
records = rooms_map.values()
|
||||
print('XXXXX.......', rooms_map)
|
||||
report_context['records'] = rooms_map.values()
|
||||
report_context['occupancy_rate'] = occupancy_rate
|
||||
report_context['occupancy_rooms'] = occupancy_rooms
|
||||
|
@ -1132,80 +1129,79 @@ class InvoicePaymentForm(ModelView):
|
|||
return Date.today()
|
||||
|
||||
|
||||
class WizardInvoicePayment(Wizard):
|
||||
'Wizard Invoice Payment'
|
||||
__name__ = 'invoice.payment'
|
||||
start = StateView('invoice.payment.form',
|
||||
'hotel.invoice_payment_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Pay', 'pay_', 'tryton-ok', default=True),
|
||||
])
|
||||
pay_ = StateTransition()
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(WizardInvoicePayment, cls).__setup__()
|
||||
|
||||
def default_start(self, fields):
|
||||
pool = Pool()
|
||||
Booking = pool.get('hotel.booking')
|
||||
Date = pool.get('ir.date')
|
||||
booking = Booking(Transaction().context['active_id'])
|
||||
return {
|
||||
'payment_amount': booking.pending_to_pay,
|
||||
'party': booking.party.id,
|
||||
'pay_date': Date.today(),
|
||||
}
|
||||
|
||||
def transition_pay_(self):
|
||||
pool = Pool()
|
||||
User = pool.get('res.user')
|
||||
Booking = pool.get('hotel.booking')
|
||||
Invoice = pool.get('account.invoice')
|
||||
active_id = Transaction().context.get('active_id', False)
|
||||
booking = Booking(active_id)
|
||||
|
||||
invoices = []
|
||||
for folio in booking.lines:
|
||||
inv = folio.invoice
|
||||
if inv.state != 'posted':
|
||||
continue
|
||||
invoices.append(inv)
|
||||
if not invoices:
|
||||
return 'end'
|
||||
|
||||
invoice = invoices[0]
|
||||
invoice.create_move_advance(booking.vouchers)
|
||||
|
||||
# if not sale.number:
|
||||
# Invoice.set_number([sale])
|
||||
|
||||
if not invoice.party.account_receivable:
|
||||
# raise PartyMissingAccount(
|
||||
# gettext('sale_pos.msg_party_without_account_receivable', s=sale.party.name))
|
||||
pass
|
||||
account = invoice.party.account_receivable.id
|
||||
|
||||
if form.payment_amount:
|
||||
payment = StatementLine(
|
||||
statement=statements[0].id,
|
||||
date=date.today(),
|
||||
amount=form.payment_amount,
|
||||
party=sale.party.id,
|
||||
account=account,
|
||||
description=self.start.voucher,
|
||||
sale=active_id,
|
||||
# number=self.start.voucher,
|
||||
# voucher=self.start.voucher,
|
||||
)
|
||||
payment.save()
|
||||
|
||||
if sale.total_amount != sale.paid_amount:
|
||||
return 'start'
|
||||
sale.save()
|
||||
if self.start.do_invoice:
|
||||
# for inv in sale.invoices:
|
||||
# if inv.state == 'posted':
|
||||
# inv.write([inv], {'state': 'draft'})
|
||||
Invoice.workflow_to_end([sale])
|
||||
return 'end'
|
||||
# class WizardInvoicePayment(Wizard):
|
||||
# 'Wizard Invoice Payment'
|
||||
# __name__ = 'invoice.payment'
|
||||
# start = StateView('invoice.payment.form',
|
||||
# 'hotel.invoice_payment_view_form', [
|
||||
# Button('Cancel', 'end', 'tryton-cancel'),
|
||||
# Button('Pay', 'pay_', 'tryton-ok', default=True),
|
||||
# ])
|
||||
# pay_ = StateTransition()
|
||||
#
|
||||
# @classmethod
|
||||
# def __setup__(cls):
|
||||
# super(WizardInvoicePayment, cls).__setup__()
|
||||
#
|
||||
# def default_start(self, fields):
|
||||
# pool = Pool()
|
||||
# Booking = pool.get('hotel.booking')
|
||||
# Date = pool.get('ir.date')
|
||||
# booking = Booking(Transaction().context['active_id'])
|
||||
# return {
|
||||
# 'payment_amount': booking.pending_to_pay,
|
||||
# 'party': booking.party.id,
|
||||
# 'pay_date': Date.today(),
|
||||
# }
|
||||
#
|
||||
# def transition_pay_(self):
|
||||
# pool = Pool()
|
||||
# Booking = pool.get('hotel.booking')
|
||||
# Invoice = pool.get('account.invoice')
|
||||
# active_id = Transaction().context.get('active_id', False)
|
||||
# booking = Booking(active_id)
|
||||
#
|
||||
# invoices = []
|
||||
# for folio in booking.lines:
|
||||
# inv = folio.invoice
|
||||
# if inv.state != 'posted':
|
||||
# continue
|
||||
# invoices.append(inv)
|
||||
# if not invoices:
|
||||
# return 'end'
|
||||
#
|
||||
# invoice = invoices[0]
|
||||
# invoice.create_move_advance(booking.vouchers)
|
||||
#
|
||||
# # if not sale.number:
|
||||
# # Invoice.set_number([sale])
|
||||
#
|
||||
# if not invoice.party.account_receivable:
|
||||
# # raise PartyMissingAccount(
|
||||
# # gettext('sale_pos.msg_party_without_account_receivable', s=sale.party.name))
|
||||
# pass
|
||||
# account = invoice.party.account_receivable.id
|
||||
#
|
||||
# if form.payment_amount:
|
||||
# payment = StatementLine(
|
||||
# statement=statements[0].id,
|
||||
# date=date.today(),
|
||||
# amount=form.payment_amount,
|
||||
# party=sale.party.id,
|
||||
# account=account,
|
||||
# description=self.start.voucher,
|
||||
# sale=active_id,
|
||||
# # number=self.start.voucher,
|
||||
# # voucher=self.start.voucher,
|
||||
# )
|
||||
# payment.save()
|
||||
#
|
||||
# if sale.total_amount != sale.paid_amount:
|
||||
# return 'start'
|
||||
# sale.save()
|
||||
# if self.start.do_invoice:
|
||||
# # for inv in sale.invoices:
|
||||
# # if inv.state == 'posted':
|
||||
# # inv.write([inv], {'state': 'draft'})
|
||||
# Invoice.workflow_to_end([sale])
|
||||
# return 'end'
|
||||
|
|
Binary file not shown.
81
folio.py
81
folio.py
|
@ -1849,53 +1849,52 @@ class GuestsListReport(Report):
|
|||
report_context = super().get_context(records, header, data)
|
||||
pool = Pool()
|
||||
Company = pool.get('company.company')
|
||||
# Operation = pool.get('hotel.operation')
|
||||
Folio = pool.get('hotel.folio')
|
||||
Room = pool.get('hotel.room')
|
||||
User = pool.get('res.user')
|
||||
user_id = Transaction().user
|
||||
|
||||
user = User(user_id)
|
||||
start_date = data['date']
|
||||
# operations = Operation.search([
|
||||
# ('start_date', '<=', start_date),
|
||||
# ('kind', '=', 'occupancy'),
|
||||
# ('state', '=', 'open'),
|
||||
# ], order=[('room.code', 'ASC')])
|
||||
#
|
||||
# total_guests = []
|
||||
# rooms_occupied = []
|
||||
# for op in operations:
|
||||
# total_guests.append(len(op.guests))
|
||||
# rooms_occupied.append(op.room.id)
|
||||
#
|
||||
# rooms = Room.search_read([])
|
||||
#
|
||||
# _rooms_occupied = len(set(rooms_occupied))
|
||||
# num_rooms = len(rooms)
|
||||
# if num_rooms:
|
||||
# occupancy_rate = round(_rooms_occupied / num_rooms, 2)
|
||||
# else:
|
||||
# occupancy_rate = 0
|
||||
#
|
||||
# operations_ = []
|
||||
# for op in operations:
|
||||
# for guest in op.guests:
|
||||
# operations_.append({
|
||||
# 'room': op.room.code,
|
||||
# 'guest': guest.party.name,
|
||||
# 'party': op.party.code,
|
||||
# 'start_date': op.start_date,
|
||||
# 'end_date': op.end_date,
|
||||
# 'nights_quantity': op.nights_quantity,
|
||||
# })
|
||||
# report_context['records'] = operations_
|
||||
# report_context['total_rooms'] = _rooms_occupied
|
||||
# report_context['total_guests'] = sum(total_guests)
|
||||
# report_context['occupancy_rate'] = occupancy_rate
|
||||
# report_context['company'] = Company(data['company']).party.name
|
||||
# report_context['date'] = data['date']
|
||||
# report_context['print_date'] = datetime.now()
|
||||
# report_context['user'] = user.name
|
||||
folios = Folio.search([
|
||||
('arrival_date', '<=', start_date),
|
||||
('registration_state', '=', 'check_in'),
|
||||
], order=[('room.code', 'ASC')])
|
||||
|
||||
total_guests = []
|
||||
rooms_occupied = []
|
||||
for op in folios:
|
||||
total_guests.append(len(op.guests))
|
||||
rooms_occupied.append(op.room.id)
|
||||
|
||||
rooms = Room.search_read([])
|
||||
|
||||
_rooms_occupied = len(set(rooms_occupied))
|
||||
num_rooms = len(rooms)
|
||||
if num_rooms:
|
||||
occupancy_rate = round(_rooms_occupied / num_rooms, 2)
|
||||
else:
|
||||
occupancy_rate = 0
|
||||
|
||||
guests = []
|
||||
for op in folios:
|
||||
for guest in op.guests:
|
||||
guests.append({
|
||||
'room': op.room.code,
|
||||
'guest': guest.party.name,
|
||||
'party': op.party.name if op.party else '',
|
||||
'arrival_date': op.arrival_date,
|
||||
'departure_date': op.departure_date,
|
||||
'nights_quantity': op.nights_quantity,
|
||||
})
|
||||
report_context['records'] = guests
|
||||
report_context['total_rooms'] = _rooms_occupied
|
||||
report_context['total_guests'] = sum(total_guests)
|
||||
report_context['occupancy_rate'] = occupancy_rate
|
||||
report_context['company'] = Company(data['company']).party.name
|
||||
report_context['date'] = data['date']
|
||||
report_context['print_date'] = datetime.now()
|
||||
report_context['user'] = user.name
|
||||
return report_context
|
||||
|
||||
|
||||
|
|
BIN
guests_list.fods
BIN
guests_list.fods
Binary file not shown.
Loading…
Reference in New Issue