aii: book expense in delivery note instead of sales invoice
This commit is contained in:
parent
407331675f
commit
a0e7c1539b
@ -27,8 +27,6 @@ from webnotes.model.bean import getlist
|
|||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import _, msgprint
|
from webnotes import _, msgprint
|
||||||
|
|
||||||
from stock.utils import get_buying_amount, get_sales_bom
|
|
||||||
|
|
||||||
session = webnotes.session
|
session = webnotes.session
|
||||||
|
|
||||||
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
|
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
|
||||||
@ -702,18 +700,8 @@ class DocType(SellingController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def make_item_gl_entries(self, gl_entries):
|
def make_item_gl_entries(self, gl_entries):
|
||||||
# item gl entries
|
|
||||||
auto_inventory_accounting = \
|
|
||||||
cint(webnotes.defaults.get_global_default("auto_inventory_accounting"))
|
|
||||||
|
|
||||||
if auto_inventory_accounting:
|
|
||||||
if cint(self.doc.is_pos) and cint(self.doc.update_stock):
|
|
||||||
stock_account = self.get_default_account("stock_in_hand_account")
|
|
||||||
else:
|
|
||||||
stock_account = self.get_default_account("stock_delivered_but_not_billed")
|
|
||||||
|
|
||||||
for item in self.doclist.get({"parentfield": "entries"}):
|
|
||||||
# income account gl entries
|
# income account gl entries
|
||||||
|
for item in self.doclist.get({"parentfield": "entries"}):
|
||||||
if flt(item.amount):
|
if flt(item.amount):
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
@ -726,26 +714,14 @@ class DocType(SellingController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# expense account gl entries
|
# expense account gl entries
|
||||||
if auto_inventory_accounting and flt(item.buying_amount):
|
if cint(webnotes.defaults.get_global_default("auto_inventory_accounting")) \
|
||||||
|
and cint(self.doc.is_pos) and cint(self.doc.update_stock):
|
||||||
|
|
||||||
|
for item in self.doclist.get({"parentfield": "entries"}):
|
||||||
self.check_expense_account(item)
|
self.check_expense_account(item)
|
||||||
|
|
||||||
gl_entries.append(
|
gl_entries += self.get_gl_entries_for_stock(item.expense_account,
|
||||||
self.get_gl_dict({
|
-1*item.buying_amount, cost_center=item.cost_center)
|
||||||
"account": item.expense_account,
|
|
||||||
"against": stock_account,
|
|
||||||
"debit": item.buying_amount,
|
|
||||||
"remarks": self.doc.remarks or "Accounting Entry for Stock",
|
|
||||||
"cost_center": item.cost_center
|
|
||||||
})
|
|
||||||
)
|
|
||||||
gl_entries.append(
|
|
||||||
self.get_gl_dict({
|
|
||||||
"account": stock_account,
|
|
||||||
"against": item.expense_account,
|
|
||||||
"credit": item.buying_amount,
|
|
||||||
"remarks": self.doc.remarks or "Accounting Entry for Stock"
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
def make_pos_gl_entries(self, gl_entries):
|
def make_pos_gl_entries(self, gl_entries):
|
||||||
if cint(self.doc.is_pos) and self.doc.cash_bank_account and self.doc.paid_amount:
|
if cint(self.doc.is_pos) and self.doc.cash_bank_account and self.doc.paid_amount:
|
||||||
@ -790,42 +766,6 @@ class DocType(SellingController):
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_buying_amount(self):
|
|
||||||
if cint(self.doc.is_pos) and cint(self.doc.update_stock):
|
|
||||||
stock_ledger_entries = self.get_stock_ledger_entries()
|
|
||||||
item_sales_bom = get_sales_bom()
|
|
||||||
else:
|
|
||||||
stock_ledger_entries = item_sales_bom = None
|
|
||||||
|
|
||||||
for item in self.doclist.get({"parentfield": "entries"}):
|
|
||||||
if item.item_code in self.stock_items or \
|
|
||||||
(item_sales_bom and item_sales_bom.get(item.item_code)):
|
|
||||||
item.buying_amount = self.get_item_buying_amount(item, stock_ledger_entries,
|
|
||||||
item_sales_bom)
|
|
||||||
webnotes.conn.set_value("Sales Invoice Item", item.name,
|
|
||||||
"buying_amount", item.buying_amount)
|
|
||||||
|
|
||||||
def get_item_buying_amount(self, item, stock_ledger_entries, item_sales_bom):
|
|
||||||
item_buying_amount = 0
|
|
||||||
if stock_ledger_entries:
|
|
||||||
# is pos and update stock
|
|
||||||
item_buying_amount = get_buying_amount(item.item_code, item.warehouse, -1*item.qty,
|
|
||||||
self.doc.doctype, self.doc.name, item.name, stock_ledger_entries, item_sales_bom)
|
|
||||||
item.buying_amount = item_buying_amount > 0 and item_buying_amount or 0
|
|
||||||
elif item.delivery_note and item.dn_detail:
|
|
||||||
# against delivery note
|
|
||||||
dn_item = webnotes.conn.get_value("Delivery Note Item", item.dn_detail,
|
|
||||||
["buying_amount", "qty"], as_dict=1)
|
|
||||||
item_buying_rate = flt(dn_item.buying_amount) / flt(dn_item.qty)
|
|
||||||
item_buying_amount = item_buying_rate * flt(item.qty)
|
|
||||||
|
|
||||||
return item_buying_amount
|
|
||||||
|
|
||||||
def check_expense_account(self, item):
|
|
||||||
if not item.expense_account:
|
|
||||||
msgprint(_("""Expense account is mandatory for item: """) + item.item_code,
|
|
||||||
raise_exception=1)
|
|
||||||
|
|
||||||
def update_c_form(self):
|
def update_c_form(self):
|
||||||
"""Update amended id in C-form"""
|
"""Update amended id in C-form"""
|
||||||
if self.doc.c_form_no and self.doc.amended_from:
|
if self.doc.c_form_no and self.doc.amended_from:
|
||||||
|
@ -86,68 +86,6 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEquals(gle_count[0][0], 8)
|
self.assertEquals(gle_count[0][0], 8)
|
||||||
|
|
||||||
def test_sales_invoice_gl_entry_with_aii_delivery_note(self):
|
|
||||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
|
||||||
|
|
||||||
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
|
|
||||||
|
|
||||||
self._insert_purchase_receipt()
|
|
||||||
dn = self._insert_delivery_note()
|
|
||||||
|
|
||||||
si_against_dn = webnotes.copy_doclist(test_records[1])
|
|
||||||
si_against_dn[1]["delivery_note"] = dn.doc.name
|
|
||||||
si_against_dn[1]["dn_detail"] = dn.doclist[1].name
|
|
||||||
si = webnotes.bean(si_against_dn)
|
|
||||||
si.insert()
|
|
||||||
|
|
||||||
si.submit()
|
|
||||||
|
|
||||||
gl_entries = webnotes.conn.sql("""select account, debit, credit
|
|
||||||
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
|
||||||
order by account asc""", si.doc.name, as_dict=1)
|
|
||||||
self.assertTrue(gl_entries)
|
|
||||||
|
|
||||||
expected_values = sorted([
|
|
||||||
[si.doc.debit_to, 630.0, 0.0],
|
|
||||||
[test_records[1][1]["income_account"], 0.0, 500.0],
|
|
||||||
[test_records[1][2]["account_head"], 0.0, 80.0],
|
|
||||||
[test_records[1][3]["account_head"], 0.0, 50.0],
|
|
||||||
["Stock Delivered But Not Billed - _TC", 0.0, 375.0],
|
|
||||||
[test_records[1][1]["expense_account"], 375.0, 0.0]
|
|
||||||
])
|
|
||||||
for i, gle in enumerate(gl_entries):
|
|
||||||
self.assertEquals(expected_values[i][0], gle.account)
|
|
||||||
self.assertEquals(expected_values[i][1], gle.debit)
|
|
||||||
self.assertEquals(expected_values[i][2], gle.credit)
|
|
||||||
|
|
||||||
si.cancel()
|
|
||||||
gl_entries = webnotes.conn.sql("""select account, debit, credit
|
|
||||||
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
|
||||||
and ifnull(is_cancelled, 'No') = 'No'
|
|
||||||
order by account asc, name asc""", si.doc.name, as_dict=1)
|
|
||||||
|
|
||||||
expected_values = sorted([
|
|
||||||
[si.doc.debit_to, 630.0, 0.0],
|
|
||||||
[si.doc.debit_to, 0.0, 630.0],
|
|
||||||
[test_records[1][1]["income_account"], 0.0, 500.0],
|
|
||||||
[test_records[1][1]["income_account"], 500.0, 0.0],
|
|
||||||
[test_records[1][2]["account_head"], 0.0, 80.0],
|
|
||||||
[test_records[1][2]["account_head"], 80.0, 0.0],
|
|
||||||
[test_records[1][3]["account_head"], 0.0, 50.0],
|
|
||||||
[test_records[1][3]["account_head"], 50.0, 0.0],
|
|
||||||
["Stock Delivered But Not Billed - _TC", 0.0, 375.0],
|
|
||||||
["Stock Delivered But Not Billed - _TC", 375.0, 0.0],
|
|
||||||
[test_records[1][1]["expense_account"], 375.0, 0.0],
|
|
||||||
[test_records[1][1]["expense_account"], 0.0, 375.0]
|
|
||||||
|
|
||||||
])
|
|
||||||
for i, gle in enumerate(gl_entries):
|
|
||||||
self.assertEquals(expected_values[i][0], gle.account)
|
|
||||||
self.assertEquals(expected_values[i][1], gle.debit)
|
|
||||||
self.assertEquals(expected_values[i][2], gle.credit)
|
|
||||||
|
|
||||||
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
|
|
||||||
|
|
||||||
def test_pos_gl_entry_with_aii(self):
|
def test_pos_gl_entry_with_aii(self):
|
||||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||||
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
|
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
|
||||||
@ -262,8 +200,6 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
|
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _insert_purchase_receipt(self):
|
def _insert_purchase_receipt(self):
|
||||||
from stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
from stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
||||||
as pr_test_records
|
as pr_test_records
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-03-07 11:42:55",
|
"creation": "2013-03-07 11:42:55",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-03-18 15:41:19",
|
"modified": "2013-03-21 18:35:47",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -207,11 +207,10 @@
|
|||||||
"width": "120px"
|
"width": "120px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:sys_defaults.auto_inventory_accounting",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "expense_account",
|
"fieldname": "expense_account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 1,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
"label": "Expense Account",
|
"label": "Expense Account",
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
|
@ -39,3 +39,19 @@ class SellingController(StockController):
|
|||||||
if self.meta.get_field("in_words_export"):
|
if self.meta.get_field("in_words_export"):
|
||||||
self.doc.in_words_export = money_in_words(disable_rounded_total and
|
self.doc.in_words_export = money_in_words(disable_rounded_total and
|
||||||
self.doc.grand_total_export or self.doc.rounded_total_export, self.doc.currency)
|
self.doc.grand_total_export or self.doc.rounded_total_export, self.doc.currency)
|
||||||
|
|
||||||
|
def set_buying_amount(self):
|
||||||
|
from stock.utils import get_buying_amount, get_sales_bom
|
||||||
|
stock_ledger_entries = self.get_stock_ledger_entries()
|
||||||
|
item_sales_bom = get_sales_bom()
|
||||||
|
|
||||||
|
if stock_ledger_entries:
|
||||||
|
for item in self.doclist.get({"parentfield": self.fname}):
|
||||||
|
if item.item_code in self.stock_items or \
|
||||||
|
(item_sales_bom and item_sales_bom.get(item.item_code)):
|
||||||
|
buying_amount = get_buying_amount(item.item_code, item.warehouse, -1*item.qty,
|
||||||
|
self.doc.doctype, self.doc.name, item.name, stock_ledger_entries,
|
||||||
|
item_sales_bom)
|
||||||
|
item.buying_amount = buying_amount > 0 and buying_amount or 0
|
||||||
|
webnotes.conn.set_value(self.tname, item.name, "buying_amount",
|
||||||
|
item.buying_amount)
|
@ -16,10 +16,13 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
|
from webnotes import msgprint, _
|
||||||
from controllers.accounts_controller import AccountsController
|
from controllers.accounts_controller import AccountsController
|
||||||
|
|
||||||
class StockController(AccountsController):
|
class StockController(AccountsController):
|
||||||
def make_gl_entries(self, against_stock_account, amount, cost_center=None):
|
def get_gl_entries_for_stock(self, against_stock_account, amount,
|
||||||
|
stock_in_hand_account=None, cost_center=None):
|
||||||
|
if not stock_in_hand_account:
|
||||||
stock_in_hand_account = self.get_default_account("stock_in_hand_account")
|
stock_in_hand_account = self.get_default_account("stock_in_hand_account")
|
||||||
|
|
||||||
if amount:
|
if amount:
|
||||||
@ -41,9 +44,14 @@ class StockController(AccountsController):
|
|||||||
"remarks": self.doc.remarks or "Accounting Entry for Stock",
|
"remarks": self.doc.remarks or "Accounting Entry for Stock",
|
||||||
}, self.doc.docstatus == 2),
|
}, self.doc.docstatus == 2),
|
||||||
]
|
]
|
||||||
from accounts.general_ledger import make_gl_entries
|
|
||||||
make_gl_entries(gl_entries, cancel=self.doc.docstatus == 2)
|
|
||||||
|
|
||||||
|
return gl_entries
|
||||||
|
|
||||||
|
|
||||||
|
def check_expense_account(self, item):
|
||||||
|
if not item.expense_account:
|
||||||
|
msgprint(_("""Expense account is mandatory for item: """) + item.item_code,
|
||||||
|
raise_exception=1)
|
||||||
|
|
||||||
def get_stock_ledger_entries(self, item_list=None, warehouse_list=None):
|
def get_stock_ledger_entries(self, item_list=None, warehouse_list=None):
|
||||||
if not (item_list and warehouse_list):
|
if not (item_list and warehouse_list):
|
||||||
|
@ -309,3 +309,23 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
|||||||
cur_frm.email_doc(wn.boot.notification_settings.delivery_note_message);
|
cur_frm.email_doc(wn.boot.notification_settings.delivery_note_message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// expense account
|
||||||
|
cur_frm.fields_dict['delivery_note_details'].grid.get_field('expense_account').get_query = function(doc) {
|
||||||
|
return {
|
||||||
|
"query": "accounts.utils.get_account_list",
|
||||||
|
"filters": {
|
||||||
|
"is_pl_account": "Yes",
|
||||||
|
"debit_or_credit": "Debit",
|
||||||
|
"company": doc.company
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// cost center
|
||||||
|
cur_frm.fields_dict["delivery_note_details"].grid.get_field("cost_center").get_query = function(doc) {
|
||||||
|
return {
|
||||||
|
query: "accounts.utils.get_cost_center_list",
|
||||||
|
filters: { company_name: doc.company}
|
||||||
|
}
|
||||||
|
}
|
@ -144,6 +144,8 @@ class DocType(SellingController):
|
|||||||
self.validate_mandatory()
|
self.validate_mandatory()
|
||||||
self.validate_reference_value()
|
self.validate_reference_value()
|
||||||
self.validate_for_items()
|
self.validate_for_items()
|
||||||
|
self.validate_warehouse()
|
||||||
|
|
||||||
sales_com_obj.validate_max_discount(self, 'delivery_note_details')
|
sales_com_obj.validate_max_discount(self, 'delivery_note_details')
|
||||||
sales_com_obj.get_allocated_sum(self)
|
sales_com_obj.get_allocated_sum(self)
|
||||||
sales_com_obj.check_conversion_rate(self)
|
sales_com_obj.check_conversion_rate(self)
|
||||||
@ -203,6 +205,12 @@ class DocType(SellingController):
|
|||||||
else:
|
else:
|
||||||
chk_dupl_itm.append(f)
|
chk_dupl_itm.append(f)
|
||||||
|
|
||||||
|
def validate_warehouse(self):
|
||||||
|
for d in self.get_item_list():
|
||||||
|
if webnotes.conn.get_value("Item", d['item_code'], "is_stock_item") == "Yes":
|
||||||
|
if not d['warehouse']:
|
||||||
|
msgprint("Please enter Warehouse for item %s as it is stock item"
|
||||||
|
% d['item_code'], raise_exception=1)
|
||||||
|
|
||||||
def validate_items_with_prevdoc(self, d):
|
def validate_items_with_prevdoc(self, d):
|
||||||
"""check if same item, warehouse present in prevdoc"""
|
"""check if same item, warehouse present in prevdoc"""
|
||||||
@ -393,41 +401,17 @@ class DocType(SellingController):
|
|||||||
total = (amount/self.doc.net_total)*self.doc.grand_total
|
total = (amount/self.doc.net_total)*self.doc.grand_total
|
||||||
get_obj('Sales Common').check_credit(self, total)
|
get_obj('Sales Common').check_credit(self, total)
|
||||||
|
|
||||||
def set_buying_amount(self):
|
|
||||||
from stock.utils import get_buying_amount, get_sales_bom
|
|
||||||
stock_ledger_entries = self.get_stock_ledger_entries()
|
|
||||||
item_sales_bom = get_sales_bom()
|
|
||||||
|
|
||||||
if stock_ledger_entries:
|
|
||||||
for item in self.doclist.get({"parentfield": "delivery_note_details"}):
|
|
||||||
if item.item_code in self.stock_items or \
|
|
||||||
(item_sales_bom and item_sales_bom.get(item.item_code)):
|
|
||||||
buying_amount = get_buying_amount(item.item_code, item.warehouse, -1*item.qty,
|
|
||||||
self.doc.doctype, self.doc.name, item.name, stock_ledger_entries,
|
|
||||||
item_sales_bom)
|
|
||||||
item.buying_amount = buying_amount > 0 and buying_amount or 0
|
|
||||||
webnotes.conn.set_value("Delivery Note Item", item.name, "buying_amount",
|
|
||||||
item.buying_amount)
|
|
||||||
|
|
||||||
self.validate_warehouse()
|
|
||||||
|
|
||||||
def validate_warehouse(self):
|
|
||||||
for d in self.get_item_list():
|
|
||||||
if webnotes.conn.get_value("Item", d['item_code'], "is_stock_item") == "Yes":
|
|
||||||
if not d['warehouse']:
|
|
||||||
msgprint("Please enter Warehouse for item %s as it is stock item"
|
|
||||||
% d['item_code'], raise_exception=1)
|
|
||||||
|
|
||||||
def make_gl_entries(self):
|
def make_gl_entries(self):
|
||||||
if not cint(webnotes.defaults.get_global_default("auto_inventory_accounting")):
|
if not cint(webnotes.defaults.get_global_default("auto_inventory_accounting")):
|
||||||
return
|
return
|
||||||
|
|
||||||
against_stock_account = self.get_default_account("stock_delivered_but_not_billed")
|
gl_entries = []
|
||||||
total_buying_amount = self.get_total_buying_amount()
|
for item in self.doclist.get({"parentfield": "delivery_note_details"}):
|
||||||
|
self.check_expense_account(item)
|
||||||
|
|
||||||
super(DocType, self).make_gl_entries(against_stock_account, -1*total_buying_amount)
|
gl_entries += self.get_gl_entries_for_stock(item.expense_account, -1*item.buying_amount,
|
||||||
|
cost_center=item.cost_center)
|
||||||
|
|
||||||
def get_total_buying_amount(self):
|
if gl_entries:
|
||||||
total_buying_amount = sum([item.buying_amount for item in
|
from accounts.general_ledger import make_gl_entries
|
||||||
self.doclist.get({"parentfield": "delivery_note_details"})])
|
make_gl_entries(gl_entries)
|
||||||
return total_buying_amount
|
|
@ -56,6 +56,9 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
self._insert_purchase_receipt()
|
self._insert_purchase_receipt()
|
||||||
|
|
||||||
dn = webnotes.bean(copy=test_records[0])
|
dn = webnotes.bean(copy=test_records[0])
|
||||||
|
dn.doclist[1].expense_account = "Cost of Goods Sold - _TC"
|
||||||
|
dn.doclist[1].cost_center = "Auto Inventory Accounting - _TC"
|
||||||
|
|
||||||
stock_in_hand_account = webnotes.conn.get_value("Company", dn.doc.company,
|
stock_in_hand_account = webnotes.conn.get_value("Company", dn.doc.company,
|
||||||
"stock_in_hand_account")
|
"stock_in_hand_account")
|
||||||
|
|
||||||
@ -65,6 +68,7 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
dn.insert()
|
dn.insert()
|
||||||
dn.submit()
|
dn.submit()
|
||||||
|
|
||||||
|
|
||||||
gl_entries = webnotes.conn.sql("""select account, debit, credit
|
gl_entries = webnotes.conn.sql("""select account, debit, credit
|
||||||
from `tabGL Entry` where voucher_type='Delivery Note' and voucher_no=%s
|
from `tabGL Entry` where voucher_type='Delivery Note' and voucher_no=%s
|
||||||
order by account asc""", dn.doc.name, as_dict=1)
|
order by account asc""", dn.doc.name, as_dict=1)
|
||||||
@ -72,9 +76,8 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
|
|
||||||
expected_values = sorted([
|
expected_values = sorted([
|
||||||
[stock_in_hand_account, 0.0, 375.0],
|
[stock_in_hand_account, 0.0, 375.0],
|
||||||
["Stock Delivered But Not Billed - _TC", 375.0, 0.0]
|
["Cost of Goods Sold - _TC", 375.0, 0.0]
|
||||||
])
|
])
|
||||||
|
|
||||||
for i, gle in enumerate(gl_entries):
|
for i, gle in enumerate(gl_entries):
|
||||||
self.assertEquals(expected_values[i][0], gle.account)
|
self.assertEquals(expected_values[i][0], gle.account)
|
||||||
self.assertEquals(expected_values[i][1], gle.debit)
|
self.assertEquals(expected_values[i][1], gle.debit)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-03-07 11:42:59",
|
"creation": "2013-03-07 11:42:59",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-03-07 15:46:43",
|
"modified": "2013-03-21 18:36:22",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -236,6 +236,7 @@
|
|||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "batch_no",
|
"fieldname": "batch_no",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"hidden": 0,
|
||||||
"label": "Batch No",
|
"label": "Batch No",
|
||||||
"oldfieldname": "batch_no",
|
"oldfieldname": "batch_no",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
@ -243,6 +244,28 @@
|
|||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 0
|
"read_only": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "expense_account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Expense Account",
|
||||||
|
"no_copy": 1,
|
||||||
|
"options": "Account",
|
||||||
|
"print_hide": 1,
|
||||||
|
"width": "120px"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "cost_center",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "Cost Center",
|
||||||
|
"no_copy": 1,
|
||||||
|
"options": "Cost Center",
|
||||||
|
"print_hide": 1,
|
||||||
|
"width": "120px"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "item_group",
|
"fieldname": "item_group",
|
||||||
|
@ -318,10 +318,14 @@ class DocType(BuyingController):
|
|||||||
if not cint(webnotes.defaults.get_global_default("auto_inventory_accounting")):
|
if not cint(webnotes.defaults.get_global_default("auto_inventory_accounting")):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
from accounts.general_ledger import make_gl_entries
|
||||||
|
|
||||||
against_stock_account = self.get_default_account("stock_received_but_not_billed")
|
against_stock_account = self.get_default_account("stock_received_but_not_billed")
|
||||||
total_valuation_amount = self.get_total_valuation_amount()
|
total_valuation_amount = self.get_total_valuation_amount()
|
||||||
|
gl_entries = self.get_gl_entries_for_stock(against_stock_account, total_valuation_amount)
|
||||||
|
|
||||||
super(DocType, self).make_gl_entries(against_stock_account, total_valuation_amount)
|
if gl_entries:
|
||||||
|
make_gl_entries(gl_entries, cancel=self.doc.docstatus == 2)
|
||||||
|
|
||||||
def get_total_valuation_amount(self):
|
def get_total_valuation_amount(self):
|
||||||
total_valuation_amount = 0.0
|
total_valuation_amount = 0.0
|
||||||
|
@ -174,11 +174,15 @@ class DocType(StockController):
|
|||||||
if not self.doc.expense_adjustment_account:
|
if not self.doc.expense_adjustment_account:
|
||||||
webnotes.msgprint(_("Please enter Expense/Adjustment Account"), raise_exception=1)
|
webnotes.msgprint(_("Please enter Expense/Adjustment Account"), raise_exception=1)
|
||||||
|
|
||||||
|
from accounts.general_ledger import make_gl_entries
|
||||||
|
|
||||||
cost_center = "Auto Inventory Accounting - %s" % (self.company_abbr,)
|
cost_center = "Auto Inventory Accounting - %s" % (self.company_abbr,)
|
||||||
total_valuation_amount = self.get_total_valuation_amount()
|
total_valuation_amount = self.get_total_valuation_amount()
|
||||||
|
|
||||||
super(DocType, self).make_gl_entries(self.doc.expense_adjustment_account,
|
gl_entries = self.get_gl_entries_for_stock(self.doc.expense_adjustment_account,
|
||||||
total_valuation_amount, cost_center)
|
total_valuation_amount, cost_center=cost_center)
|
||||||
|
if gl_entries:
|
||||||
|
make_gl_entries(gl_entries, cancel=self.doc.docstatus == 2)
|
||||||
|
|
||||||
def get_total_valuation_amount(self):
|
def get_total_valuation_amount(self):
|
||||||
total_valuation_amount = 0
|
total_valuation_amount = 0
|
||||||
|
@ -26,7 +26,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertTrue(mr_name)
|
self.assertTrue(mr_name)
|
||||||
|
|
||||||
def atest_material_receipt_gl_entry(self):
|
def test_material_receipt_gl_entry(self):
|
||||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||||
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
|
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
|
|
||||||
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
|
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
|
||||||
|
|
||||||
def atest_material_issue_gl_entry(self):
|
def test_material_issue_gl_entry(self):
|
||||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||||
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
|
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
self.assertEquals(expected_sle[i][1], sle.warehouse)
|
self.assertEquals(expected_sle[i][1], sle.warehouse)
|
||||||
self.assertEquals(expected_sle[i][2], sle.actual_qty)
|
self.assertEquals(expected_sle[i][2], sle.actual_qty)
|
||||||
|
|
||||||
def acheck_gl_entries(self, voucher_type, voucher_no, expected_gl_entries):
|
def check_gl_entries(self, voucher_type, voucher_no, expected_gl_entries):
|
||||||
# check gl entries
|
# check gl entries
|
||||||
|
|
||||||
gl_entries = webnotes.conn.sql("""select account, debit, credit
|
gl_entries = webnotes.conn.sql("""select account, debit, credit
|
||||||
|
@ -309,10 +309,14 @@ class DocType(StockController):
|
|||||||
if not self.doc.expense_account:
|
if not self.doc.expense_account:
|
||||||
msgprint(_("Please enter Expense Account"), raise_exception=1)
|
msgprint(_("Please enter Expense Account"), raise_exception=1)
|
||||||
|
|
||||||
|
from accounts.general_ledger import make_gl_entries
|
||||||
|
|
||||||
cost_center = "Auto Inventory Accounting - %s" % (self.company_abbr,)
|
cost_center = "Auto Inventory Accounting - %s" % (self.company_abbr,)
|
||||||
|
|
||||||
super(DocType, self).make_gl_entries(self.doc.expense_account,
|
gl_entries = self.get_gl_entries_for_stock(self.doc.expense_account,
|
||||||
self.doc.stock_value_difference, cost_center)
|
self.doc.stock_value_difference, cost_center=cost_center)
|
||||||
|
if gl_entries:
|
||||||
|
make_gl_entries(gl_entries, cancel=self.doc.docstatus == 2)
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
def upload():
|
def upload():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user