mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 21:19:19 +00:00
started with Auto Inventory Accounting - test case for purchase receipt
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import msgprint, _
|
||||
from webnotes.utils import flt
|
||||
from utilities.transaction_base import TransactionBase
|
||||
|
||||
@@ -37,15 +38,7 @@ class AccountsController(TransactionBase):
|
||||
}
|
||||
gl_dict.update(args)
|
||||
return gl_dict
|
||||
|
||||
def get_stock_in_hand_account(self):
|
||||
stock_in_hand = webnotes.conn.get_value("Company", self.doc.company, "stock_in_hand")
|
||||
if not stock_in_hand:
|
||||
webnotes.msgprint("""Please specify "Stock In Hand" account
|
||||
for company: %s""" % (self.doc.company,), raise_exception=1)
|
||||
|
||||
return stock_in_hand
|
||||
|
||||
|
||||
def clear_unallocated_advances(self, childtype, parentfield):
|
||||
self.doclist.remove_items({"parentfield": parentfield, "allocated_amount": ["in", [0, None, ""]]})
|
||||
|
||||
@@ -73,4 +66,24 @@ class AccountsController(TransactionBase):
|
||||
"remarks": d.remark,
|
||||
"advance_amount": flt(d.amount),
|
||||
"allocate_amount": 0
|
||||
})
|
||||
})
|
||||
|
||||
def get_stock_in_hand_account(self):
|
||||
stock_in_hand_account = webnotes.conn.get_value("Company", self.doc.company, "stock_in_hand_account")
|
||||
|
||||
if not stock_in_hand_account:
|
||||
msgprint(_("Missing") + ": "
|
||||
+ _(webnotes.get_doctype("company").get_label("stock_in_hand_account")
|
||||
+ " " + _("for Company") + " " + self.doc.company), raise_exception=True)
|
||||
|
||||
return stock_in_hand_account
|
||||
|
||||
@property
|
||||
def stock_items(self):
|
||||
if not hasattr(self, "_stock_items"):
|
||||
item_codes = list(set(item.item_code for item in self.doclist.get({"parentfield": self.fname})))
|
||||
self._stock_items = [r[0] for r in webnotes.conn.sql("""select name
|
||||
from `tabItem` where name in (%s) and is_stock_item='Yes'""" % \
|
||||
(", ".join((["%s"]*len(item_codes))),), item_codes)]
|
||||
|
||||
return self._stock_items
|
||||
@@ -113,6 +113,14 @@ class BuyingController(AccountsController):
|
||||
|
||||
for item in self.item_doclist:
|
||||
round_floats_in_doc(item, self.precision.item)
|
||||
|
||||
# hack! - cleaned up in _cleanup()
|
||||
if self.doc.doctype != "Purchase Invoice":
|
||||
item.rate = item.purchase_rate
|
||||
self.precision.item.rate = self.precision.item.purchase_rate
|
||||
|
||||
item.discount = item.discount_rate
|
||||
self.precision.item.discount = self.precision.item.discount_rate
|
||||
|
||||
if item.discount == 100:
|
||||
if not item.import_ref_rate:
|
||||
@@ -128,10 +136,10 @@ class BuyingController(AccountsController):
|
||||
item.import_ref_rate = flt(item.import_rate /
|
||||
(1.0 - (item.discount_rate / 100.0)),
|
||||
self.precision.item.import_ref_rate)
|
||||
|
||||
|
||||
item.import_amount = flt(item.import_rate * item.qty,
|
||||
self.precision.item.import_amount)
|
||||
|
||||
|
||||
_set_base(item, "import_ref_rate", "purchase_ref_rate")
|
||||
_set_base(item, "import_rate", "rate")
|
||||
_set_base(item, "import_amount", "amount")
|
||||
@@ -256,6 +264,9 @@ class BuyingController(AccountsController):
|
||||
for item in self.item_doclist:
|
||||
item.purchase_rate = item.rate
|
||||
del item.fields["rate"]
|
||||
|
||||
item.discount_rate = item.discount
|
||||
del item.fields["discount"]
|
||||
|
||||
def validate_on_previous_row(self, tax):
|
||||
"""
|
||||
@@ -315,16 +326,6 @@ class BuyingController(AccountsController):
|
||||
item.item_tax_amount += flt(current_tax_amount,
|
||||
self.precision.item.item_tax_amount)
|
||||
|
||||
@property
|
||||
def stock_items(self):
|
||||
if not hasattr(self, "_stock_items"):
|
||||
item_codes = list(set(item.item_code for item in self.item_doclist))
|
||||
self._stock_items = [r[0] for r in webnotes.conn.sql("""select name
|
||||
from `tabItem` where name in (%s) and is_stock_item='Yes'""" % \
|
||||
(", ".join((["%s"]*len(item_codes))),), item_codes)]
|
||||
|
||||
return self._stock_items
|
||||
|
||||
@property
|
||||
def precision(self):
|
||||
if not hasattr(self, "_precision"):
|
||||
|
||||
Reference in New Issue
Block a user