blob: f02e8482f4a858378f3c31ccb8ecfd7968f7491f [file] [log] [blame]
Anand Doshi756dca72013-01-15 18:39:21 +05301# ERPNext - web based ERP (http://erpnext.com)
2# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17from __future__ import unicode_literals
18import webnotes
Anand Doshif8f0c0d2013-01-17 20:20:56 +053019from webnotes import _, msgprint
Anand Doshi8595fcf2013-02-08 19:28:14 +053020from webnotes.utils import flt, cint
21import json
Anand Doshi756dca72013-01-15 18:39:21 +053022
23from buying.utils import get_item_details
Anand Doshif8f0c0d2013-01-17 20:20:56 +053024from setup.utils import get_company_currency
Anand Doshi8595fcf2013-02-08 19:28:14 +053025from webnotes.model.utils import round_floats_in_doc
Anand Doshi756dca72013-01-15 18:39:21 +053026
Nabin Hait89a94d82013-03-19 12:01:46 +053027from controllers.stock_controller import StockController
Nabin Haitbf495c92013-01-30 12:49:08 +053028
Rushabh Mehtaecb36f22013-05-02 11:34:37 +053029class WrongWarehouseCompany(Exception): pass
30
Nabin Hait89a94d82013-03-19 12:01:46 +053031class BuyingController(StockController):
Saurabh6f753182013-03-20 12:55:28 +053032 def validate(self):
33 super(BuyingController, self).validate()
Nabin Hait205f7ce2013-04-26 13:35:06 +053034 self.validate_stock_or_nonstock_items()
Rushabh Mehtaecb36f22013-05-02 11:34:37 +053035 self.validate_warehouse_belongs_to_company()
Anand Doshif8f0c0d2013-01-17 20:20:56 +053036 if self.meta.get_field("currency"):
37 self.company_currency = get_company_currency(self.doc.company)
38 self.validate_conversion_rate("currency", "conversion_rate")
Anand Doshi8957bf92013-01-17 20:29:28 +053039
40 if self.doc.price_list_name and self.doc.price_list_currency:
41 self.validate_conversion_rate("price_list_currency", "plc_conversion_rate")
Anand Doshi8595fcf2013-02-08 19:28:14 +053042
43 # IMPORTANT: enable this only when client side code is similar to this one
Anand Doshi3576b182013-02-08 19:30:06 +053044 # self.calculate_taxes_and_totals()
Saurabh6f753182013-03-20 12:55:28 +053045
Nabin Haitd3b62502013-01-21 17:24:31 +053046 # set total in words
Nabin Hait5b4c2942013-01-22 11:12:02 +053047 self.set_total_in_words()
Rushabh Mehtaecb36f22013-05-02 11:34:37 +053048
49 def validate_warehouse_belongs_to_company(self):
Rushabh Mehtac7115982013-05-02 14:22:40 +053050 for warehouse, company in webnotes.conn.get_values("Warehouse",
51 self.doclist.get_distinct_values("warehouse"), "company").items():
52 if company and company != self.doc.company:
Anand Doshieb41ffd2013-05-02 18:10:19 +053053 webnotes.msgprint(_("Company mismatch for Warehouse") + (": %s" % (warehouse,)),
Rushabh Mehtaecb36f22013-05-02 11:34:37 +053054 raise_exception=WrongWarehouseCompany)
Rushabh Mehtac7115982013-05-02 14:22:40 +053055
Nabin Hait205f7ce2013-04-26 13:35:06 +053056 def validate_stock_or_nonstock_items(self):
Nabin Haitbc2d9e82013-06-19 14:58:01 +053057 if not self.stock_items:
Nabin Hait205f7ce2013-04-26 13:35:06 +053058 tax_for_valuation = [d.account_head for d in
59 self.doclist.get({"parentfield": "purchase_tax_details"})
60 if d.category in ["Valuation", "Valuation and Total"]]
61 if tax_for_valuation:
62 webnotes.msgprint(_("""Tax Category can not be 'Valuation' or 'Valuation and Total'
63 as all items are non-stock items"""), raise_exception=1)
64
Anand Doshi756dca72013-01-15 18:39:21 +053065 def update_item_details(self):
66 for item in self.doclist.get({"parentfield": self.fname}):
67 ret = get_item_details({
68 "doctype": self.doc.doctype,
69 "docname": self.doc.name,
70 "item_code": item.item_code,
71 "warehouse": item.warehouse,
72 "supplier": self.doc.supplier,
73 "transaction_date": self.doc.posting_date,
Nabin Haitc10c90a2013-02-06 11:44:43 +053074 "conversion_rate": self.doc.conversion_rate,
75 "price_list_name": self.doc.price_list_name,
76 "price_list_currency": self.doc.price_list_currency,
77 "plc_conversion_rate": self.doc.plc_conversion_rate
Anand Doshi756dca72013-01-15 18:39:21 +053078 })
79 for r in ret:
80 if not item.fields.get(r):
81 item.fields[r] = ret[r]
Anand Doshif8f0c0d2013-01-17 20:20:56 +053082
83 def validate_conversion_rate(self, currency_field, conversion_rate_field):
84 """common validation for currency and price list currency"""
85
86 currency = self.doc.fields.get(currency_field)
87 conversion_rate = flt(self.doc.fields.get(conversion_rate_field))
88 conversion_rate_label = self.meta.get_label(conversion_rate_field)
89
90 if conversion_rate == 0:
91 msgprint(conversion_rate_label + _(' cannot be 0'), raise_exception=True)
92
93 # parenthesis for 'OR' are necessary as we want it to evaluate as
94 # mandatory valid condition and (1st optional valid condition
95 # or 2nd optional valid condition)
96 valid_conversion_rate = (conversion_rate and
97 ((currency == self.company_currency and conversion_rate == 1.00)
98 or (currency != self.company_currency and conversion_rate != 1.00)))
99
100 if not valid_conversion_rate:
101 msgprint(_('Please enter valid ') + conversion_rate_label + (': ')
Nabin Hait10221982013-01-18 16:47:39 +0530102 + ("1 %s = [?] %s" % (currency, self.company_currency)),
Anand Doshif8f0c0d2013-01-17 20:20:56 +0530103 raise_exception=True)
Nabin Haitd3b62502013-01-21 17:24:31 +0530104
105 def set_total_in_words(self):
Nabin Hait5b4c2942013-01-22 11:12:02 +0530106 from webnotes.utils import money_in_words
Nabin Haitd3b62502013-01-21 17:24:31 +0530107 company_currency = get_company_currency(self.doc.company)
Nabin Hait5b4c2942013-01-22 11:12:02 +0530108 if self.meta.get_field("in_words"):
109 self.doc.in_words = money_in_words(self.doc.grand_total, company_currency)
110 if self.meta.get_field("in_words_import"):
111 self.doc.in_words_import = money_in_words(self.doc.grand_total_import,
Anand Doshi613cb6a2013-02-06 17:33:46 +0530112 self.doc.currency)
113
114 def calculate_taxes_and_totals(self):
Anand Doshi62090462013-02-07 19:47:34 +0530115 self.doc.conversion_rate = flt(self.doc.conversion_rate)
Anand Doshi8595fcf2013-02-08 19:28:14 +0530116 self.item_doclist = self.doclist.get({"parentfield": self.fname})
117 self.tax_doclist = self.doclist.get({"parentfield": "purchase_tax_details"})
Anand Doshi62090462013-02-07 19:47:34 +0530118
Anand Doshi8595fcf2013-02-08 19:28:14 +0530119 self.calculate_item_values()
120 self.initialize_taxes()
121 self.calculate_net_total()
122 self.calculate_taxes()
123 self.calculate_totals()
124 self.calculate_outstanding_amount()
125
126 self._cleanup()
127
128 def calculate_item_values(self):
129 def _set_base(item, print_field, base_field):
130 """set values in base currency"""
131 item.fields[base_field] = flt((flt(item.fields[print_field],
132 self.precision.item[print_field]) * self.doc.conversion_rate),
133 self.precision.item[base_field])
134
135 for item in self.item_doclist:
136 round_floats_in_doc(item, self.precision.item)
Anand Doshia1d4b782013-02-26 18:09:47 +0530137
138 # hack! - cleaned up in _cleanup()
139 if self.doc.doctype != "Purchase Invoice":
140 item.rate = item.purchase_rate
141 self.precision.item.rate = self.precision.item.purchase_rate
142
143 item.discount = item.discount_rate
144 self.precision.item.discount = self.precision.item.discount_rate
Anand Doshi8595fcf2013-02-08 19:28:14 +0530145
146 if item.discount == 100:
147 if not item.import_ref_rate:
148 item.import_ref_rate = item.import_rate
149 item.import_rate = 0
150 else:
151 if item.import_ref_rate:
152 item.import_rate = flt(item.import_ref_rate *
153 (1.0 - (item.discount_rate / 100.0)),
154 self.precision.item.import_rate)
155 else:
156 # assume that print rate and discount are specified
157 item.import_ref_rate = flt(item.import_rate /
158 (1.0 - (item.discount_rate / 100.0)),
159 self.precision.item.import_ref_rate)
Anand Doshia1d4b782013-02-26 18:09:47 +0530160
Anand Doshi8595fcf2013-02-08 19:28:14 +0530161 item.import_amount = flt(item.import_rate * item.qty,
162 self.precision.item.import_amount)
Anand Doshia1d4b782013-02-26 18:09:47 +0530163
Anand Doshi8595fcf2013-02-08 19:28:14 +0530164 _set_base(item, "import_ref_rate", "purchase_ref_rate")
165 _set_base(item, "import_rate", "rate")
166 _set_base(item, "import_amount", "amount")
167
168 def initialize_taxes(self):
169 for tax in self.tax_doclist:
170 # initialize totals to 0
171 tax.tax_amount = tax.total = 0.0
172
173 # temporary fields
174 tax.tax_amount_for_current_item = tax.grand_total_for_current_item = 0.0
175
176 tax.item_wise_tax_detail = {}
177
178 self.validate_on_previous_row(tax)
179
180 round_floats_in_doc(tax, self.precision.tax)
181
182 def calculate_net_total(self):
183 self.doc.net_total = 0
184 self.doc.net_total_import = 0
185
186 for item in self.item_doclist:
187 self.doc.net_total += item.amount
188 self.doc.net_total_import += item.import_amount
189
190 self.doc.net_total = flt(self.doc.net_total, self.precision.main.net_total)
191 self.doc.net_total_import = flt(self.doc.net_total_import,
192 self.precision.main.net_total_import)
193
194 def calculate_taxes(self):
195 for item in self.item_doclist:
196 item_tax_map = self._load_item_tax_rate(item.item_tax_rate)
197 item.item_tax_amount = 0
198
199 for i, tax in enumerate(self.tax_doclist):
200 # tax_amount represents the amount of tax for the current step
201 current_tax_amount = self.get_current_tax_amount(item, tax, item_tax_map)
202
203 self.set_item_tax_amount(item, tax, current_tax_amount)
204
205 # case when net total is 0 but there is an actual type charge
206 # in this case add the actual amount to tax.tax_amount
207 # and tax.grand_total_for_current_item for the first such iteration
208 if not (current_tax_amount or self.doc.net_total or tax.tax_amount) and \
209 tax.charge_type=="Actual":
210 zero_net_total_adjustment = flt(tax.rate, self.precision.tax.tax_amount)
211 current_tax_amount += zero_net_total_adjustment
212
213 # store tax_amount for current item as it will be used for
214 # charge type = 'On Previous Row Amount'
215 tax.tax_amount_for_current_item = current_tax_amount
216
217 # accumulate tax amount into tax.tax_amount
218 tax.tax_amount += tax.tax_amount_for_current_item
219
220 if tax.category == "Valuation":
221 # if just for valuation, do not add the tax amount in total
222 # hence, setting it as 0 for further steps
223 current_tax_amount = 0
224 else:
225 current_tax_amount *= tax.add_deduct_tax == "Deduct" and -1.0 or 1.0
226
227 # Calculate tax.total viz. grand total till that step
228 # note: grand_total_for_current_item contains the contribution of
229 # item's amount, previously applied tax and the current tax on that item
230 if i==0:
231 tax.grand_total_for_current_item = flt(item.amount +
232 current_tax_amount, self.precision.tax.total)
233
234 else:
235 tax.grand_total_for_current_item = \
236 flt(self.tax_doclist[i-1].grand_total_for_current_item +
237 current_tax_amount, self.precision.tax.total)
238
239 # in tax.total, accumulate grand total of each item
240 tax.total += tax.grand_total_for_current_item
241
242 # store tax_breakup for each item
243 # DOUBT: should valuation type amount also be stored?
244 tax.item_wise_tax_detail[item.item_code] = current_tax_amount
245
246 def calculate_totals(self):
247 if self.tax_doclist:
248 self.doc.grand_total = flt(self.tax_doclist[-1].total,
249 self.precision.main.grand_total)
250 self.doc.grand_total_import = flt(
251 self.doc.grand_total / self.doc.conversion_rate,
252 self.precision.main.grand_total_import)
253 else:
254 self.doc.grand_total = flt(self.doc.net_total,
255 self.precision.main.grand_total)
Anand Doshi4a7248e2013-02-27 18:10:30 +0530256 self.doc.grand_total_import = flt(
Anand Doshi8595fcf2013-02-08 19:28:14 +0530257 self.doc.grand_total / self.doc.conversion_rate,
258 self.precision.main.grand_total_import)
259
260 self.doc.total_tax = \
261 flt(self.doc.grand_total - self.doc.net_total,
262 self.precision.main.total_tax)
263
264 if self.meta.get_field("rounded_total"):
265 self.doc.rounded_total = round(self.doc.grand_total)
266
267 if self.meta.get_field("rounded_total_import"):
268 self.doc.rounded_total_import = round(self.doc.grand_total_import)
269
270 def calculate_outstanding_amount(self):
271 if self.doc.doctype == "Purchase Invoice" and self.doc.docstatus == 0:
272 self.doc.total_advance = flt(self.doc.total_advance,
273 self.precision.main.total_advance)
Anand Doshi9d794fc2013-02-27 13:34:22 +0530274 self.doc.total_amount_to_pay = flt(self.doc.grand_total - flt(self.doc.write_off_amount,
275 self.precision.main.write_off_amount), self.precision.main.total_amount_to_pay)
276 self.doc.outstanding_amount = flt(self.doc.total_amount_to_pay - self.doc.total_advance,
Anand Doshi8595fcf2013-02-08 19:28:14 +0530277 self.precision.main.outstanding_amount)
278
279 def _cleanup(self):
280 for tax in self.tax_doclist:
281 del tax.fields["grand_total_for_current_item"]
282 del tax.fields["tax_amount_for_current_item"]
283 tax.item_wise_tax_detail = json.dumps(tax.item_wise_tax_detail)
284
285 # except in purchase invoice, rate field is purchase_rate
286 if self.doc.doctype != "Purchase Invoice":
287 for item in self.item_doclist:
288 item.purchase_rate = item.rate
289 del item.fields["rate"]
Anand Doshia1d4b782013-02-26 18:09:47 +0530290
291 item.discount_rate = item.discount
292 del item.fields["discount"]
Anand Doshi8595fcf2013-02-08 19:28:14 +0530293
294 def validate_on_previous_row(self, tax):
295 """
296 validate if a valid row id is mentioned in case of
297 On Previous Row Amount and On Previous Row Total
298 """
299 if tax.charge_type in ["On Previous Row Amount", "On Previous Row Total"] and \
300 (not tax.row_id or cint(tax.row_id) >= tax.idx):
301 msgprint((_("Row") + " # %(idx)s [%(taxes_doctype)s]: " + \
302 _("Please specify a valid") + " %(row_id_label)s") % {
303 "idx": tax.idx,
304 "taxes_doctype": tax.parenttype,
305 "row_id_label": self.meta.get_label("row_id",
306 parentfield="purchase_tax_details")
307 }, raise_exception=True)
308
309 def _load_item_tax_rate(self, item_tax_rate):
310 if not item_tax_rate:
311 return {}
312 return json.loads(item_tax_rate)
313
314 def get_current_tax_amount(self, item, tax, item_tax_map):
315 tax_rate = self._get_tax_rate(tax, item_tax_map)
316
317 if tax.charge_type == "Actual":
318 # distribute the tax amount proportionally to each item row
319 actual = flt(tax.rate, self.precision.tax.tax_amount)
320 current_tax_amount = (self.doc.net_total
321 and ((item.amount / self.doc.net_total) * actual)
322 or 0)
323 elif tax.charge_type == "On Net Total":
324 current_tax_amount = (tax_rate / 100.0) * item.amount
325 elif tax.charge_type == "On Previous Row Amount":
326 current_tax_amount = (tax_rate / 100.0) * \
327 self.tax_doclist[cint(tax.row_id) - 1].tax_amount_for_current_item
328 elif tax.charge_type == "On Previous Row Total":
329 current_tax_amount = (tax_rate / 100.0) * \
330 self.tax_doclist[cint(tax.row_id) - 1].grand_total_for_current_item
331
332 return flt(current_tax_amount, self.precision.tax.tax_amount)
333
334 def _get_tax_rate(self, tax, item_tax_map):
335 if item_tax_map.has_key(tax.account_head):
336 return flt(item_tax_map.get(tax.account_head), self.precision.tax.rate)
337 else:
338 return tax.rate
339
340 def set_item_tax_amount(self, item, tax, current_tax_amount):
341 """
342 item_tax_amount is the total tax amount applied on that item
343 stored for valuation
344
345 TODO: rename item_tax_amount to valuation_tax_amount
346 """
347 if tax.category in ["Valuation", "Valuation and Total"] and \
348 item.item_code in self.stock_items:
349 item.item_tax_amount += flt(current_tax_amount,
350 self.precision.item.item_tax_amount)
Anand Doshi4a7248e2013-02-27 18:10:30 +0530351
352 # update valuation rate
353 def update_valuation_rate(self, parentfield):
354 for d in self.doclist.get({"parentfield": parentfield}):
Nabin Hait0fc24542013-03-25 11:06:00 +0530355 d.conversion_factor = d.conversion_factor or flt(webnotes.conn.get_value(
Nabin Haita9afc252013-03-01 10:41:41 +0530356 "UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom},
Nabin Hait0fc24542013-03-25 11:06:00 +0530357 "conversion_factor")) or 1
Anand Doshi1bfec3a2013-02-28 19:17:46 +0530358 if d.item_code and d.qty:
359 # if no item code, which is sometimes the case in purchase invoice,
360 # then it is not possible to track valuation against it
Nabin Haitfdefe072013-05-20 13:59:24 +0530361 d.valuation_rate = flt(((flt(d.purchase_rate, self.precision.item.purchase_rate) or
362 flt(d.rate, self.precision.item.rate)) +
Nabin Haite1b2ae52013-05-09 16:56:19 +0530363 (flt(d.item_tax_amount, self.precision.item.item_tax_amount) +
364 flt(d.rm_supp_cost, self.precision.item.rm_supp_cost)) /
365 flt(d.qty, self.precision.item.qty)) /
366 flt(d.conversion_factor, self.precision.item.conversion_factor),
Nabin Haitfdefe072013-05-20 13:59:24 +0530367 self.precision.item.valuation_rate)
Anand Doshi4a7248e2013-02-27 18:10:30 +0530368 else:
369 d.valuation_rate = 0.0
Nabin Hait54d209f2013-03-01 18:51:10 +0530370
371 def validate_for_subcontracting(self):
372 if not self.doc.is_subcontracted and self.sub_contracted_items:
373 webnotes.msgprint(_("""Please enter whether %s is made for subcontracting or purchasing,
374 in 'Is Subcontracted' field""" % self.doc.doctype), raise_exception=1)
375
376 if self.doc.doctype == "Purchase Receipt" and self.doc.is_subcontracted=="Yes" \
377 and not self.doc.supplier_warehouse:
378 webnotes.msgprint(_("Supplier Warehouse mandatory subcontracted purchase receipt"),
379 raise_exception=1)
380
381 def update_raw_materials_supplied(self, raw_material_table):
382 self.doclist = self.doc.clear_table(self.doclist, raw_material_table)
383 if self.doc.is_subcontracted=="Yes":
384 for item in self.doclist.get({"parentfield": self.fname}):
385 if item.item_code in self.sub_contracted_items:
386 self.add_bom_items(item, raw_material_table)
387
388 def add_bom_items(self, d, raw_material_table):
389 bom_items = self.get_items_from_default_bom(d.item_code)
390 raw_materials_cost = 0
391 for item in bom_items:
392 required_qty = flt(item.qty_consumed_per_unit) * flt(d.qty) * flt(d.conversion_factor)
393 rm_doclist = {
394 "parentfield": raw_material_table,
395 "doctype": self.doc.doctype + " Item Supplied",
396 "reference_name": d.name,
397 "bom_detail_no": item.name,
398 "main_item_code": d.item_code,
399 "rm_item_code": item.item_code,
400 "stock_uom": item.stock_uom,
401 "required_qty": required_qty,
402 "conversion_factor": d.conversion_factor,
403 "rate": item.rate,
404 "amount": required_qty * flt(item.rate)
405 }
406 if self.doc.doctype == "Purchase Receipt":
407 rm_doclist.update({
408 "consumed_qty": required_qty,
409 "description": item.description,
410 })
411
412 self.doclist.append(rm_doclist)
413
414 raw_materials_cost += required_qty * flt(item.rate)
415
416 if self.doc.doctype == "Purchase Receipt":
417 d.rm_supp_cost = raw_materials_cost
418
419 def get_items_from_default_bom(self, item_code):
420 # print webnotes.conn.sql("""select name from `tabBOM` where item = '_Test FG Item'""")
421 bom_items = webnotes.conn.sql("""select t2.item_code, t2.qty_consumed_per_unit,
422 t2.rate, t2.stock_uom, t2.name, t2.description
423 from `tabBOM` t1, `tabBOM Item` t2
424 where t2.parent = t1.name and t1.item = %s and t1.is_default = 1
425 and t1.docstatus = 1 and t1.is_active = 1""", item_code, as_dict=1)
426 if not bom_items:
427 msgprint(_("No default BOM exists for item: ") + item_code, raise_exception=1)
428
429 return bom_items
430
Anand Doshi8595fcf2013-02-08 19:28:14 +0530431
432 @property
Anand Doshi8595fcf2013-02-08 19:28:14 +0530433 def precision(self):
434 if not hasattr(self, "_precision"):
435 self._precision = webnotes._dict()
436 self._precision.main = self.meta.get_precision_map()
437 self._precision.item = self.meta.get_precision_map(parentfield = self.fname)
438 if self.meta.get_field("purchase_tax_details"):
439 self._precision.tax = self.meta.get_precision_map(parentfield = \
440 "purchase_tax_details")
441 return self._precision
Nabin Hait5418d712013-02-27 18:11:17 +0530442
443 @property
444 def sub_contracted_items(self):
445 if not hasattr(self, "_sub_contracted_items"):
Nabin Haitebd51442013-04-23 15:36:26 +0530446 self._sub_contracted_items = []
Nabin Hait5418d712013-02-27 18:11:17 +0530447 item_codes = list(set(item.item_code for item in
448 self.doclist.get({"parentfield": self.fname})))
Nabin Haitebd51442013-04-23 15:36:26 +0530449 if item_codes:
450 self._sub_contracted_items = [r[0] for r in webnotes.conn.sql("""select name
451 from `tabItem` where name in (%s) and is_sub_contracted_item='Yes'""" % \
452 (", ".join((["%s"]*len(item_codes))),), item_codes)]
Nabin Hait5418d712013-02-27 18:11:17 +0530453
454 return self._sub_contracted_items
455
456 @property
457 def purchase_items(self):
458 if not hasattr(self, "_purchase_items"):
Nabin Haitebd51442013-04-23 15:36:26 +0530459 self._purchase_items = []
Nabin Hait5418d712013-02-27 18:11:17 +0530460 item_codes = list(set(item.item_code for item in
461 self.doclist.get({"parentfield": self.fname})))
Nabin Haitebd51442013-04-23 15:36:26 +0530462 if item_codes:
463 self._purchase_items = [r[0] for r in webnotes.conn.sql("""select name
464 from `tabItem` where name in (%s) and is_purchase_item='Yes'""" % \
465 (", ".join((["%s"]*len(item_codes))),), item_codes)]
Nabin Hait5418d712013-02-27 18:11:17 +0530466
Anand Doshi55d9a622013-02-27 18:14:28 +0530467 return self._purchase_items