-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add: card to operation workspace * feat: workspace to include all statistic * fix: remove percentage and rename * fix: custoerm inn flow * fix: inn booking from guest booking form * fix; customer and channe; * fix: add max_floor and fix arr * fix; inn room add floor fix * fix: out or order room * fix: bugs and add helper role * fix: does not exist * Feat/printing format (#118) * feat: add bill print * feat: add print receipt * fix address * fix: card number to today date fixed
- Loading branch information
Showing
15 changed files
with
603 additions
and
5 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
inn/inn_hotels/doctype/inn_reservation/inn_reservation_card.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import frappe | ||
from datetime import date | ||
|
||
|
||
@frappe.whitelist() | ||
def get_card_number_expected_departure(): | ||
today = date.today().isoformat() | ||
data = frappe.db.count("Inn Reservation", {"status": ["!=", "Finish"], "expected_departure": today}) | ||
|
||
result = { | ||
"value": data, | ||
"fieldtype": "Int", | ||
"route_options": {"expected_departure": today, "status": ["!=", "Finish"]}, | ||
"route": ["inn-reservation"] | ||
} | ||
|
||
return result | ||
|
||
|
||
@frappe.whitelist() | ||
def get_card_number_expected_arrival(): | ||
today = date.today().isoformat() | ||
data = frappe.db.count("Inn Reservation", {"status": ["!=", "In House"], "expected_arrival": today}) | ||
|
||
result = { | ||
"value": data, | ||
"fieldtype": "Int", | ||
"route_options": {"expected_arrival": today, "status": ["!=", "In House"]}, | ||
"route": ["inn-reservation"] | ||
} | ||
|
||
return result |
266 changes: 266 additions & 0 deletions
266
inn/inn_hotels/doctype/inn_room_booking/inn_room_card_owner_webcard.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,266 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2020, Core Initiative and contributors | ||
# For license information, please see license.txt | ||
|
||
from __future__ import unicode_literals | ||
import frappe | ||
from frappe.model.document import Document | ||
from dateutil.parser import parse | ||
from datetime import date, timedelta | ||
|
||
def count_all_room(start_date, end_date): | ||
default_availability = frappe.db.count("Inn Room") | ||
try: | ||
start_date = parse(start_date, False).date() | ||
except ValueError: | ||
raise frappe.ValidationError("{start_date} is not a valid date string") | ||
|
||
try: | ||
end_date = parse(end_date, False).date() | ||
except ValueError: | ||
raise frappe.ValidationError("{end_date} is not a valid date string") | ||
|
||
delta = end_date - start_date | ||
if delta.days < 0: | ||
raise frappe.ValidationError("start date must before end date") | ||
|
||
return default_availability * delta.days | ||
|
||
@frappe.whitelist() | ||
def count_sold_room(start_date = None, end_date=None): | ||
if start_date == None and end_date == None: | ||
start_date = date.today().isoformat() | ||
end_date = date.today() + timedelta(days=1) | ||
end_date = end_date.isoformat() | ||
|
||
|
||
try: | ||
start_date = parse(start_date, False).date() | ||
except ValueError: | ||
raise frappe.ValidationError("{start_date} is not a valid date string") | ||
|
||
try: | ||
end_date = parse(end_date, False).date() | ||
except ValueError: | ||
raise frappe.ValidationError("{end_date} is not a valid date string") | ||
|
||
delta = end_date - start_date | ||
if delta.days < 0: | ||
raise frappe.ValidationError("start date must before end date") | ||
|
||
|
||
total_sold = 0 | ||
# calculate reservation start before start_date and reservation end after start date | ||
current_sold = frappe.db.get_values(doctype="Inn Room Booking", filters={"start": ["<", start_date], "end": [">", start_date], "room_availability": "Room Sold"}, fieldname=["start", "end"], as_dict=True) | ||
for ii in current_sold: | ||
room_end_date = ii.end | ||
if room_end_date > end_date: | ||
room_end_date = end_date | ||
|
||
days_sold = (room_end_date - start_date).days | ||
total_sold += days_sold | ||
|
||
|
||
# calculate reservation start after start_date and reservations start before before_date | ||
current_sold = frappe.db.get_values(doctype="Inn Room Booking", filters=[["start", "between", [start_date, end_date]], ["room_availability", "=", "Room Sold"]], fieldname=["start", "end"], as_dict=True) | ||
for ii in current_sold: | ||
room_start_date = ii.start | ||
room_end_date = ii.end | ||
if room_end_date > end_date: | ||
room_end_date = end_date | ||
|
||
days_sold = (room_end_date - room_start_date).days | ||
total_sold += days_sold | ||
|
||
return { | ||
"value": total_sold, | ||
"fieldtype": "Int" | ||
} | ||
|
||
@frappe.whitelist() | ||
def count_available_room(start_date=None, end_date=None): | ||
if start_date == None and end_date == None: | ||
start_date = date.today().isoformat() | ||
end_date = date.today() + timedelta(days=1) | ||
end_date = end_date.isoformat() | ||
|
||
|
||
default_availability = frappe.db.count("Inn Room") | ||
try: | ||
start_date = parse(start_date, False).date() | ||
except ValueError: | ||
raise frappe.ValidationError("{start_date} is not a valid date string") | ||
|
||
try: | ||
end_date = parse(end_date, False).date() | ||
except ValueError: | ||
raise frappe.ValidationError("{end_date} is not a valid date string") | ||
|
||
delta = end_date - start_date | ||
if delta.days < 0: | ||
raise frappe.ValidationError("start date must before end date") | ||
|
||
|
||
all_room = default_availability * delta.days | ||
|
||
total_sold = 0 | ||
# calculate reservation start before start_date and reservation end after start date | ||
current_used = frappe.db.get_values(doctype="Inn Room Booking", filters={"start": ["<", start_date], "end": [">", start_date]}, fieldname=["start", "end"], as_dict=True) | ||
for ii in current_used: | ||
room_end_date = ii.end | ||
if room_end_date > end_date: | ||
room_end_date = end_date | ||
|
||
days_sold = (room_end_date - start_date).days | ||
total_sold += days_sold | ||
|
||
|
||
# calculate reservation start after start_date and reservations start before before_date | ||
current_used = frappe.db.get_values(doctype="Inn Room Booking", filters=[["start", "between", [start_date, end_date]]], fieldname=["start", "end"], as_dict=True) | ||
for ii in current_used: | ||
room_start_date = ii.start | ||
room_end_date = ii.end | ||
if room_end_date > end_date: | ||
room_end_date = end_date | ||
|
||
days_sold = (room_end_date - room_start_date).days | ||
total_sold += days_sold | ||
|
||
return { | ||
"value": all_room - total_sold, | ||
"fieldtype": "Int" | ||
} | ||
|
||
@frappe.whitelist() | ||
def count_ooo_room(start_date=None, end_date=None): | ||
if start_date == None and end_date == None: | ||
start_date = date.today().isoformat() | ||
end_date = date.today() + timedelta(days=1) | ||
end_date = end_date.isoformat() | ||
|
||
|
||
try: | ||
start_date = parse(start_date, False) | ||
except ValueError: | ||
raise frappe.ValidationError("{start_date} is not a valid date string") | ||
|
||
try: | ||
end_date = parse(end_date, False) | ||
except ValueError: | ||
raise frappe.ValidationError("{end_date} is not a valid date string") | ||
|
||
delta = end_date - start_date | ||
if delta.days < 0: | ||
raise frappe.ValidationError("start date must before end date") | ||
|
||
|
||
total_sold = 0 | ||
# calculate reservation start before start_date and reservation end after start date | ||
current_ooo = frappe.db.get_values(doctype="Inn Room Booking", filters={"start": ["<", start_date], "end": [">", start_date], "room_availability": "Out of Order"}, fieldname=["start", "end"], as_dict=True) | ||
for ii in current_ooo: | ||
room_end_date = ii.end | ||
if room_end_date > end_date: | ||
room_end_date = end_date | ||
|
||
days_sold = (room_end_date - start_date).days | ||
total_sold += days_sold | ||
|
||
|
||
# calculate reservation start after start_date and reservations start before before_date | ||
current_ooo = frappe.db.get_values(doctype="Inn Room Booking", filters=[["start", "between", [start_date, end_date]], ["room_availability", "=", "Out of Order"]], fieldname=["start", "end"], as_dict=True) | ||
for ii in current_ooo: | ||
room_start_date = ii.start | ||
room_end_date = ii.end | ||
if room_end_date > end_date: | ||
room_end_date = end_date | ||
|
||
days_sold = (room_end_date - room_start_date).days | ||
total_sold += days_sold | ||
|
||
return { | ||
"value": total_sold, | ||
"fieldtype": "Int" | ||
} | ||
|
||
def calculate_total_rate_and_sold(start_date, end_date): | ||
try: | ||
start_date = parse(start_date, False).date() | ||
except ValueError: | ||
raise frappe.ValidationError("{start_date} is not a valid date string") | ||
|
||
try: | ||
end_date = parse(end_date, False).date() | ||
except ValueError: | ||
raise frappe.ValidationError("{end_date} is not a valid date string") | ||
|
||
delta = end_date - start_date | ||
if delta.days < 0: | ||
raise frappe.ValidationError("start date must before end date") | ||
|
||
total_sold = 0 | ||
total_rate = 0 | ||
cached_rate = {} | ||
# calculate reservation start before start_date and reservation end after start date | ||
current_sold = frappe.db.get_values(doctype="Inn Reservation", filters={"arrival": ["<", start_date], "expected_departure": [">", start_date]}, fieldname=["arrival", "expected_departure", "room_rate"], as_dict=True) | ||
for ii in current_sold: | ||
room_end_date = ii.expected_departure | ||
if room_end_date > end_date: | ||
room_end_date = end_date | ||
|
||
days_sold = (room_end_date - start_date).days | ||
total_sold += days_sold | ||
|
||
if ii.room_rate not in cached_rate: | ||
room_rate = frappe.db.get_value(doctype="Inn Room Rate", filters={"name": ii.room_rate}, fieldname="final_total_rate_amount") | ||
cached_rate[ii.room_rate] = room_rate.final_total_rate_amount | ||
|
||
total_rate = cached_rate[ii.room_rate] * days_sold | ||
|
||
|
||
# calculate reservation start after start_date and reservations start before before_date | ||
current_sold = frappe.db.get_values(doctype="Inn Reservation", filters=[["expected_arrival", "between", [start_date, end_date]]], fieldname=["expected_arrival", "expected_departure", "room_rate"], as_dict=True) | ||
for ii in current_sold: | ||
room_start_date = ii.expected_arrival | ||
room_end_date = ii.expected_departure | ||
if room_end_date > end_date: | ||
room_end_date = end_date | ||
|
||
days_sold = (room_end_date - room_start_date).days | ||
total_sold += days_sold | ||
|
||
|
||
if ii.room_rate not in cached_rate: | ||
room_rate = frappe.db.get_value(doctype="Inn Room Rate", filters={"name": ii.room_rate}, fieldname="final_total_rate_amount") | ||
cached_rate[ii.room_rate] = room_rate | ||
total_rate += cached_rate[ii.room_rate] * days_sold | ||
|
||
return total_rate, total_sold | ||
|
||
@frappe.whitelist() | ||
def calculate_average_rate(start_date=None, end_date=None): | ||
if start_date == None and end_date == None: | ||
start_date = date.today().isoformat() | ||
end_date = date.today() + timedelta(days=1) | ||
end_date = end_date.isoformat() | ||
total_rate, total_sold = calculate_total_rate_and_sold(start_date, end_date) | ||
if total_sold == 0: | ||
value = 0 | ||
else: | ||
value = total_rate / total_sold | ||
|
||
return { | ||
"value": value, | ||
"fieldtype": "Currency" | ||
} | ||
|
||
@frappe.whitelist() | ||
def calculate_total_rate(start_date=None, end_date=None): | ||
if start_date == None and end_date == None: | ||
start_date = date.today().isoformat() | ||
end_date = date.today() + timedelta(days=1) | ||
end_date = end_date.isoformat() | ||
total_rate, _ = calculate_total_rate_and_sold(start_date, end_date) | ||
return { | ||
"value": total_rate, | ||
"fieldtype": "Int" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"color": "#ECAD4B", | ||
"creation": "2024-02-22 13:27:29.372728", | ||
"docstatus": 0, | ||
"doctype": "Number Card", | ||
"filters_json": "null", | ||
"function": "Count", | ||
"idx": 0, | ||
"is_public": 0, | ||
"is_standard": 1, | ||
"label": "Arrival", | ||
"method": "inn.inn_hotels.doctype.inn_reservation.inn_reservation_card.get_card_number_expected_arrival", | ||
"modified": "2024-02-22 13:52:18.349937", | ||
"modified_by": "Administrator", | ||
"module": "Inn Hotels", | ||
"name": "Arrival", | ||
"owner": "Administrator", | ||
"report_function": "Sum", | ||
"show_percentage_stats": 1, | ||
"stats_time_interval": "Daily", | ||
"type": "Custom" | ||
} |
23 changes: 23 additions & 0 deletions
23
inn/inn_hotels/number_card/inn_hotel_aar_room_sold/inn_hotel_aar_room_sold.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"color": "#B4CD29", | ||
"creation": "2024-02-22 14:19:41.547594", | ||
"docstatus": 0, | ||
"doctype": "Number Card", | ||
"filters_config": "[{\n fieldname: \"start_date\",\n label: \"Start Date\", \n fieldtype: \"Date\",\n reqd: 1\n}, {\n fieldname: \"end_date\",\n label: \"End Date\",\n fieldtype: \"Date\",\n reqd: 1\n}]", | ||
"filters_json": "{}", | ||
"function": "Count", | ||
"idx": 0, | ||
"is_public": 0, | ||
"is_standard": 1, | ||
"label": "Inn Hotel AAR Room Sold", | ||
"method": "inn.inn_hotels.doctype.inn_room_booking.inn_room_card_owner_webcard.calculate_average_rate", | ||
"modified": "2024-02-22 14:20:11.160526", | ||
"modified_by": "Administrator", | ||
"module": "Inn Hotels", | ||
"name": "Inn Hotel AAR Room Sold", | ||
"owner": "Administrator", | ||
"report_function": "Sum", | ||
"show_percentage_stats": 1, | ||
"stats_time_interval": "Daily", | ||
"type": "Custom" | ||
} |
23 changes: 23 additions & 0 deletions
23
inn/inn_hotels/number_card/inn_hotel_available_room/inn_hotel_available_room.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"color": "#4F9DD9", | ||
"creation": "2024-02-22 14:18:15.704194", | ||
"docstatus": 0, | ||
"doctype": "Number Card", | ||
"filters_config": "[{\n fieldname: \"start_date\",\n label: \"Start Date\", \n fieldtype: \"Date\",\n reqd: 1\n}, {\n fieldname: \"end_date\",\n label: \"End Date\",\n fieldtype: \"Date\",\n reqd: 1\n}]", | ||
"filters_json": "{}", | ||
"function": "Count", | ||
"idx": 0, | ||
"is_public": 0, | ||
"is_standard": 1, | ||
"label": "Inn Hotel Available Room", | ||
"method": "inn.inn_hotels.doctype.inn_room_booking.inn_room_card_owner_webcard.count_available_room", | ||
"modified": "2024-02-22 14:26:58.050253", | ||
"modified_by": "Administrator", | ||
"module": "Inn Hotels", | ||
"name": "Inn Hotel Available Room", | ||
"owner": "Administrator", | ||
"report_function": "Sum", | ||
"show_percentage_stats": 1, | ||
"stats_time_interval": "Daily", | ||
"type": "Custom" | ||
} |
22 changes: 22 additions & 0 deletions
22
inn/inn_hotels/number_card/inn_hotel_expected_departure/inn_hotel_expected_departure.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"color": "#CB2929", | ||
"creation": "2024-02-22 13:52:41.666131", | ||
"docstatus": 0, | ||
"doctype": "Number Card", | ||
"filters_json": "null", | ||
"function": "Count", | ||
"idx": 0, | ||
"is_public": 0, | ||
"is_standard": 1, | ||
"label": "Inn Hotel Expected Departure", | ||
"method": "inn.inn_hotels.doctype.inn_reservation.inn_reservation_card.get_card_number_expected_departure", | ||
"modified": "2024-02-22 13:52:47.344662", | ||
"modified_by": "Administrator", | ||
"module": "Inn Hotels", | ||
"name": "Inn Hotel Expected Departure", | ||
"owner": "Administrator", | ||
"report_function": "Sum", | ||
"show_percentage_stats": 1, | ||
"stats_time_interval": "Daily", | ||
"type": "Custom" | ||
} |
Oops, something went wrong.