fixed conflict and aii check in global defaults

This commit is contained in:
Nabin Hait
2013-03-28 15:54:11 +05:30
21 changed files with 595 additions and 494 deletions

View File

@@ -1,8 +1,8 @@
[
{
"creation": "2013-03-25 11:55:16",
"creation": "2013-03-26 11:03:09",
"docstatus": 0,
"modified": "2013-03-25 15:43:04",
"modified": "2013-03-28 15:42:41",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -248,7 +248,7 @@
"doctype": "DocField",
"fieldname": "expense_account",
"fieldtype": "Link",
"hidden": 1,
"hidden": 0,
"label": "Expense Account",
"no_copy": 1,
"options": "Account",
@@ -260,11 +260,12 @@
"doctype": "DocField",
"fieldname": "cost_center",
"fieldtype": "Link",
"hidden": 1,
"hidden": 0,
"label": "Cost Center",
"no_copy": 1,
"options": "Cost Center",
"print_hide": 1,
"read_only": 0,
"width": "120px"
},
{

View File

@@ -24,7 +24,8 @@ class TestMaterialRequest(unittest.TestCase):
"doctype": "Stock Entry",
"posting_date": "2013-03-01",
"posting_time": "00:00:00",
"purpose": "Material Receipt"
"purpose": "Material Receipt",
"fiscal_year": "_Test Fiscal Year 2013",
},
{
"conversion_factor": 1.0,
@@ -125,7 +126,8 @@ class TestMaterialRequest(unittest.TestCase):
["Material Request Item", "Stock Entry Detail"]], mr.doc.name)
se_doclist[0].fields.update({
"posting_date": "2013-03-01",
"posting_time": "01:00"
"posting_time": "01:00",
"fiscal_year": "_Test Fiscal Year 2013",
})
se_doclist[1].fields.update({
"qty": 27.0,
@@ -186,7 +188,8 @@ class TestMaterialRequest(unittest.TestCase):
["Material Request Item", "Stock Entry Detail"]], mr.doc.name)
se_doclist[0].fields.update({
"posting_date": "2013-03-01",
"posting_time": "00:00"
"posting_time": "00:00",
"fiscal_year": "_Test Fiscal Year 2013",
})
se_doclist[1].fields.update({
"qty": 60.0,
@@ -239,7 +242,8 @@ class TestMaterialRequest(unittest.TestCase):
["Material Request Item", "Stock Entry Detail"]], mr.doc.name)
se_doclist[0].fields.update({
"posting_date": "2013-03-01",
"posting_time": "00:00"
"posting_time": "00:00",
"fiscal_year": "_Test Fiscal Year 2013",
})
se_doclist[1].fields.update({
"qty": 60.0,

View File

@@ -170,9 +170,10 @@ def get_buying_amount(item_code, warehouse, qty, voucher_type, voucher_no, vouch
# sales bom item
buying_amount = 0.0
for bom_item in item_sales_bom[item_code]:
buying_amount += _get_buying_amount(voucher_type, voucher_no, "[** No Item Row **]",
bom_item.item_code, bom_item.warehouse or warehouse,
bom_item.total_qty or (bom_item.qty * qty), stock_ledger_entries)
if bom_item.get("parent_detail_docname")==voucher_detail_no:
buying_amount += _get_buying_amount(voucher_type, voucher_no, "[** No Item Row **]",
bom_item.item_code, bom_item.warehouse or warehouse,
bom_item.total_qty or (bom_item.qty * qty), stock_ledger_entries)
return buying_amount
else:
# doesn't have sales bom
@@ -181,13 +182,16 @@ def get_buying_amount(item_code, warehouse, qty, voucher_type, voucher_no, vouch
def _get_buying_amount(voucher_type, voucher_no, item_row, item_code, warehouse, qty,
stock_ledger_entries):
for i, sle in enumerate(stock_ledger_entries):
relevant_stock_ledger_entries = [sle for sle in stock_ledger_entries
if sle.item_code == item_code and sle.warehouse == warehouse]
for i, sle in enumerate(relevant_stock_ledger_entries):
if sle.voucher_type == voucher_type and sle.voucher_no == voucher_no and \
(sle.voucher_detail_no == item_row or (sle.voucher_type != "Stock Reconciliation"
and sle.item_code == item_code and sle.warehouse == warehouse and flt(sle.qty) == qty)):
previous_stock_value = len(stock_ledger_entries) > i+1 and \
flt(stock_ledger_entries[i+1].stock_value) or 0.0
((sle.voucher_detail_no == item_row) or (sle.voucher_type != "Stock Reconciliation"
and flt(sle.qty) == qty)):
previous_stock_value = len(relevant_stock_ledger_entries) > i+1 and \
flt(relevant_stock_ledger_entries[i+1].stock_value) or 0.0
buying_amount = previous_stock_value - flt(sle.stock_value)
return buying_amount