Anand Doshi | 885e074 | 2015-03-03 14:55:30 +0530 | [diff] [blame] | 1 | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors |
Rushabh Mehta | 0e13221 | 2015-02-04 17:02:24 +0530 | [diff] [blame] | 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 4 | |
prssanna | 71e5b60 | 2020-10-29 14:19:34 +0530 | [diff] [blame] | 5 | def set_print_templates_for_item_table(doc, settings): |
Rushabh Mehta | 0e13221 | 2015-02-04 17:02:24 +0530 | [diff] [blame] | 6 | doc.print_templates = { |
prssanna | 71e5b60 | 2020-10-29 14:19:34 +0530 | [diff] [blame] | 7 | "items": "templates/print_formats/includes/items.html", |
Rushabh Mehta | 0e13221 | 2015-02-04 17:02:24 +0530 | [diff] [blame] | 8 | } |
ShashaQin | 429ab20 | 2016-02-09 16:45:51 +0800 | [diff] [blame] | 9 | |
prssanna | 71e5b60 | 2020-10-29 14:19:34 +0530 | [diff] [blame] | 10 | doc.child_print_templates = { |
| 11 | "items": { |
| 12 | "qty": "templates/print_formats/includes/item_table_qty.html", |
Rohit Waghchaure | 9cf645e | 2023-06-26 16:00:53 +0530 | [diff] [blame] | 13 | "serial_and_batch_bundle": "templates/print_formats/includes/serial_and_batch_bundle.html", |
prssanna | 71e5b60 | 2020-10-29 14:19:34 +0530 | [diff] [blame] | 14 | } |
| 15 | } |
ShashaQin | 429ab20 | 2016-02-09 16:45:51 +0800 | [diff] [blame] | 16 | |
prssanna | 71e5b60 | 2020-10-29 14:19:34 +0530 | [diff] [blame] | 17 | doc.flags.compact_item_fields = ["description", "qty", "rate", "amount"] |
| 18 | |
| 19 | if settings.compact_item_print: |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 20 | doc.child_print_templates["items"][ |
| 21 | "description" |
| 22 | ] = "templates/print_formats/includes/item_table_description.html" |
robert schouten | 67eff49 | 2017-01-25 08:20:43 +0800 | [diff] [blame] | 23 | doc.flags.format_columns = format_columns |
shreyas | 6f8dfa4 | 2016-03-07 18:22:40 +0530 | [diff] [blame] | 24 | |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 25 | |
prssanna | 71e5b60 | 2020-10-29 14:19:34 +0530 | [diff] [blame] | 26 | def set_print_templates_for_taxes(doc, settings): |
prssanna | b57b3c9 | 2020-10-22 15:37:47 +0530 | [diff] [blame] | 27 | doc.flags.show_inclusive_tax_in_print = doc.is_inclusive_tax() |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 28 | doc.print_templates.update( |
| 29 | { |
| 30 | "total": "templates/print_formats/includes/total.html", |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 31 | } |
| 32 | ) |
| 33 | |
Anand Baburajan | 491a50a | 2023-06-13 19:42:56 +0530 | [diff] [blame] | 34 | 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 | |
prssanna | 13c6e2f | 2020-10-22 17:19:00 +0530 | [diff] [blame] | 41 | |
robert schouten | 67eff49 | 2017-01-25 08:20:43 +0800 | [diff] [blame] | 42 | def format_columns(display_columns, compact_fields): |
Akhil Narang | 3effaf2 | 2024-03-27 11:37:26 +0530 | [diff] [blame] | 43 | compact_fields = [*compact_fields, "image", "item_code", "item_name"] |
robert schouten | 67eff49 | 2017-01-25 08:20:43 +0800 | [diff] [blame] | 44 | final_columns = [] |
| 45 | for column in display_columns: |
| 46 | if column not in compact_fields: |
| 47 | final_columns.append(column) |
| 48 | return final_columns |