From f450df9ead1bdbf3c70e1f43731571d1a61e19c3 Mon Sep 17 00:00:00 2001 From: Hilmy <54829572+anhilmy@users.noreply.github.com> Date: Thu, 29 Feb 2024 13:12:14 +0700 Subject: [PATCH] Feat/printing format (#118) * feat: add bill print * feat: add print receipt * fix address --- inn/hooks.py | 3 +- .../inn_hotels_setting.json | 22 +++++++++++++- .../inn_pos_usage/inn_extended_bill.py | 30 +++++++++++++++++++ .../doctype/inn_pos_usage/inn_pos_usage.json | 4 ++- .../doctype/inn_pos_usage/inn_pos_usage.py | 1 + inn/inn_hotels/doctype/inn_room/inn_room.js | 4 +-- .../pos_extended_bill/pos_extended_bill.json | 5 ++-- .../pos_extended_captain_order.json | 6 ++-- .../pos_extended_invoice.json | 5 ++-- .../pos_extended_table_order.json | 2 +- 10 files changed, 68 insertions(+), 14 deletions(-) create mode 100644 inn/inn_hotels/doctype/inn_pos_usage/inn_extended_bill.py diff --git a/inn/hooks.py b/inn/hooks.py index 98066db..a3ac7b8 100644 --- a/inn/hooks.py +++ b/inn/hooks.py @@ -134,7 +134,8 @@ "inn.inn_hotels.doctype.inn_reservation.inn_reservation.get_date", "inn.inn_hotels.doctype.inn_pos_usage.inn_pos_usage.print_list_order", - "inn.inn_hotels.page.pos_extended.pos_extended.get_table_number" + "inn.inn_hotels.page.pos_extended.pos_extended.get_table_number", + "inn.inn_hotels.doctype.inn_pos_usage.inn_extended_bill.extended_bil_extra_data" ] } diff --git a/inn/inn_hotels/doctype/inn_hotels_setting/inn_hotels_setting.json b/inn/inn_hotels/doctype/inn_hotels_setting/inn_hotels_setting.json index bc19fa1..a08eaef 100644 --- a/inn/inn_hotels/doctype/inn_hotels_setting/inn_hotels_setting.json +++ b/inn/inn_hotels/doctype/inn_hotels_setting/inn_hotels_setting.json @@ -45,6 +45,9 @@ "profit_sharing_account", "profit_sharing_transaction_type", "service_charge_account", + "inn_pos_extended_section", + "tax_name_pos_receipt", + "pos_receipt_remarks", "master_data_generator_sb", "bed_type_generator", "room_type_generator", @@ -321,11 +324,28 @@ "label": "Number of Floor", "non_negative": 1, "reqd": 1 + }, + { + "fieldname": "inn_pos_extended_section", + "fieldtype": "Section Break", + "label": "Inn POS Extended" + }, + { + "default": "Tax&Service (21%)", + "fieldname": "tax_name_pos_receipt", + "fieldtype": "Data", + "label": "Tax Name POS Receipt", + "reqd": 1 + }, + { + "fieldname": "pos_receipt_remarks", + "fieldtype": "Small Text", + "label": "POS Receipt Remarks" } ], "issingle": 1, "links": [], - "modified": "2024-02-27 09:29:10.285393", + "modified": "2024-02-29 11:35:51.569635", "modified_by": "Administrator", "module": "Inn Hotels", "name": "Inn Hotels Setting", diff --git a/inn/inn_hotels/doctype/inn_pos_usage/inn_extended_bill.py b/inn/inn_hotels/doctype/inn_pos_usage/inn_extended_bill.py new file mode 100644 index 0000000..d8afb1f --- /dev/null +++ b/inn/inn_hotels/doctype/inn_pos_usage/inn_extended_bill.py @@ -0,0 +1,30 @@ +import frappe +from frappe import utils + + +def extended_bil_extra_data(invoice): + + tax_name = frappe.db.get_single_value("Inn Hotels Setting", "tax_name_pos_receipt", True) + + address = frappe.get_all("Dynamic Link", filters={"link_doctype": "Company", "link_name": invoice.company,"parenttype":"Address"}, fields=["parent"]) + if address: + address = frappe.get_value("Address", filters=address[0].parent, fieldname="address_line1", as_dict=True) + + order_id = frappe.get_value("Inn POS Usage", filters={"pos_invoice": invoice.name}, fieldname="name", as_dict=True) + + total_tax = 0 + for tax in invoice.taxes: + total_tax += tax.tax_amount + total_tax = utils.fmt_money(total_tax, 2, "Rp") + + remarks = frappe.db.get_single_value("Inn Hotels Setting", "pos_receipt_remarks", True) + + return { + "address": address.address_line1, + "order_id": order_id.name, + "tax": { + "name": tax_name, + "total": total_tax + }, + "remarks": remarks + } \ No newline at end of file diff --git a/inn/inn_hotels/doctype/inn_pos_usage/inn_pos_usage.json b/inn/inn_hotels/doctype/inn_pos_usage/inn_pos_usage.json index 3074a8d..0a0e52f 100644 --- a/inn/inn_hotels/doctype/inn_pos_usage/inn_pos_usage.json +++ b/inn/inn_hotels/doctype/inn_pos_usage/inn_pos_usage.json @@ -1,6 +1,7 @@ { "actions": [], "allow_rename": 1, + "autoname": "format:FB-{DD}/{MM}/{YY}-{####}", "creation": "2024-02-12 11:06:40.509746", "doctype": "DocType", "engine": "InnoDB", @@ -51,10 +52,11 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-02-13 12:38:30.114825", + "modified": "2024-02-28 14:17:01.329170", "modified_by": "Administrator", "module": "Inn Hotels", "name": "Inn POS Usage", + "naming_rule": "Expression", "owner": "Administrator", "permissions": [ { diff --git a/inn/inn_hotels/doctype/inn_pos_usage/inn_pos_usage.py b/inn/inn_hotels/doctype/inn_pos_usage/inn_pos_usage.py index 3ab43f0..65166ea 100644 --- a/inn/inn_hotels/doctype/inn_pos_usage/inn_pos_usage.py +++ b/inn/inn_hotels/doctype/inn_pos_usage/inn_pos_usage.py @@ -13,6 +13,7 @@ class InnPOSUsage(Document): def print_list_order(pos_invoice): order_dict = frappe.get_last_doc('Inn POS Usage', filters={'pos_invoice': pos_invoice}) res = { + "name": order_dict.name, "table": order_dict.table, "items": order_dict.new_item } diff --git a/inn/inn_hotels/doctype/inn_room/inn_room.js b/inn/inn_hotels/doctype/inn_room/inn_room.js index d2fa978..ef0650d 100644 --- a/inn/inn_hotels/doctype/inn_room/inn_room.js +++ b/inn/inn_hotels/doctype/inn_room/inn_room.js @@ -3,9 +3,7 @@ frappe.ui.form.on('Inn Room', { refresh: function (frm, cdt, cdn) { - set_option_floor_plan(frm) - if (frappe.user.has_role('Housekeeping') || frappe.user.has_role('Housekeeping Assistant') || frappe.user.has_role('Housekeeping Supervisor') || @@ -116,6 +114,7 @@ frappe.ui.form.on('Inn Room', { let form_control_field; async function set_option_floor_plan(frm) { + frm.set_df_property("floor", "hidden", true) wrapper = $(".layout-main-section").find('div[data-fieldname="room_detail"]').find('.section-body').find('div[data-fieldname="column_break"').find("form") if (!wrapper.find('[data-fieldname="floor_choice"]').length) { await create_choice_field_floor(frm, wrapper) @@ -127,7 +126,6 @@ async function set_option_floor_plan(frm) { } async function create_choice_field_floor(frm, wrapper) { - frm.set_df_property("floor", "hidden", true) let opt_floor = [""] await frappe.db.get_single_value("Inn Hotels Setting", "number_of_floor",) diff --git a/inn/inn_hotels/print_format/pos_extended_bill/pos_extended_bill.json b/inn/inn_hotels/print_format/pos_extended_bill/pos_extended_bill.json index 373ec7c..47adab3 100644 --- a/inn/inn_hotels/print_format/pos_extended_bill/pos_extended_bill.json +++ b/inn/inn_hotels/print_format/pos_extended_bill/pos_extended_bill.json @@ -2,6 +2,7 @@ "absolute_value": 0, "align_labels_right": 0, "creation": "2024-02-12 15:19:53.428647", + "css": ".heading {\n border-bottom: dashed;\n padding-bottom: 0.5rem;\n box-sizing: content-box;\n}\n\n.detail {\n border-top: dashed;\n padding: 0.5rem 0;\n}\n\n.item-container {\n border-top: thin dashed;\n border-bottom: thin dashed;\n padding: 0 0.5rem 1rem;\n}\n\n.item-name {\n line-height: 1rem;\n}\n\n.item-quantity {\n display: flex;\n justify-content: flex-end;\n}\n\n.item-quantity > div {\n margin-left: 3rem;\n}\n\n.line-height-2px {\n line-height: 2px;\n}\n\n.footer {\n margin: 0.5rem;\n}\n\n.footer > div {\n display: flex;\n justify-content: space-between;\n}\n\n.nominal {\n text-align: end;\n}\n\n@media screen {\n\t.print-format {\n\t\twidth: 4in;\n\t\tpadding: 0.25in;\n\t\tmin-height: 1in;\n\t}\n}", "custom_format": 1, "default_print_language": "en", "disabled": 0, @@ -9,14 +10,14 @@ "docstatus": 0, "doctype": "Print Format", "font_size": 14, - "html": "\n\n{% if letter_head %}\n {{ letter_head }}\n{% endif %}\n\n
\n\t{{ doc.company }}
\n\t{{ _(\"Bill\") }}
\n
\n\t{{ _(\"Receipt No\") }}: {{ doc.name }}
\n\t{{ _(\"Cashier\") }}: {{ doc.owner }}
\n\t{{ _(\"Customer\") }}: {{ doc.customer_name }}
\n\t{% set table_number = get_table_number(doc.name) %}\n\n\t{{ _(\"Table\") }}: {{ table_number if table_number else \"None\" }}
\n\t{{ _(\"Date\") }}: {{ doc.get_formatted(\"posting_date\") }}
\n\t{{ _(\"Time\") }}: {{ doc.get_formatted(\"posting_time\") }}
\n
{{ _(\"Item\") }} | \n\t\t\t{{ _(\"Qty\") }} | \n\t\t\t{{ _(\"Amount\") }} | \n\t\t
---|---|---|
\n\t\t\t\t{{ item.item_code }}\n\t\t\t\t{%- if item.item_name != item.item_code -%}\n\t\t\t\t\t {{ item.item_name }}\n\t\t\t\t{%- endif -%}\n\t\t\t\t{%- if item.serial_no -%}\n\t\t\t\t\t {{ _(\"SR.No\") }}: \n\t\t\t\t\t{{ item.serial_no | replace(\"\\n\", \", \") }}\n\t\t\t\t{%- endif -%}\n\t\t\t | \n\t\t\t{{ item.qty }} @ {{ item.get_formatted(\"rate\") }} | \n\t\t\t{{ item.get_formatted(\"amount\") }} | \n\t\t
\n\t\t\t\t\t{{ _(\"Total Excl. Tax\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"net_total\", doc) }}\n\t\t\t\t | \n\t\t\t{% else %}\n\t\t\t\t\n\t\t\t\t\t{{ _(\"Total\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"total\", doc) }}\n\t\t\t\t | \n\t\t\t{% endif %}\n\t\t
\n\t\t\t\t {% if '%' in row.description %}\n\t\t\t\t\t {{ row.description }}\n\t\t\t\t\t{% else %}\n\t\t\t\t\t {{ row.description }}@{{ row.rate }}%\n\t\t\t\t\t{% endif %}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ row.get_formatted(\"tax_amount\", doc) }}\n\t\t\t\t | \n\t\t\t||
\n\t\t\t\t{{ _(\"Discount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"discount_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Grand Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"grand_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Rounded Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"rounded_total\") }}\n\t\t\t | \n\t\t
{{ doc.terms or \"\" }}
", + "html": "{% set extra = extended_bil_extra_data(doc) %}\n\n\n\t{{ doc.company }}
\n\t{{ extra.address }}
\n
Tanggal | \n: {{doc.get_formatted(\"posting_date\") }} {{doc.get_formatted(\"posting_time\")}} | \n
Nama | \n: {{ doc.title }} | \n
Order | \n: {{ extra.order_id }} | \n
Kasir | \n: {{ doc.owner }} | \n
\n\tOrder ID: {{doc.name}}
\n\tTable No: {{list.table}}
\n
Qty | \n\t\t\tItem | \n\t\t
{{ item.quantity }} | \n\t\t\t{{ item.item_name }} | \n\t\t
\n\t\t | \n\t\t\t | \n\t\t\t | \n\t\t |
\n\t\t | \n\t\t\t | {{ item.quantity }} | \n\t\t\t{{ item.item_name }} | \n\t\t
\n\t{{ doc.company }}
\n\t{{ doc.select_print_heading or _(\"Invoice\") }}
\n
\n\t{{ _(\"Receipt No\") }}: {{ doc.name }}
\n\t{{ _(\"Cashier\") }}: {{ doc.owner }}
\n\t{{ _(\"Customer\") }}: {{ doc.customer_name }}
\n\t{{ _(\"Table\") }}: {{ frappe.db.get_value(doctype=\"Inn POS Usage\", filters={\"pos_invoice\": doc.name}, fieldname=[\"table\"]) }}
\n\t{{ _(\"Date\") }}: {{ doc.get_formatted(\"posting_date\") }}
\n\t{{ _(\"Time\") }}: {{ doc.get_formatted(\"posting_time\") }}
\n
{{ _(\"Item\") }} | \n\t\t\t{{ _(\"Qty\") }} | \n\t\t\t{{ _(\"Amount\") }} | \n\t\t
---|---|---|
\n\t\t\t\t{{ item.item_code }}\n\t\t\t\t{%- if item.item_name != item.item_code -%}\n\t\t\t\t\t {{ item.item_name }}\n\t\t\t\t{%- endif -%}\n\t\t\t\t{%- if item.serial_no -%}\n\t\t\t\t\t {{ _(\"SR.No\") }}: \n\t\t\t\t\t{{ item.serial_no | replace(\"\\n\", \", \") }}\n\t\t\t\t{%- endif -%}\n\t\t\t | \n\t\t\t{{ item.qty }} @ {{ item.get_formatted(\"rate\") }} | \n\t\t\t{{ item.get_formatted(\"amount\") }} | \n\t\t
\n\t\t\t\t\t{{ _(\"Total Excl. Tax\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"net_total\", doc) }}\n\t\t\t\t | \n\t\t\t{% else %}\n\t\t\t\t\n\t\t\t\t\t{{ _(\"Total\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"total\", doc) }}\n\t\t\t\t | \n\t\t\t{% endif %}\n\t\t
\n\t\t\t\t {% if '%' in row.description %}\n\t\t\t\t\t {{ row.description }}\n\t\t\t\t\t{% else %}\n\t\t\t\t\t {{ row.description }}@{{ row.rate }}%\n\t\t\t\t\t{% endif %}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ row.get_formatted(\"tax_amount\", doc) }}\n\t\t\t\t | \n\t\t\t||
\n\t\t\t\t{{ _(\"Discount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"discount_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Grand Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"grand_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t{{ _(\"Rounded Total\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"rounded_total\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t {{ row.mode_of_payment }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ row.get_formatted(\"amount\", doc) }}\n\t\t\t\t | \n\t\t\t||
\n\t\t\t\t{{ _(\"Paid Amount\") }}\n\t\t\t | \n\t\t\t\n\t\t\t\t{{ doc.get_formatted(\"paid_amount\") }}\n\t\t\t | \n\t\t||
\n\t\t\t\t\t{{ _(\"Change Amount\") }}\n\t\t\t\t | \n\t\t\t\t\n\t\t\t\t\t{{ doc.get_formatted(\"change_amount\") }}\n\t\t\t\t | \n\t\t\t
{{ doc.terms or \"\" }}
\n{{ _(\"Thank you, please visit again.\") }}
", + "html": "{% set extra = extended_bil_extra_data(doc) %}\n\n\n\t{{ doc.company }}
\n\t{{ extra.address }}
\n
Tanggal | \n: {{doc.get_formatted(\"posting_date\") }} {{doc.get_formatted(\"posting_time\")}} | \n
Nomor Resi | \n: {{doc.name }} | \n
Order | \n: {{ extra.order_id }} | \n
Nama | \n: {{ doc.title }} | \n
Kasir | \n: {{ doc.owner }} | \n
Payment | \n: | \n{{ row.mode_of_payment }} | \n
Paid Amt | \n: | \n{{ doc.get_formatted(\"paid_amount\", doc) }} | \n
Change | \n: | \n{{ doc.get_formatted(\"change_amount\", doc) }} | \n