|
| 1 | +// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors |
| 2 | +// License: GNU General Public License v3. See license.txt |
| 3 | + |
| 4 | +frappe.query_reports["Available Serial No"] = { |
| 5 | + filters: [ |
| 6 | + { |
| 7 | + fieldname: "company", |
| 8 | + label: __("Company"), |
| 9 | + fieldtype: "Link", |
| 10 | + options: "Company", |
| 11 | + default: frappe.defaults.get_user_default("Company"), |
| 12 | + reqd: 1, |
| 13 | + }, |
| 14 | + { |
| 15 | + fieldname: "from_date", |
| 16 | + label: __("From Date"), |
| 17 | + fieldtype: "Date", |
| 18 | + default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), |
| 19 | + reqd: 1, |
| 20 | + }, |
| 21 | + { |
| 22 | + fieldname: "to_date", |
| 23 | + label: __("To Date"), |
| 24 | + fieldtype: "Date", |
| 25 | + default: frappe.datetime.get_today(), |
| 26 | + reqd: 1, |
| 27 | + }, |
| 28 | + { |
| 29 | + fieldname: "warehouse", |
| 30 | + label: __("Warehouse"), |
| 31 | + fieldtype: "Link", |
| 32 | + options: "Warehouse", |
| 33 | + get_query: function () { |
| 34 | + const company = frappe.query_report.get_filter_value("company"); |
| 35 | + return { |
| 36 | + filters: { company: company }, |
| 37 | + }; |
| 38 | + }, |
| 39 | + }, |
| 40 | + { |
| 41 | + fieldname: "item_code", |
| 42 | + label: __("Item"), |
| 43 | + fieldtype: "Link", |
| 44 | + options: "Item", |
| 45 | + get_query: function () { |
| 46 | + return { |
| 47 | + query: "erpnext.controllers.queries.item_query", |
| 48 | + filters: { |
| 49 | + has_serial_no: 1, |
| 50 | + }, |
| 51 | + }; |
| 52 | + }, |
| 53 | + }, |
| 54 | + { |
| 55 | + fieldname: "item_group", |
| 56 | + label: __("Item Group"), |
| 57 | + fieldtype: "Link", |
| 58 | + options: "Item Group", |
| 59 | + }, |
| 60 | + { |
| 61 | + fieldname: "batch_no", |
| 62 | + label: __("Batch No"), |
| 63 | + fieldtype: "Link", |
| 64 | + options: "Batch", |
| 65 | + on_change() { |
| 66 | + const batch_no = frappe.query_report.get_filter_value("batch_no"); |
| 67 | + if (batch_no) { |
| 68 | + frappe.query_report.set_filter_value("segregate_serial_batch_bundle", 1); |
| 69 | + } else { |
| 70 | + frappe.query_report.set_filter_value("segregate_serial_batch_bundle", 0); |
| 71 | + } |
| 72 | + }, |
| 73 | + }, |
| 74 | + { |
| 75 | + fieldname: "brand", |
| 76 | + label: __("Brand"), |
| 77 | + fieldtype: "Link", |
| 78 | + options: "Brand", |
| 79 | + }, |
| 80 | + { |
| 81 | + fieldname: "voucher_no", |
| 82 | + label: __("Voucher #"), |
| 83 | + fieldtype: "Data", |
| 84 | + }, |
| 85 | + { |
| 86 | + fieldname: "project", |
| 87 | + label: __("Project"), |
| 88 | + fieldtype: "Link", |
| 89 | + options: "Project", |
| 90 | + }, |
| 91 | + { |
| 92 | + fieldname: "include_uom", |
| 93 | + label: __("Include UOM"), |
| 94 | + fieldtype: "Link", |
| 95 | + options: "UOM", |
| 96 | + }, |
| 97 | + { |
| 98 | + fieldname: "valuation_field_type", |
| 99 | + label: __("Valuation Field Type"), |
| 100 | + fieldtype: "Select", |
| 101 | + width: "80", |
| 102 | + options: "Currency\nFloat", |
| 103 | + default: "Currency", |
| 104 | + }, |
| 105 | + ], |
| 106 | + formatter: function (value, row, column, data, default_formatter) { |
| 107 | + value = default_formatter(value, row, column, data); |
| 108 | + if (column.fieldname == "out_qty" && data && data.out_qty < 0) { |
| 109 | + value = "<span style='color:red'>" + value + "</span>"; |
| 110 | + } else if (column.fieldname == "in_qty" && data && data.in_qty > 0) { |
| 111 | + value = "<span style='color:green'>" + value + "</span>"; |
| 112 | + } |
| 113 | + |
| 114 | + return value; |
| 115 | + }, |
| 116 | +}; |
| 117 | + |
| 118 | +erpnext.utils.add_inventory_dimensions("Balance Serial No", 10); |
0 commit comments