Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/printing format #118

Merged
merged 3 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion inn/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
30 changes: 30 additions & 0 deletions inn/inn_hotels/doctype/inn_pos_usage/inn_extended_bill.py
Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 3 additions & 1 deletion inn/inn_hotels/doctype/inn_pos_usage/inn_pos_usage.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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": [
{
Expand Down
1 change: 1 addition & 0 deletions inn/inn_hotels/doctype/inn_pos_usage/inn_pos_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 1 addition & 3 deletions inn/inn_hotels/doctype/inn_room/inn_room.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') ||
Expand Down Expand Up @@ -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)
Expand All @@ -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",)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
"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,
"doc_type": "POS Invoice",
"docstatus": 0,
"doctype": "Print Format",
"font_size": 14,
"html": "<style>\n\t.print-format table, .print-format tr, \n\t.print-format td, .print-format div, .print-format p {\n\t\tline-height: 150%;\n\t\tvertical-align: middle;\n\t}\n\t@media screen {\n\t\t.print-format {\n\t\t\twidth: 4in;\n\t\t\tpadding: 0.25in;\n\t\t\tmin-height: 8in;\n\t\t}\n\t}\n</style>\n\n{% if letter_head %}\n {{ letter_head }}\n{% endif %}\n\n<p class=\"text-center\" style=\"margin-bottom: 1rem\">\n\t{{ doc.company }}<br>\n\t<b>{{ _(\"Bill\") }}</b><br>\n</p>\n<p>\n\t<b>{{ _(\"Receipt No\") }}:</b> {{ doc.name }}<br>\n\t<b>{{ _(\"Cashier\") }}:</b> {{ doc.owner }}<br>\n\t<b>{{ _(\"Customer\") }}:</b> {{ doc.customer_name }}<br>\n\t{% set table_number = get_table_number(doc.name) %}\n\n\t<b>{{ _(\"Table\") }}:</b> {{ table_number if table_number else \"None\" }}<br>\n\t<b>{{ _(\"Date\") }}:</b> {{ doc.get_formatted(\"posting_date\") }}<br>\n\t<b>{{ _(\"Time\") }}:</b> {{ doc.get_formatted(\"posting_time\") }}<br>\n</p>\n\n<hr>\n<table class=\"table table-condensed\">\n\t<thead>\n\t\t<tr>\n\t\t\t<th width=\"50%\">{{ _(\"Item\") }}</th>\n\t\t\t<th width=\"25%\" class=\"text-right\">{{ _(\"Qty\") }}</th>\n\t\t\t<th width=\"25%\" class=\"text-right\">{{ _(\"Amount\") }}</th>\n\t\t</tr>\n\t</thead>\n\t<tbody>\n\t\t{%- for item in doc.items -%}\n\t\t<tr>\n\t\t\t<td>\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<br>{{ item.item_name }}\n\t\t\t\t{%- endif -%}\n\t\t\t\t{%- if item.serial_no -%}\n\t\t\t\t\t<br><b>{{ _(\"SR.No\") }}:</b><br>\n\t\t\t\t\t{{ item.serial_no | replace(\"\\n\", \", \") }}\n\t\t\t\t{%- endif -%}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">{{ item.qty }}<br>@ {{ item.get_formatted(\"rate\") }}</td>\n\t\t\t<td class=\"text-right\">{{ item.get_formatted(\"amount\") }}</td>\n\t\t</tr>\n\t\t{%- endfor -%}\n\t</tbody>\n</table>\n<table class=\"table table-condensed no-border\">\n\t<tbody>\n\t\t<tr>\n\t\t\t{% if doc.flags.show_inclusive_tax_in_print %}\n\t\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t\t{{ _(\"Total Excl. Tax\") }}\n\t\t\t\t</td>\n\t\t\t\t<td class=\"text-right\">\n\t\t\t\t\t{{ doc.get_formatted(\"net_total\", doc) }}\n\t\t\t\t</td>\n\t\t\t{% else %}\n\t\t\t\t<td class=\"text-right\" style=\"width: 70%\">\n\t\t\t\t\t{{ _(\"Total\") }}\n\t\t\t\t</td>\n\t\t\t\t<td class=\"text-right\">\n\t\t\t\t\t{{ doc.get_formatted(\"total\", doc) }}\n\t\t\t\t</td>\n\t\t\t{% endif %}\n\t\t</tr>\n\t\t{%- for row in doc.taxes -%}\n\t\t {%- if not row.included_in_print_rate or doc.flags.show_inclusive_tax_in_print -%}\n\t\t\t<tr>\n\t\t\t\t<td class=\"text-right\" style=\"width: 70%\">\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</td>\n\t\t\t\t<td class=\"text-right\">\n\t\t\t\t\t{{ row.get_formatted(\"tax_amount\", doc) }}\n\t\t\t\t</td>\n\t\t\t<tr>\n\t\t {%- endif -%}\n\t\t{%- endfor -%}\n\n\t\t{%- if doc.discount_amount -%}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 75%\">\n\t\t\t\t{{ _(\"Discount\") }}\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ doc.get_formatted(\"discount_amount\") }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{%- endif -%}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 75%\">\n\t\t\t\t<b>{{ _(\"Grand Total\") }}</b>\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ doc.get_formatted(\"grand_total\") }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{%- if doc.rounded_total -%}\n\t\t<tr>\n\t\t\t<td class=\"text-right\" style=\"width: 75%\">\n\t\t\t\t<b>{{ _(\"Rounded Total\") }}</b>\n\t\t\t</td>\n\t\t\t<td class=\"text-right\">\n\t\t\t\t{{ doc.get_formatted(\"rounded_total\") }}\n\t\t\t</td>\n\t\t</tr>\n\t\t{%- endif -%}\n\t</tbody>\n</table>\n<hr>\n<p>{{ doc.terms or \"\" }}</p>",
"html": "{% set extra = extended_bil_extra_data(doc) %}\n\n<p class=\"text-center heading\">\n\t{{ doc.company }}<br>\n\t{{ extra.address }}<br>\n</p>\n\n<div class=\"detail\">\n <table>\n <tbody>\n <tr class=\"line-height-2px\">\n <td>Tanggal</td>\n <td>: {{doc.get_formatted(\"posting_date\") }} {{doc.get_formatted(\"posting_time\")}}</td>\n </tr>\n <tr class=\"line-height-2px\">\n <td>Nama</td>\n <td>: {{ doc.title }}</td>\n </tr>\n <tr class=\"line-height-2px\">\n <td>Order</td>\n <td>: {{ extra.order_id }}</td>\n </tr>\n <tr class=\"line-height-2px\">\n <td>Kasir</td>\n <td>: {{ doc.owner }}</td>\n </tr>\n </tbody>\n </table>\n</div>\n\n<div class=\"item-container\">\n{%- for item in doc.items -%}\n\t<div>\n\t\t<div class=\"item-name\">\n\t\t <br>{{ item.item_name }}\n\t\t</div>\n\t\t<div class=\"item-quantity\">\n \t<div>{{ item.qty }} @ {{ item.get_formatted(\"rate\") }}</div>\n \t<div>{{ item.get_formatted(\"amount\") }}</div>\n\t\t</div>\n\t</div>\n{%- endfor -%}\n</div>\n\n\n<div class=\"footer\">\n <div class=\"subtotal\">\n <div class=\"bill-label\">\n <p>{{_(\"Subtotal\")}}</p>\n </div>\n <div class=\"nominal\">\n <p>{{ doc.get_formatted(\"total\", doc) }}</p>\n </div>\n </div>\n \n {%- if extra.tax.name -%}\n <div class=\"tax\">\n <div class=\"bill-label\">\n <p>{{ extra.tax.name }}</p>\n </div>\n <div class=\"nominal\">\n <p>{{ extra.tax.total }}</p>\n </div>\n </div>\n\t{%- endif -%}\n\t\n {%- if doc.discount_amount -%}\n <div class=\"discount\">\n <div class=\"bill-label\">\n <p>{{_(\"Discount\")}}</p>\n </div>\n <div class=\"nominal\">\n <p>{{ doc.get_formatted(\"discount_amount\") }}</p>\n </div>\n </div>\n\t{%- endif -%}\n\t\n <div class=\"grand-total\">\n <div class=\"bill-label\">\n <p>{{_(\"Grand Total\")}}</p>\n </div>\n <div class=\"nominal\">\n <p>{{ doc.get_formatted(\"grand_total\") }}</p>\n </div>\n </div>\n \n \n\t{%- if doc.rounded_total -%}\n\t\n <div class=\"rounded-total\">\n <div class=\"bill-label\">\n <p>{{_(\"Rounded Total\")}}</p>\n </div>\n <div class=\"nominal\">\n <p>{{ doc.get_formatted(\"rounded_total\") }}</p>\n </div>\n </div>\n\t{%- endif -%}\n \n</div>\n",
"idx": 0,
"line_breaks": 0,
"margin_bottom": 15.0,
"margin_left": 15.0,
"margin_right": 15.0,
"margin_top": 15.0,
"modified": "2024-02-13 16:00:18.302763",
"modified": "2024-02-29 11:29:21.776161",
"modified_by": "Administrator",
"module": "Inn Hotels",
"name": "POS Extended Bill",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"absolute_value": 0,
"align_labels_right": 0,
"creation": "2024-02-13 10:57:02.837376",
"css": ".print-format table, .print-format tr, \n.print-format td, .print-format div, .print-format p {\n\tfont-family: Monospace;\n\tline-height: 200%;\n\tvertical-align: middle;\n}\n@media screen {\n\t.print-format {\n\t\twidth: 4in;\n\t\tpadding: 0.25in;\n\t\tmin-height: 8in;\n\t}\n}",
"css": ".print-format table, .print-format tr, \n.print-format td, .print-format div, .print-format p {\n\tfont-family: Monospace;\n\tline-height: 200%;\n\tvertical-align: middle;\n}\n@media screen {\n\t.print-format {\n\t\twidth: 4in;\n\t\tpadding: 0.25in;\n\t\tmin-height: 8in;\n\t}\n}\n\n.title {\n text-align: center;\n}\n\n.top-divider {\n border-top: dashed;\n}\n\ninput[type=\"checkbox\"] {\n transform:scale(1.5, 1.5);\n}",
"custom_format": 1,
"default_print_language": "en",
"disabled": 0,
Expand All @@ -11,14 +11,14 @@
"doctype": "Print Format",
"font": "Default",
"font_size": 0,
"html": "{% set list = print_list_order(doc.name) %}\n<p class=\"text-center\">\n\tOrder ID: {{doc.name}}<br />\n\tTable No: {{list.table}}<br/>\n</p>\n<hr>\n<table class=\"table table-condensed cart no-border\">\n\t<thead>\n\t\t<tr>\n\t\t\t<td width=\"25%\"><b>Qty</b></td>\n\t\t\t<td width=\"50%\"><b>Item</b></td>\n\t\t</tr>\n\t</thead>\n\t<tbody>\n\t\t{% for item in list[\"items\"] %}\n\t\t<tr>\n\t\t\t<td>{{ item.quantity }}</td>\n\t\t\t<td>{{ item.item_name }}</td>\n\t\t</tr>\n\t\t{% endfor %}\n\t</tbody>\n</table>\n",
"html": "{% set list = print_list_order(doc.name) %}\n<h1 class=\"text-center\">\n\tORDER: {{list.name}}<br />\n\tTABLE: {{list.table}}<br/>\n</h1>\n<hr class=\"top-divider\"><hr class=\"top-divider\">\n\n<div class=\"title\">\n<h1>PESANAN</h1>\n</div>\n<table class=\"\">\n\t<thead>\n\t\t<tr>\n\t\t <td width=\"10%\"></td>\n\t\t <td width=\"10%\"></td>\n\t\t\t<td width=\"10%\"></td>\n\t\t\t<td width=\"70%\"></td>\n\t\t</tr>\n\t</thead>\n\t<tbody>\n\t\t{% for item in list[\"items\"] %}\n\t\t<tr>\n\t\t <td></td>\n\t\t <td><h1><input type=\"checkbox\" \\></h1></td>\n\t\t\t<td><h1>{{ item.quantity }}</h1></td>\n\t\t\t<td><h1>{{ item.item_name }}</h1></td>\n\t\t</tr>\n\t\t{% endfor %}\n\t</tbody>\n</table>\n",
"idx": 0,
"line_breaks": 0,
"margin_bottom": 0.0,
"margin_left": 0.0,
"margin_right": 0.0,
"margin_top": 0.0,
"modified": "2024-02-13 14:10:30.526511",
"modified": "2024-02-28 14:50:01.251509",
"modified_by": "Administrator",
"module": "Inn Hotels",
"name": "POS Extended Captain Order",
Expand Down
Loading