fixes for gl entries in purchase invoice

This commit is contained in:
Nabin Hait
2013-02-01 17:03:05 +05:30
parent 1a2974c53d
commit 982a0a0e0a
2 changed files with 29 additions and 27 deletions

View File

@@ -451,7 +451,7 @@ class DocType(BuyingController):
# item gl entries # item gl entries
stock_item_and_auto_accounting = False stock_item_and_auto_accounting = False
for item in self.doclist.get({"parentfield": "entries"}): for item in self.doclist.get({"parentfield": "entries"}):
if auto_inventory_accounting and \ if auto_inventory_accounting and flt(item.valuation_rate) and \
webnotes.conn.get_value("Item", item.item_code, "is_stock_item")=="Yes": webnotes.conn.get_value("Item", item.item_code, "is_stock_item")=="Yes":
# if auto inventory accounting enabled and stock item, # if auto inventory accounting enabled and stock item,
# then do stock related gl entries, expense will be booked in sales invoice # then do stock related gl entries, expense will be booked in sales invoice
@@ -467,7 +467,7 @@ class DocType(BuyingController):
stock_item_and_auto_accounting = True stock_item_and_auto_accounting = True
else: elif flt(item.amount):
# if not a stock item or auto inventory accounting disabled, book the expense # if not a stock item or auto inventory accounting disabled, book the expense
gl_entries.append( gl_entries.append(
self.get_gl_dict({ self.get_gl_dict({

View File

@@ -664,15 +664,16 @@ class DocType(SellingController):
# item gl entries # item gl entries
for item in getlist(self.doclist, 'entries'): for item in getlist(self.doclist, 'entries'):
# income account gl entries # income account gl entries
gl_entries.append( if flt(item.amount):
self.get_gl_dict({ gl_entries.append(
"account": item.income_account, self.get_gl_dict({
"against": self.doc.debit_to, "account": item.income_account,
"credit": item.amount, "against": self.doc.debit_to,
"remarks": self.doc.remarks, "credit": item.amount,
"cost_center": item.cost_center "remarks": self.doc.remarks,
}, is_cancel) "cost_center": item.cost_center
) }, is_cancel)
)
# if auto inventory accounting enabled and stock item, # if auto inventory accounting enabled and stock item,
# then do stock related gl entries # then do stock related gl entries
if auto_inventory_accounting and item.delivery_note and \ if auto_inventory_accounting and item.delivery_note and \
@@ -682,22 +683,23 @@ class DocType(SellingController):
item.dn_detail, "purchase_rate") item.dn_detail, "purchase_rate")
valuation_amount = purchase_rate * item.qty valuation_amount = purchase_rate * item.qty
# expense account gl entries # expense account gl entries
gl_entries.append( if flt(valuation_amount):
self.get_gl_dict({ gl_entries.append(
"account": item.expense_account, self.get_gl_dict({
"against": "Stock Delivered But Not Billed - %s" % (abbr,), "account": item.expense_account,
"debit": valuation_amount, "against": "Stock Delivered But Not Billed - %s" % (abbr,),
"remarks": self.doc.remarks or "Accounting Entry for Stock" "debit": valuation_amount,
}, is_cancel) "remarks": self.doc.remarks or "Accounting Entry for Stock"
) }, is_cancel)
gl_entries.append( )
self.get_gl_dict({ gl_entries.append(
"account": "Stock Delivered But Not Billed - %s" % (abbr,), self.get_gl_dict({
"against": item.expense_account, "account": "Stock Delivered But Not Billed - %s" % (abbr,),
"credit": valuation_amount, "against": item.expense_account,
"remarks": self.doc.remarks or "Accounting Entry for Stock" "credit": valuation_amount,
}, is_cancel) "remarks": self.doc.remarks or "Accounting Entry for Stock"
) }, is_cancel)
)
if self.doc.is_pos and self.doc.cash_bank_account and self.doc.paid_amount: if self.doc.is_pos and self.doc.cash_bank_account and self.doc.paid_amount:
# POS, make payment entries # POS, make payment entries
gl_entries.append( gl_entries.append(