Rushabh Mehta | ad45e31 | 2013-11-20 12:59:58 +0530 | [diff] [blame] | 1 | // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
Rushabh Mehta | e67d1fb | 2013-08-05 14:59:54 +0530 | [diff] [blame] | 2 | // License: GNU General Public License v3. See license.txt |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 3 | |
| 4 | wn.provide("erpnext"); |
Anand Doshi | a648f46 | 2013-07-30 14:42:15 +0530 | [diff] [blame] | 5 | wn.require("app/js/controllers/stock_controller.js"); |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 6 | |
Anand Doshi | a648f46 | 2013-07-30 14:42:15 +0530 | [diff] [blame] | 7 | erpnext.TransactionController = erpnext.stock.StockController.extend({ |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 8 | onload: function() { |
Anand Doshi | 1e4fb68 | 2013-08-23 12:56:33 +0530 | [diff] [blame] | 9 | var me = this; |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 10 | if(this.frm.doc.__islocal) { |
Anand Doshi | 1e4fb68 | 2013-08-23 12:56:33 +0530 | [diff] [blame] | 11 | var today = get_today(), |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 12 | currency = wn.defaults.get_default("currency"); |
| 13 | |
| 14 | $.each({ |
Anand Doshi | fc77718 | 2013-05-27 19:29:07 +0530 | [diff] [blame] | 15 | posting_date: today, |
| 16 | due_date: today, |
| 17 | transaction_date: today, |
| 18 | currency: currency, |
| 19 | price_list_currency: currency, |
| 20 | status: "Draft", |
| 21 | company: wn.defaults.get_default("company"), |
| 22 | fiscal_year: wn.defaults.get_default("fiscal_year"), |
| 23 | is_subcontracted: "No", |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 24 | }, function(fieldname, value) { |
| 25 | if(me.frm.fields_dict[fieldname] && !me.frm.doc[fieldname]) |
| 26 | me.frm.set_value(fieldname, value); |
Akhilesh Darjee | 61b5c59 | 2013-10-15 20:24:34 +0530 | [diff] [blame] | 27 | }); |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 28 | } |
Akhilesh Darjee | 564c621 | 2013-10-17 11:31:11 +0530 | [diff] [blame] | 29 | |
Anand Doshi | 1e4fb68 | 2013-08-23 12:56:33 +0530 | [diff] [blame] | 30 | if(this.other_fname) { |
Anand Doshi | a91c95f | 2013-08-23 13:00:47 +0530 | [diff] [blame] | 31 | this[this.other_fname + "_remove"] = this.calculate_taxes_and_totals; |
| 32 | } |
| 33 | |
| 34 | if(this.fname) { |
| 35 | this[this.fname + "_remove"] = this.calculate_taxes_and_totals; |
Anand Doshi | 1e4fb68 | 2013-08-23 12:56:33 +0530 | [diff] [blame] | 36 | } |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 37 | }, |
| 38 | |
Anand Doshi | 5e4e5d7 | 2013-08-06 17:23:44 +0530 | [diff] [blame] | 39 | onload_post_render: function() { |
Akhilesh Darjee | 61b5c59 | 2013-10-15 20:24:34 +0530 | [diff] [blame] | 40 | var me = this; |
| 41 | if(this.frm.doc.__islocal && this.frm.doc.company && !this.frm.doc.is_pos) { |
Akhilesh Darjee | 04638a5 | 2013-10-17 13:19:46 +0530 | [diff] [blame] | 42 | if(!this.frm.doc.customer || !this.frm.doc.supplier) { |
Akhilesh Darjee | 7837827 | 2013-10-11 19:06:30 +0530 | [diff] [blame] | 43 | return this.frm.call({ |
| 44 | doc: this.frm.doc, |
| 45 | method: "onload_post_render", |
| 46 | freeze: true, |
| 47 | callback: function(r) { |
| 48 | // remove this call when using client side mapper |
| 49 | me.set_default_values(); |
| 50 | me.set_dynamic_labels(); |
Akhilesh Darjee | acf65a7 | 2013-10-17 13:04:26 +0530 | [diff] [blame] | 51 | me.calculate_taxes_and_totals(); |
Akhilesh Darjee | 7837827 | 2013-10-11 19:06:30 +0530 | [diff] [blame] | 52 | } |
| 53 | }); |
Akhilesh Darjee | 61b5c59 | 2013-10-15 20:24:34 +0530 | [diff] [blame] | 54 | } else { |
| 55 | this.calculate_taxes_and_totals(); |
| 56 | } |
Anand Doshi | 5e4e5d7 | 2013-08-06 17:23:44 +0530 | [diff] [blame] | 57 | } |
| 58 | }, |
| 59 | |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 60 | refresh: function() { |
| 61 | this.frm.clear_custom_buttons(); |
| 62 | erpnext.hide_naming_series(); |
Anand Doshi | bdee6e0 | 2013-07-09 13:03:39 +0530 | [diff] [blame] | 63 | erpnext.hide_company(); |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 64 | this.show_item_wise_taxes(); |
Nabin Hait | 1f996c3 | 2013-07-29 19:00:53 +0530 | [diff] [blame] | 65 | this.set_dynamic_labels(); |
Akhilesh Darjee | 6773bc2 | 2013-09-17 11:56:17 +0530 | [diff] [blame] | 66 | |
| 67 | // Show POS button only if it is enabled from features setup |
| 68 | if(cint(sys_defaults.fs_pos_view)===1 && this.frm.doctype!="Material Request") |
Rushabh Mehta | e34090a | 2013-11-15 11:30:23 +0530 | [diff] [blame] | 69 | this.make_pos_btn(); |
Akhilesh Darjee | 6773bc2 | 2013-09-17 11:56:17 +0530 | [diff] [blame] | 70 | }, |
| 71 | |
Rushabh Mehta | e34090a | 2013-11-15 11:30:23 +0530 | [diff] [blame] | 72 | make_pos_btn: function() { |
Akhilesh Darjee | 6773bc2 | 2013-09-17 11:56:17 +0530 | [diff] [blame] | 73 | if(!this.pos_active) { |
| 74 | var btn_label = wn._("POS View"), |
| 75 | icon = "icon-desktop"; |
| 76 | } else { |
| 77 | var btn_label = wn._(this.frm.doctype) + wn._(" View"), |
| 78 | icon = "icon-file-text"; |
Akhilesh Darjee | 6773bc2 | 2013-09-17 11:56:17 +0530 | [diff] [blame] | 79 | } |
| 80 | var me = this; |
Rushabh Mehta | e34090a | 2013-11-15 11:30:23 +0530 | [diff] [blame] | 81 | |
| 82 | this.$pos_btn = this.frm.appframe.add_button(btn_label, function() { |
Akhilesh Darjee | 6773bc2 | 2013-09-17 11:56:17 +0530 | [diff] [blame] | 83 | me.toggle_pos(); |
Akhilesh Darjee | 6773bc2 | 2013-09-17 11:56:17 +0530 | [diff] [blame] | 84 | }, icon); |
| 85 | }, |
| 86 | |
| 87 | toggle_pos: function(show) { |
Akhilesh Darjee | f83576b | 2013-09-18 18:35:12 +0530 | [diff] [blame] | 88 | // Check whether it is Selling or Buying cycle |
| 89 | var price_list = wn.meta.has_field(cur_frm.doc.doctype, "selling_price_list") ? |
| 90 | this.frm.doc.selling_price_list : this.frm.doc.buying_price_list; |
| 91 | |
| 92 | if (!price_list) |
Akhilesh Darjee | 6773bc2 | 2013-09-17 11:56:17 +0530 | [diff] [blame] | 93 | msgprint(wn._("Please select Price List")) |
| 94 | else { |
| 95 | if((show===true && this.pos_active) || (show===false && !this.pos_active)) return; |
| 96 | |
| 97 | // make pos |
Akhilesh Darjee | f624ffa | 2013-09-23 12:27:16 +0530 | [diff] [blame] | 98 | if(!this.frm.pos) { |
Akhilesh Darjee | 6773bc2 | 2013-09-17 11:56:17 +0530 | [diff] [blame] | 99 | this.frm.layout.add_view("pos"); |
| 100 | this.frm.pos = new erpnext.POS(this.frm.layout.views.pos, this.frm); |
| 101 | } |
| 102 | |
| 103 | // toggle view |
| 104 | this.frm.layout.set_view(this.pos_active ? "" : "pos"); |
| 105 | this.pos_active = !this.pos_active; |
| 106 | |
| 107 | // refresh |
| 108 | if(this.pos_active) |
| 109 | this.frm.pos.refresh(); |
Akhilesh Darjee | f83576b | 2013-09-18 18:35:12 +0530 | [diff] [blame] | 110 | this.frm.refresh(); |
Akhilesh Darjee | 6773bc2 | 2013-09-17 11:56:17 +0530 | [diff] [blame] | 111 | } |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 112 | }, |
Akhilesh Darjee | fcd70d0 | 2013-10-18 14:24:21 +0530 | [diff] [blame] | 113 | |
| 114 | serial_no: function(doc, cdt, cdn) { |
| 115 | var me = this; |
| 116 | var item = wn.model.get_doc(cdt, cdn); |
| 117 | |
| 118 | if (item.serial_no) { |
| 119 | if (!item.item_code) { |
| 120 | this.frm.script_manager.trigger("item_code", cdt, cdn); |
| 121 | } |
| 122 | else { |
| 123 | var sr_no = []; |
| 124 | |
| 125 | // Replacing all occurences of comma with carriage return |
| 126 | var serial_nos = item.serial_no.trim().replace(/,/g, '\n'); |
| 127 | |
| 128 | serial_nos = serial_nos.trim().split('\n'); |
| 129 | |
| 130 | // Trim each string and push unique string to new list |
| 131 | for (var x=0; x<=serial_nos.length - 1; x++) { |
| 132 | if (serial_nos[x].trim() != "" && sr_no.indexOf(serial_nos[x].trim()) == -1) { |
| 133 | sr_no.push(serial_nos[x].trim()); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | // Add the new list to the serial no. field in grid with each in new line |
| 138 | item.serial_no = ""; |
| 139 | for (var x=0; x<=sr_no.length - 1; x++) |
| 140 | item.serial_no += sr_no[x] + '\n'; |
| 141 | |
| 142 | refresh_field("serial_no", item.name, item.parentfield); |
| 143 | wn.model.set_value(item.doctype, item.name, "qty", sr_no.length); |
| 144 | } |
| 145 | } |
| 146 | }, |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 147 | |
Anand Doshi | 923d41d | 2013-05-28 17:23:36 +0530 | [diff] [blame] | 148 | validate: function() { |
| 149 | this.calculate_taxes_and_totals(); |
| 150 | }, |
| 151 | |
Anand Doshi | 5e4e5d7 | 2013-08-06 17:23:44 +0530 | [diff] [blame] | 152 | set_default_values: function() { |
| 153 | $.each(wn.model.get_doclist(this.frm.doctype, this.frm.docname), function(i, doc) { |
| 154 | var updated = wn.model.set_default_values(doc); |
| 155 | if(doc.parentfield) { |
| 156 | refresh_field(doc.parentfield); |
| 157 | } else { |
| 158 | refresh_field(updated); |
| 159 | } |
| 160 | }); |
| 161 | }, |
| 162 | |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 163 | company: function() { |
Anand Doshi | d52b03a | 2013-06-21 12:22:52 +0530 | [diff] [blame] | 164 | if(this.frm.doc.company && this.frm.fields_dict.currency) { |
Akhilesh Darjee | 1797cfe | 2013-10-11 13:34:10 +0530 | [diff] [blame] | 165 | var company_currency = this.get_company_currency(); |
Akhilesh Darjee | 7837827 | 2013-10-11 19:06:30 +0530 | [diff] [blame] | 166 | if (!this.frm.doc.currency) { |
Akhilesh Darjee | 1797cfe | 2013-10-11 13:34:10 +0530 | [diff] [blame] | 167 | this.frm.set_value("currency", company_currency); |
Anand Doshi | 17350b8 | 2013-08-01 15:45:23 +0530 | [diff] [blame] | 168 | } |
| 169 | |
Akhilesh Darjee | 7837827 | 2013-10-11 19:06:30 +0530 | [diff] [blame] | 170 | if (this.frm.doc.currency == company_currency) { |
Akhilesh Darjee | 1797cfe | 2013-10-11 13:34:10 +0530 | [diff] [blame] | 171 | this.frm.set_value("conversion_rate", 1.0); |
Akhilesh Darjee | 7837827 | 2013-10-11 19:06:30 +0530 | [diff] [blame] | 172 | } |
| 173 | if (this.frm.doc.price_list_currency == company_currency) { |
Akhilesh Darjee | 1797cfe | 2013-10-11 13:34:10 +0530 | [diff] [blame] | 174 | this.frm.set_value('plc_conversion_rate', 1.0); |
Akhilesh Darjee | 7837827 | 2013-10-11 19:06:30 +0530 | [diff] [blame] | 175 | } |
Akhilesh Darjee | 1797cfe | 2013-10-11 13:34:10 +0530 | [diff] [blame] | 176 | |
Nabin Hait | 48a0bd3 | 2013-07-23 15:31:39 +0530 | [diff] [blame] | 177 | this.frm.script_manager.trigger("currency"); |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 178 | } |
| 179 | }, |
| 180 | |
| 181 | get_company_currency: function() { |
| 182 | return erpnext.get_currency(this.frm.doc.company); |
| 183 | }, |
| 184 | |
| 185 | currency: function() { |
Anand Doshi | 61a2f68 | 2013-06-21 17:55:31 +0530 | [diff] [blame] | 186 | var me = this; |
| 187 | this.set_dynamic_labels(); |
Akhilesh Darjee | 7837827 | 2013-10-11 19:06:30 +0530 | [diff] [blame] | 188 | |
Anand Doshi | 61a2f68 | 2013-06-21 17:55:31 +0530 | [diff] [blame] | 189 | var company_currency = this.get_company_currency(); |
| 190 | if(this.frm.doc.currency !== company_currency) { |
| 191 | this.get_exchange_rate(this.frm.doc.currency, company_currency, |
| 192 | function(exchange_rate) { |
Akhilesh Darjee | 7837827 | 2013-10-11 19:06:30 +0530 | [diff] [blame] | 193 | me.frm.set_value("conversion_rate", exchange_rate); |
| 194 | me.conversion_rate(); |
Anand Doshi | 61a2f68 | 2013-06-21 17:55:31 +0530 | [diff] [blame] | 195 | }); |
| 196 | } else { |
| 197 | this.conversion_rate(); |
| 198 | } |
| 199 | }, |
| 200 | |
| 201 | conversion_rate: function() { |
Anand Doshi | 535d833 | 2013-07-19 13:51:07 +0530 | [diff] [blame] | 202 | if(this.frm.doc.currency === this.get_company_currency()) { |
| 203 | this.frm.set_value("conversion_rate", 1.0); |
Akhilesh Darjee | acf65a7 | 2013-10-17 13:04:26 +0530 | [diff] [blame] | 204 | } |
| 205 | if(this.frm.doc.currency === this.frm.doc.price_list_currency && |
Anand Doshi | 61a2f68 | 2013-06-21 17:55:31 +0530 | [diff] [blame] | 206 | this.frm.doc.plc_conversion_rate !== this.frm.doc.conversion_rate) { |
| 207 | this.frm.set_value("plc_conversion_rate", this.frm.doc.conversion_rate); |
| 208 | } |
Nabin Hait | b338b6e | 2013-10-15 16:55:24 +0530 | [diff] [blame] | 209 | if(flt(this.frm.doc.conversion_rate)>0.0) this.calculate_taxes_and_totals(); |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 210 | }, |
| 211 | |
Rushabh Mehta | 4a404e9 | 2013-08-09 18:11:35 +0530 | [diff] [blame] | 212 | get_price_list_currency: function(buying_or_selling) { |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 213 | var me = this; |
Rushabh Mehta | 4a404e9 | 2013-08-09 18:11:35 +0530 | [diff] [blame] | 214 | var fieldname = buying_or_selling.toLowerCase() + "_price_list"; |
| 215 | if(this.frm.doc[fieldname]) { |
Anand Doshi | 1fac2a9 | 2013-07-29 19:30:39 +0530 | [diff] [blame] | 216 | return this.frm.call({ |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 217 | method: "setup.utils.get_price_list_currency", |
Nabin Hait | 48a0bd3 | 2013-07-23 15:31:39 +0530 | [diff] [blame] | 218 | args: { |
Rushabh Mehta | 4a404e9 | 2013-08-09 18:11:35 +0530 | [diff] [blame] | 219 | price_list: this.frm.doc[fieldname], |
Nabin Hait | 48a0bd3 | 2013-07-23 15:31:39 +0530 | [diff] [blame] | 220 | }, |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 221 | callback: function(r) { |
| 222 | if(!r.exc) { |
| 223 | me.price_list_currency(); |
| 224 | } |
| 225 | } |
| 226 | }); |
| 227 | } |
| 228 | }, |
| 229 | |
Anand Doshi | 61a2f68 | 2013-06-21 17:55:31 +0530 | [diff] [blame] | 230 | get_exchange_rate: function(from_currency, to_currency, callback) { |
| 231 | var exchange_name = from_currency + "-" + to_currency; |
| 232 | wn.model.with_doc("Currency Exchange", exchange_name, function(name) { |
| 233 | var exchange_doc = wn.model.get_doc("Currency Exchange", exchange_name); |
Nabin Hait | 13f2e4d | 2013-06-25 10:56:39 +0530 | [diff] [blame] | 234 | callback(exchange_doc ? flt(exchange_doc.exchange_rate) : 0); |
Anand Doshi | 61a2f68 | 2013-06-21 17:55:31 +0530 | [diff] [blame] | 235 | }); |
| 236 | }, |
| 237 | |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 238 | price_list_currency: function() { |
Akhilesh Darjee | db59ffb | 2013-09-11 13:05:24 +0530 | [diff] [blame] | 239 | var me=this; |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 240 | this.set_dynamic_labels(); |
Anand Doshi | 61a2f68 | 2013-06-21 17:55:31 +0530 | [diff] [blame] | 241 | |
| 242 | var company_currency = this.get_company_currency(); |
| 243 | if(this.frm.doc.price_list_currency !== company_currency) { |
| 244 | this.get_exchange_rate(this.frm.doc.price_list_currency, company_currency, |
| 245 | function(exchange_rate) { |
| 246 | if(exchange_rate) { |
Akhilesh Darjee | db59ffb | 2013-09-11 13:05:24 +0530 | [diff] [blame] | 247 | me.frm.set_value("plc_conversion_rate", exchange_rate); |
Anand Doshi | 61a2f68 | 2013-06-21 17:55:31 +0530 | [diff] [blame] | 248 | me.plc_conversion_rate(); |
| 249 | } |
| 250 | }); |
| 251 | } else { |
| 252 | this.plc_conversion_rate(); |
| 253 | } |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 254 | }, |
| 255 | |
| 256 | plc_conversion_rate: function() { |
Anand Doshi | 61a2f68 | 2013-06-21 17:55:31 +0530 | [diff] [blame] | 257 | if(this.frm.doc.price_list_currency === this.get_company_currency()) { |
| 258 | this.frm.set_value("plc_conversion_rate", 1.0); |
Akhilesh Darjee | 564c621 | 2013-10-17 11:31:11 +0530 | [diff] [blame] | 259 | } |
| 260 | if(this.frm.doc.price_list_currency === this.frm.doc.currency) { |
Anand Doshi | 61a2f68 | 2013-06-21 17:55:31 +0530 | [diff] [blame] | 261 | this.frm.set_value("conversion_rate", this.frm.doc.plc_conversion_rate); |
| 262 | this.calculate_taxes_and_totals(); |
| 263 | } |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 264 | }, |
| 265 | |
| 266 | qty: function(doc, cdt, cdn) { |
| 267 | this.calculate_taxes_and_totals(); |
| 268 | }, |
| 269 | |
Anand Doshi | 923d41d | 2013-05-28 17:23:36 +0530 | [diff] [blame] | 270 | tax_rate: function(doc, cdt, cdn) { |
| 271 | this.calculate_taxes_and_totals(); |
| 272 | }, |
Akhilesh Darjee | 10dce34 | 2013-09-25 11:09:33 +0530 | [diff] [blame] | 273 | |
Anand Doshi | 923d41d | 2013-05-28 17:23:36 +0530 | [diff] [blame] | 274 | row_id: function(doc, cdt, cdn) { |
| 275 | var tax = wn.model.get_doc(cdt, cdn); |
| 276 | try { |
| 277 | this.validate_on_previous_row(tax); |
| 278 | this.calculate_taxes_and_totals(); |
| 279 | } catch(e) { |
| 280 | tax.row_id = null; |
| 281 | refresh_field("row_id", tax.name, tax.parentfield); |
| 282 | throw e; |
| 283 | } |
| 284 | }, |
| 285 | |
Anand Doshi | 61a2f68 | 2013-06-21 17:55:31 +0530 | [diff] [blame] | 286 | set_dynamic_labels: function() { |
| 287 | // What TODO? should we make price list system non-mandatory? |
| 288 | this.frm.toggle_reqd("plc_conversion_rate", |
| 289 | !!(this.frm.doc.price_list_name && this.frm.doc.price_list_currency)); |
| 290 | |
| 291 | var company_currency = this.get_company_currency(); |
| 292 | this.change_form_labels(company_currency); |
| 293 | this.change_grid_labels(company_currency); |
Anand Doshi | 5013dcb | 2013-08-05 12:16:04 +0530 | [diff] [blame] | 294 | this.frm.refresh_fields(); |
Anand Doshi | 61a2f68 | 2013-06-21 17:55:31 +0530 | [diff] [blame] | 295 | }, |
| 296 | |
Anand Doshi | 923d41d | 2013-05-28 17:23:36 +0530 | [diff] [blame] | 297 | recalculate: function() { |
| 298 | this.calculate_taxes_and_totals(); |
| 299 | }, |
| 300 | |
| 301 | recalculate_values: function() { |
| 302 | this.calculate_taxes_and_totals(); |
| 303 | }, |
| 304 | |
Anand Doshi | d0b0072 | 2013-05-28 18:54:48 +0530 | [diff] [blame] | 305 | calculate_charges: function() { |
| 306 | this.calculate_taxes_and_totals(); |
| 307 | }, |
| 308 | |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 309 | included_in_print_rate: function(doc, cdt, cdn) { |
| 310 | var tax = wn.model.get_doc(cdt, cdn); |
| 311 | try { |
| 312 | this.validate_on_previous_row(tax); |
| 313 | this.validate_inclusive_tax(tax); |
| 314 | this.calculate_taxes_and_totals(); |
| 315 | } catch(e) { |
| 316 | tax.included_in_print_rate = 0; |
| 317 | refresh_field("included_in_print_rate", tax.name, tax.parentfield); |
| 318 | throw e; |
| 319 | } |
| 320 | }, |
| 321 | |
| 322 | validate_on_previous_row: function(tax) { |
| 323 | // validate if a valid row id is mentioned in case of |
| 324 | // On Previous Row Amount and On Previous Row Total |
Bárbara Perretti | 534af0b | 2013-10-08 15:00:07 -0300 | [diff] [blame] | 325 | if(([wn._("On Previous Row Amount"), wn._("On Previous Row Total")].indexOf(tax.charge_type) != -1) && |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 326 | (!tax.row_id || cint(tax.row_id) >= tax.idx)) { |
| 327 | var msg = repl(wn._("Row") + " # %(idx)s [%(doctype)s]: " + |
| 328 | wn._("Please specify a valid") + " %(row_id_label)s", { |
| 329 | idx: tax.idx, |
| 330 | doctype: tax.doctype, |
| 331 | row_id_label: wn.meta.get_label(tax.doctype, "row_id", tax.name) |
| 332 | }); |
| 333 | msgprint(msg); |
| 334 | throw msg; |
| 335 | } |
| 336 | }, |
| 337 | |
| 338 | validate_inclusive_tax: function(tax) { |
| 339 | if(!this.frm.tax_doclist) this.frm.tax_doclist = this.get_tax_doclist(); |
| 340 | |
| 341 | var actual_type_error = function() { |
| 342 | var msg = repl(wn._("For row") + " # %(idx)s [%(doctype)s]: " + |
| 343 | "%(charge_type_label)s = \"%(charge_type)s\" " + |
| 344 | wn._("cannot be included in Item's rate"), { |
| 345 | idx: tax.idx, |
| 346 | doctype: tax.doctype, |
| 347 | charge_type_label: wn.meta.get_label(tax.doctype, "charge_type", tax.name), |
| 348 | charge_type: tax.charge_type |
| 349 | }); |
| 350 | msgprint(msg); |
| 351 | throw msg; |
| 352 | }; |
| 353 | |
| 354 | var on_previous_row_error = function(row_range) { |
| 355 | var msg = repl(wn._("For row") + " # %(idx)s [%(doctype)s]: " + |
| 356 | wn._("to be included in Item's rate, it is required that: ") + |
| 357 | " [" + wn._("Row") + " # %(row_range)s] " + wn._("also be included in Item's rate"), { |
| 358 | idx: tax.idx, |
| 359 | doctype: tax.doctype, |
| 360 | charge_type_label: wn.meta.get_label(tax.doctype, "charge_type", tax.name), |
| 361 | charge_type: tax.charge_type, |
| 362 | inclusive_label: wn.meta.get_label(tax.doctype, "included_in_print_rate", tax.name), |
| 363 | row_range: row_range, |
| 364 | }); |
| 365 | |
| 366 | msgprint(msg); |
| 367 | throw msg; |
| 368 | }; |
| 369 | |
| 370 | if(cint(tax.included_in_print_rate)) { |
| 371 | if(tax.charge_type == "Actual") { |
| 372 | // inclusive tax cannot be of type Actual |
| 373 | actual_type_error(); |
| 374 | } else if(tax.charge_type == "On Previous Row Amount" && |
| 375 | !cint(this.frm.tax_doclist[tax.row_id - 1].included_in_print_rate)) { |
| 376 | // referred row should also be an inclusive tax |
| 377 | on_previous_row_error(tax.row_id); |
| 378 | } else if(tax.charge_type == "On Previous Row Total") { |
| 379 | var taxes_not_included = $.map(this.frm.tax_doclist.slice(0, tax.row_id), |
| 380 | function(t) { return cint(t.included_in_print_rate) ? null : t; }); |
| 381 | if(taxes_not_included.length > 0) { |
| 382 | // all rows above this tax should be inclusive |
| 383 | on_previous_row_error(tax.row_id == 1 ? "1" : "1 - " + tax.row_id); |
| 384 | } |
| 385 | } |
| 386 | } |
| 387 | }, |
| 388 | |
| 389 | _load_item_tax_rate: function(item_tax_rate) { |
| 390 | return item_tax_rate ? JSON.parse(item_tax_rate) : {}; |
| 391 | }, |
| 392 | |
| 393 | _get_tax_rate: function(tax, item_tax_map) { |
| 394 | return (keys(item_tax_map).indexOf(tax.account_head) != -1) ? |
| 395 | flt(item_tax_map[tax.account_head], precision("rate", tax)) : |
| 396 | tax.rate; |
| 397 | }, |
| 398 | |
| 399 | get_item_wise_taxes_html: function() { |
| 400 | var item_tax = {}; |
| 401 | var tax_accounts = []; |
| 402 | var company_currency = this.get_company_currency(); |
| 403 | |
| 404 | $.each(this.get_tax_doclist(), function(i, tax) { |
| 405 | var tax_amount_precision = precision("tax_amount", tax); |
Anand Doshi | 53b7342 | 2013-05-31 11:50:01 +0530 | [diff] [blame] | 406 | var tax_rate_precision = precision("rate", tax); |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 407 | $.each(JSON.parse(tax.item_wise_tax_detail || '{}'), |
Anand Doshi | 53b7342 | 2013-05-31 11:50:01 +0530 | [diff] [blame] | 408 | function(item_code, tax_data) { |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 409 | if(!item_tax[item_code]) item_tax[item_code] = {}; |
Anand Doshi | 53b7342 | 2013-05-31 11:50:01 +0530 | [diff] [blame] | 410 | if($.isArray(tax_data)) { |
Anand Doshi | 1e4fb68 | 2013-08-23 12:56:33 +0530 | [diff] [blame] | 411 | var tax_rate = ""; |
| 412 | if(tax_data[0] != null) { |
| 413 | tax_rate = (tax.charge_type === "Actual") ? |
| 414 | format_currency(flt(tax_data[0], tax_amount_precision), company_currency, tax_amount_precision) : |
| 415 | (flt(tax_data[0], tax_rate_precision) + "%"); |
| 416 | } |
| 417 | var tax_amount = format_currency(flt(tax_data[1], tax_amount_precision), company_currency, |
| 418 | tax_amount_precision); |
Anand Doshi | 53b7342 | 2013-05-31 11:50:01 +0530 | [diff] [blame] | 419 | |
Anand Doshi | aa71b5b | 2013-08-05 13:00:53 +0530 | [diff] [blame] | 420 | item_tax[item_code][tax.name] = [tax_rate, tax_amount]; |
Anand Doshi | 53b7342 | 2013-05-31 11:50:01 +0530 | [diff] [blame] | 421 | } else { |
Anand Doshi | aa71b5b | 2013-08-05 13:00:53 +0530 | [diff] [blame] | 422 | item_tax[item_code][tax.name] = [flt(tax_data, tax_rate_precision) + "%", ""]; |
Anand Doshi | 53b7342 | 2013-05-31 11:50:01 +0530 | [diff] [blame] | 423 | } |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 424 | }); |
Anand Doshi | aa71b5b | 2013-08-05 13:00:53 +0530 | [diff] [blame] | 425 | tax_accounts.push([tax.name, tax.account_head]); |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 426 | }); |
| 427 | |
Anand Doshi | aa71b5b | 2013-08-05 13:00:53 +0530 | [diff] [blame] | 428 | var headings = $.map([wn._("Item Name")].concat($.map(tax_accounts, function(head) { return head[1]; })), |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 429 | function(head) { return '<th style="min-width: 100px;">' + (head || "") + "</th>" }).join("\n"); |
Anand Doshi | 179e377 | 2013-09-05 16:53:57 +0530 | [diff] [blame] | 430 | |
| 431 | var distinct_item_names = []; |
| 432 | var distinct_items = []; |
| 433 | $.each(this.get_item_doclist(), function(i, item) { |
| 434 | if(distinct_item_names.indexOf(item.item_code || item.item_name)===-1) { |
| 435 | distinct_item_names.push(item.item_code || item.item_name); |
| 436 | distinct_items.push(item); |
| 437 | } |
| 438 | }); |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 439 | |
Anand Doshi | 179e377 | 2013-09-05 16:53:57 +0530 | [diff] [blame] | 440 | var rows = $.map(distinct_items, function(item) { |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 441 | var item_tax_record = item_tax[item.item_code || item.item_name]; |
Anand Doshi | 53b7342 | 2013-05-31 11:50:01 +0530 | [diff] [blame] | 442 | if(!item_tax_record) { return null; } |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 443 | return repl("<tr><td>%(item_name)s</td>%(taxes)s</tr>", { |
| 444 | item_name: item.item_name, |
| 445 | taxes: $.map(tax_accounts, function(head) { |
Anand Doshi | aa71b5b | 2013-08-05 13:00:53 +0530 | [diff] [blame] | 446 | return item_tax_record[head[0]] ? |
| 447 | "<td>(" + item_tax_record[head[0]][0] + ") " + item_tax_record[head[0]][1] + "</td>" : |
Anand Doshi | 64f316b | 2013-07-17 15:12:22 +0530 | [diff] [blame] | 448 | "<td></td>"; |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 449 | }).join("\n") |
| 450 | }); |
| 451 | }).join("\n"); |
| 452 | |
Anand Doshi | 53b7342 | 2013-05-31 11:50:01 +0530 | [diff] [blame] | 453 | if(!rows) return ""; |
Rushabh Mehta | 7d8b189 | 2013-11-08 16:27:18 +0530 | [diff] [blame] | 454 | return '<p><a href="#" onclick="$(\'.tax-break-up\').toggleClass(\'hide\'); return false;">Show / Hide tax break-up</a><br><br></p>\ |
| 455 | <div class="tax-break-up hide" style="overflow-x: auto;"><table class="table table-bordered table-hover">\ |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 456 | <thead><tr>' + headings + '</tr></thead> \ |
| 457 | <tbody>' + rows + '</tbody> \ |
| 458 | </table></div>'; |
| 459 | }, |
| 460 | |
Anand Doshi | 923d41d | 2013-05-28 17:23:36 +0530 | [diff] [blame] | 461 | _validate_before_fetch: function(fieldname) { |
| 462 | var me = this; |
| 463 | if(!me.frm.doc[fieldname]) { |
| 464 | return (wn._("Please specify") + ": " + |
| 465 | wn.meta.get_label(me.frm.doc.doctype, fieldname, me.frm.doc.name) + |
| 466 | ". " + wn._("It is needed to fetch Item Details.")); |
| 467 | } |
| 468 | return null; |
| 469 | }, |
| 470 | |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 471 | validate_company_and_party: function(party_field) { |
Anand Doshi | 923d41d | 2013-05-28 17:23:36 +0530 | [diff] [blame] | 472 | var me = this; |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 473 | var valid = true; |
Anand Doshi | 923d41d | 2013-05-28 17:23:36 +0530 | [diff] [blame] | 474 | var msg = ""; |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 475 | $.each(["company", party_field], function(i, fieldname) { |
Anand Doshi | 923d41d | 2013-05-28 17:23:36 +0530 | [diff] [blame] | 476 | var msg_for_fieldname = me._validate_before_fetch(fieldname); |
| 477 | if(msg_for_fieldname) { |
| 478 | msgprint(msg_for_fieldname); |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 479 | valid = false; |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 480 | } |
| 481 | }); |
| 482 | return valid; |
| 483 | }, |
| 484 | |
| 485 | get_item_doclist: function() { |
| 486 | return wn.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, |
| 487 | {parentfield: this.fname}); |
| 488 | }, |
| 489 | |
| 490 | get_tax_doclist: function() { |
| 491 | return wn.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, |
| 492 | {parentfield: this.other_fname}); |
| 493 | }, |
| 494 | |
| 495 | validate_conversion_rate: function() { |
| 496 | this.frm.doc.conversion_rate = flt(this.frm.doc.conversion_rate, precision("conversion_rate")); |
| 497 | var conversion_rate_label = wn.meta.get_label(this.frm.doc.doctype, "conversion_rate", |
| 498 | this.frm.doc.name); |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 499 | var company_currency = this.get_company_currency(); |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 500 | |
Akhilesh Darjee | 1797cfe | 2013-10-11 13:34:10 +0530 | [diff] [blame] | 501 | if(!this.frm.doc.conversion_rate) { |
Nabin Hait | e505fbe | 2013-11-15 13:38:23 +0530 | [diff] [blame] | 502 | wn.throw(repl('%(conversion_rate_label)s' + |
| 503 | wn._(' is mandatory. Maybe Currency Exchange record is not created for ') + |
| 504 | '%(from_currency)s' + wn._(" to ") + '%(to_currency)s', |
Akhilesh Darjee | e0b3282 | 2013-11-12 19:27:16 +0530 | [diff] [blame] | 505 | { |
| 506 | "conversion_rate_label": conversion_rate_label, |
Nabin Hait | e505fbe | 2013-11-15 13:38:23 +0530 | [diff] [blame] | 507 | "from_currency": this.frm.doc.currency, |
Akhilesh Darjee | e0b3282 | 2013-11-12 19:27:16 +0530 | [diff] [blame] | 508 | "to_currency": company_currency |
Nabin Hait | e505fbe | 2013-11-15 13:38:23 +0530 | [diff] [blame] | 509 | })); |
Akhilesh Darjee | 6773bc2 | 2013-09-17 11:56:17 +0530 | [diff] [blame] | 510 | } |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 511 | }, |
| 512 | |
| 513 | calculate_taxes_and_totals: function() { |
| 514 | this.validate_conversion_rate(); |
| 515 | this.frm.item_doclist = this.get_item_doclist(); |
| 516 | this.frm.tax_doclist = this.get_tax_doclist(); |
| 517 | |
| 518 | this.calculate_item_values(); |
| 519 | this.initialize_taxes(); |
| 520 | this.determine_exclusive_rate && this.determine_exclusive_rate(); |
| 521 | this.calculate_net_total(); |
| 522 | this.calculate_taxes(); |
| 523 | this.calculate_totals(); |
| 524 | this._cleanup(); |
Anand Doshi | 923d41d | 2013-05-28 17:23:36 +0530 | [diff] [blame] | 525 | |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 526 | this.show_item_wise_taxes(); |
| 527 | }, |
| 528 | |
| 529 | initialize_taxes: function() { |
| 530 | var me = this; |
| 531 | $.each(this.frm.tax_doclist, function(i, tax) { |
| 532 | tax.item_wise_tax_detail = {}; |
| 533 | $.each(["tax_amount", "total", |
| 534 | "tax_amount_for_current_item", "grand_total_for_current_item", |
| 535 | "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"], |
| 536 | function(i, fieldname) { tax[fieldname] = 0.0 }); |
| 537 | |
| 538 | me.validate_on_previous_row(tax); |
| 539 | me.validate_inclusive_tax(tax); |
| 540 | wn.model.round_floats_in(tax); |
| 541 | }); |
| 542 | }, |
| 543 | |
| 544 | calculate_taxes: function() { |
| 545 | var me = this; |
| 546 | |
| 547 | $.each(this.frm.item_doclist, function(n, item) { |
| 548 | var item_tax_map = me._load_item_tax_rate(item.item_tax_rate); |
| 549 | |
| 550 | $.each(me.frm.tax_doclist, function(i, tax) { |
| 551 | // tax_amount represents the amount of tax for the current step |
| 552 | var current_tax_amount = me.get_current_tax_amount(item, tax, item_tax_map); |
Anand Doshi | 53b7342 | 2013-05-31 11:50:01 +0530 | [diff] [blame] | 553 | |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 554 | me.set_item_tax_amount && me.set_item_tax_amount(item, tax, current_tax_amount); |
| 555 | |
| 556 | // case when net total is 0 but there is an actual type charge |
| 557 | // in this case add the actual amount to tax.tax_amount |
| 558 | // and tax.grand_total_for_current_item for the first such iteration |
| 559 | if(tax.charge_type == "Actual" && |
| 560 | !(current_tax_amount || me.frm.doc.net_total || tax.tax_amount)) { |
| 561 | var zero_net_total_adjustment = flt(tax.rate, precision("tax_amount", tax)); |
| 562 | current_tax_amount += zero_net_total_adjustment; |
| 563 | } |
| 564 | |
| 565 | // store tax_amount for current item as it will be used for |
| 566 | // charge type = 'On Previous Row Amount' |
| 567 | tax.tax_amount_for_current_item = current_tax_amount; |
| 568 | |
| 569 | // accumulate tax amount into tax.tax_amount |
| 570 | tax.tax_amount += current_tax_amount; |
| 571 | |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 572 | // for buying |
| 573 | if(tax.category) { |
| 574 | // if just for valuation, do not add the tax amount in total |
| 575 | // hence, setting it as 0 for further steps |
| 576 | current_tax_amount = (tax.category == "Valuation") ? 0.0 : current_tax_amount; |
| 577 | |
| 578 | current_tax_amount *= (tax.add_deduct_tax == "Deduct") ? -1.0 : 1.0; |
| 579 | } |
| 580 | |
| 581 | // Calculate tax.total viz. grand total till that step |
| 582 | // note: grand_total_for_current_item contains the contribution of |
| 583 | // item's amount, previously applied tax and the current tax on that item |
| 584 | if(i==0) { |
| 585 | tax.grand_total_for_current_item = flt(item.amount + current_tax_amount, |
| 586 | precision("total", tax)); |
| 587 | } else { |
| 588 | tax.grand_total_for_current_item = |
| 589 | flt(me.frm.tax_doclist[i-1].grand_total_for_current_item + current_tax_amount, |
| 590 | precision("total", tax)); |
| 591 | } |
| 592 | |
| 593 | // in tax.total, accumulate grand total for each item |
| 594 | tax.total += tax.grand_total_for_current_item; |
| 595 | }); |
| 596 | }); |
| 597 | }, |
| 598 | |
| 599 | get_current_tax_amount: function(item, tax, item_tax_map) { |
| 600 | var tax_rate = this._get_tax_rate(tax, item_tax_map); |
| 601 | var current_tax_amount = 0.0; |
| 602 | |
| 603 | if(tax.charge_type == "Actual") { |
| 604 | // distribute the tax amount proportionally to each item row |
| 605 | var actual = flt(tax.rate, precision("tax_amount", tax)); |
| 606 | current_tax_amount = this.frm.doc.net_total ? |
| 607 | ((item.amount / this.frm.doc.net_total) * actual) : |
| 608 | 0.0; |
| 609 | |
| 610 | } else if(tax.charge_type == "On Net Total") { |
| 611 | current_tax_amount = (tax_rate / 100.0) * item.amount; |
| 612 | |
| 613 | } else if(tax.charge_type == "On Previous Row Amount") { |
| 614 | current_tax_amount = (tax_rate / 100.0) * |
| 615 | this.frm.tax_doclist[cint(tax.row_id) - 1].tax_amount_for_current_item; |
| 616 | |
| 617 | } else if(tax.charge_type == "On Previous Row Total") { |
| 618 | current_tax_amount = (tax_rate / 100.0) * |
| 619 | this.frm.tax_doclist[cint(tax.row_id) - 1].grand_total_for_current_item; |
| 620 | |
| 621 | } |
| 622 | |
Anand Doshi | 53b7342 | 2013-05-31 11:50:01 +0530 | [diff] [blame] | 623 | current_tax_amount = flt(current_tax_amount, precision("tax_amount", tax)); |
| 624 | |
| 625 | // store tax breakup for each item |
| 626 | tax.item_wise_tax_detail[item.item_code || item.item_name] = [tax_rate, current_tax_amount]; |
| 627 | |
| 628 | return current_tax_amount; |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 629 | }, |
| 630 | |
| 631 | _cleanup: function() { |
| 632 | $.each(this.frm.tax_doclist, function(i, tax) { |
| 633 | $.each(["tax_amount_for_current_item", "grand_total_for_current_item", |
| 634 | "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"], |
| 635 | function(i, fieldname) { delete tax[fieldname]; }); |
| 636 | |
| 637 | tax.item_wise_tax_detail = JSON.stringify(tax.item_wise_tax_detail); |
| 638 | }); |
| 639 | }, |
Anand Doshi | fc77718 | 2013-05-27 19:29:07 +0530 | [diff] [blame] | 640 | |
| 641 | calculate_total_advance: function(parenttype, advance_parentfield) { |
| 642 | if(this.frm.doc.doctype == parenttype && this.frm.doc.docstatus < 2) { |
| 643 | var advance_doclist = wn.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, |
| 644 | {parentfield: advance_parentfield}); |
| 645 | this.frm.doc.total_advance = flt(wn.utils.sum( |
| 646 | $.map(advance_doclist, function(adv) { return adv.allocated_amount }) |
| 647 | ), precision("total_advance")); |
| 648 | |
| 649 | this.calculate_outstanding_amount(); |
| 650 | } |
| 651 | }, |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 652 | |
| 653 | _set_in_company_currency: function(item, print_field, base_field) { |
| 654 | // set values in base currency |
| 655 | item[base_field] = flt(item[print_field] * this.frm.doc.conversion_rate, |
| 656 | precision(base_field, item)); |
| 657 | }, |
Anand Doshi | bf3e54a | 2013-06-05 14:11:32 +0530 | [diff] [blame] | 658 | |
| 659 | get_terms: function() { |
| 660 | var me = this; |
| 661 | if(this.frm.doc.tc_name) { |
Anand Doshi | 1fac2a9 | 2013-07-29 19:30:39 +0530 | [diff] [blame] | 662 | return this.frm.call({ |
Anand Doshi | bf3e54a | 2013-06-05 14:11:32 +0530 | [diff] [blame] | 663 | method: "webnotes.client.get_value", |
| 664 | args: { |
| 665 | doctype: "Terms and Conditions", |
| 666 | fieldname: "terms", |
| 667 | filters: { name: this.frm.doc.tc_name }, |
| 668 | }, |
| 669 | }); |
| 670 | } |
| 671 | }, |
Anand Doshi | 3543f30 | 2013-05-24 19:25:01 +0530 | [diff] [blame] | 672 | }); |