blob: f99711631ffab607d2e51676ea04dda13566c474 [file] [log] [blame]
Anand Doshi885e0742015-03-03 14:55:30 +05301# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
Rushabh Mehta0e132212015-02-04 17:02:24 +05302# License: GNU General Public License v3. See license.txt
3
Chillar Anand915b3432021-09-02 16:44:59 +05304
prssanna71e5b602020-10-29 14:19:34 +05305def set_print_templates_for_item_table(doc, settings):
Rushabh Mehta0e132212015-02-04 17:02:24 +05306 doc.print_templates = {
prssanna71e5b602020-10-29 14:19:34 +05307 "items": "templates/print_formats/includes/items.html",
Rushabh Mehta0e132212015-02-04 17:02:24 +05308 }
ShashaQin429ab202016-02-09 16:45:51 +08009
prssanna71e5b602020-10-29 14:19:34 +053010 doc.child_print_templates = {
11 "items": {
12 "qty": "templates/print_formats/includes/item_table_qty.html",
Rohit Waghchaure9cf645e2023-06-26 16:00:53 +053013 "serial_and_batch_bundle": "templates/print_formats/includes/serial_and_batch_bundle.html",
prssanna71e5b602020-10-29 14:19:34 +053014 }
15 }
ShashaQin429ab202016-02-09 16:45:51 +080016
prssanna71e5b602020-10-29 14:19:34 +053017 doc.flags.compact_item_fields = ["description", "qty", "rate", "amount"]
18
19 if settings.compact_item_print:
Ankush Menat494bd9e2022-03-28 18:52:46 +053020 doc.child_print_templates["items"][
21 "description"
22 ] = "templates/print_formats/includes/item_table_description.html"
robert schouten67eff492017-01-25 08:20:43 +080023 doc.flags.format_columns = format_columns
shreyas6f8dfa42016-03-07 18:22:40 +053024
Ankush Menat494bd9e2022-03-28 18:52:46 +053025
prssanna71e5b602020-10-29 14:19:34 +053026def set_print_templates_for_taxes(doc, settings):
prssannab57b3c92020-10-22 15:37:47 +053027 doc.flags.show_inclusive_tax_in_print = doc.is_inclusive_tax()
Ankush Menat494bd9e2022-03-28 18:52:46 +053028 doc.print_templates.update(
29 {
30 "total": "templates/print_formats/includes/total.html",
Ankush Menat494bd9e2022-03-28 18:52:46 +053031 }
32 )
33
Anand Baburajan491a50a2023-06-13 19:42:56 +053034 if not doc.should_show_taxes_as_table_in_print():
35 doc.print_templates.update(
36 {
37 "taxes": "templates/print_formats/includes/taxes.html",
38 }
39 )
40
prssanna13c6e2f2020-10-22 17:19:00 +053041
robert schouten67eff492017-01-25 08:20:43 +080042def format_columns(display_columns, compact_fields):
Akhil Narang3effaf22024-03-27 11:37:26 +053043 compact_fields = [*compact_fields, "image", "item_code", "item_name"]
robert schouten67eff492017-01-25 08:20:43 +080044 final_columns = []
45 for column in display_columns:
46 if column not in compact_fields:
47 final_columns.append(column)
48 return final_columns