mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 11:49:10 +00:00
Merge branch 'master' of https://github.com/webnotes/erpnext
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-02-22 01:27:40",
|
||||
"creation": "2013-03-08 15:36:47",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-03-07 07:03:29",
|
||||
"modified": "2013-03-22 16:45:28",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "wasim@webnotestech.com"
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"autoname": "PVTD.######",
|
||||
@@ -26,6 +26,17 @@
|
||||
"doctype": "DocType",
|
||||
"name": "Purchase Taxes and Charges"
|
||||
},
|
||||
{
|
||||
"default": "Valuation and Total",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "category",
|
||||
"fieldtype": "Select",
|
||||
"label": "Consider Tax or Charge for",
|
||||
"oldfieldname": "category",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "Valuation and Total\nValuation\nTotal",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "charge_type",
|
||||
@@ -105,17 +116,6 @@
|
||||
"oldfieldname": "row_id",
|
||||
"oldfieldtype": "Data"
|
||||
},
|
||||
{
|
||||
"default": "Valuation and Total",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "category",
|
||||
"fieldtype": "Select",
|
||||
"label": "Consider Tax or Charge for",
|
||||
"oldfieldname": "category",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "Valuation and Total\nValuation\nTotal",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"default": "Add",
|
||||
"doctype": "DocField",
|
||||
|
||||
@@ -27,8 +27,6 @@ from webnotes.model.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import _, msgprint
|
||||
|
||||
from stock.utils import get_buying_amount, get_sales_bom
|
||||
|
||||
session = webnotes.session
|
||||
|
||||
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
|
||||
@@ -701,19 +699,9 @@ class DocType(SellingController):
|
||||
})
|
||||
)
|
||||
|
||||
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")
|
||||
|
||||
def make_item_gl_entries(self, gl_entries):
|
||||
# income account gl entries
|
||||
for item in self.doclist.get({"parentfield": "entries"}):
|
||||
# income account gl entries
|
||||
if flt(item.amount):
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
@@ -725,28 +713,16 @@ class DocType(SellingController):
|
||||
})
|
||||
)
|
||||
|
||||
# expense account gl entries
|
||||
if auto_inventory_accounting and flt(item.buying_amount):
|
||||
# expense account gl entries
|
||||
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)
|
||||
|
||||
gl_entries += self.get_gl_entries_for_stock(item.expense_account,
|
||||
-1*item.buying_amount, cost_center=item.cost_center)
|
||||
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"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):
|
||||
if cint(self.doc.is_pos) and self.doc.cash_bank_account and self.doc.paid_amount:
|
||||
# POS, make payment entries
|
||||
@@ -789,42 +765,6 @@ class DocType(SellingController):
|
||||
"cost_center": self.doc.write_off_cost_center
|
||||
})
|
||||
)
|
||||
|
||||
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):
|
||||
"""Update amended id in C-form"""
|
||||
|
||||
@@ -86,68 +86,6 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
|
||||
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):
|
||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
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)
|
||||
|
||||
|
||||
|
||||
def _insert_purchase_receipt(self):
|
||||
from stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
||||
as pr_test_records
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-03-07 11:42:55",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-03-18 15:41:19",
|
||||
"modified": "2013-03-21 18:35:47",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -207,11 +207,10 @@
|
||||
"width": "120px"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:sys_defaults.auto_inventory_accounting",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "expense_account",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"hidden": 1,
|
||||
"in_filter": 1,
|
||||
"label": "Expense Account",
|
||||
"options": "Account",
|
||||
|
||||
Reference in New Issue
Block a user