mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 12:49:10 +00:00
aii: stock reconciliation with test case
This commit is contained in:
@@ -207,4 +207,4 @@ def get_parent_account(doctype, txt, searchfield, start, page_len, filters):
|
||||
where group_or_ledger = 'Group' and docstatus != 2 and company = %s
|
||||
and %s like %s order by name limit %s, %s""" %
|
||||
("%s", searchfield, "%s", "%s", "%s"),
|
||||
(filters["company"], "%%%s%%" % txt, start, page_len), as_list=1)
|
||||
(filters["company"], "%%%s%%" % txt, start, page_len), as_list=1)
|
||||
@@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-01-10 16:34:06",
|
||||
"creation": "2013-01-22 16:50:25",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-01-22 14:46:59",
|
||||
"modified": "2013-03-13 12:29:40",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -23,7 +23,6 @@
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
@@ -42,22 +41,6 @@
|
||||
"doctype": "DocType",
|
||||
"name": "Fiscal Year"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "year_details",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Fiscal Year Details",
|
||||
"oldfieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "trash_reason",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Trash Reason",
|
||||
"oldfieldname": "trash_reason",
|
||||
"oldfieldtype": "Small Text",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"description": "For e.g. 2012, 2012-13",
|
||||
"doctype": "DocField",
|
||||
@@ -73,6 +56,7 @@
|
||||
"fieldname": "year_start_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Year Start Date",
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "year_start_date",
|
||||
"oldfieldtype": "Date",
|
||||
"reqd": 1
|
||||
@@ -84,6 +68,7 @@
|
||||
"fieldname": "is_fiscal_year_closed",
|
||||
"fieldtype": "Select",
|
||||
"label": "Year Closed",
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "is_fiscal_year_closed",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "\nNo\nYes",
|
||||
|
||||
@@ -238,8 +238,11 @@ cur_frm.cscript.expense_head = function(doc, cdt, cdn){
|
||||
refresh_field('entries');
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['entries'].grid.get_field("cost_center").get_query = function(doc) {
|
||||
return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.docstatus != 2 ORDER BY `tabCost Center`.`name` ASC LIMIT 50';
|
||||
cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = function(doc) {
|
||||
return {
|
||||
query: "accounts.utils.get_cost_center_list",
|
||||
filters: { company_name: doc.company}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.cost_center = function(doc, cdt, cdn){
|
||||
|
||||
@@ -271,8 +271,6 @@ cur_frm.cscript.is_opening = function(doc, dt, dn) {
|
||||
if (doc.is_opening == 'Yes') unhide_field('aging_date');
|
||||
}
|
||||
|
||||
/* **************************** TRIGGERS ********************************** */
|
||||
|
||||
// Get Items based on SO or DN Selected
|
||||
cur_frm.cscript.get_items = function(doc, dt, dn) {
|
||||
var callback = function(r,rt) {
|
||||
@@ -371,6 +369,18 @@ cur_frm.set_query("income_account", "entries", function(doc) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE (tabAccount.debit_or_credit="Credit" OR tabAccount.account_type = "Income Account") AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"';
|
||||
})
|
||||
|
||||
// expense account
|
||||
cur_frm.fields_dict['entries'].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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// warehouse in detail table
|
||||
//----------------------------
|
||||
cur_frm.fields_dict['entries'].grid.get_field('warehouse').get_query= function(doc, cdt, cdn) {
|
||||
@@ -380,8 +390,11 @@ cur_frm.fields_dict['entries'].grid.get_field('warehouse').get_query= function(d
|
||||
|
||||
// Cost Center in Details Table
|
||||
// -----------------------------
|
||||
cur_frm.fields_dict.entries.grid.get_field("cost_center").get_query = function(doc) {
|
||||
return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY `tabCost Center`.`name` ASC LIMIT 50';
|
||||
cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = function(doc) {
|
||||
return {
|
||||
query: "accounts.utils.get_cost_center_list",
|
||||
filters: { company_name: doc.company}
|
||||
}
|
||||
}
|
||||
|
||||
// Sales Order
|
||||
|
||||
@@ -804,8 +804,9 @@ class DocType(SellingController):
|
||||
item_buying_amount = 0
|
||||
if stock_ledger_entries:
|
||||
# is pos and update stock
|
||||
item_buying_amount = get_buying_amount(item.item_code, item.warehouse, item.qty,
|
||||
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,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-03-07 11:42:55",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-03-11 14:58:50",
|
||||
"modified": "2013-03-18 15:41:19",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -207,14 +207,16 @@
|
||||
"width": "120px"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:sys_defaults.auto_inventory_accounting",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "expense_account",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 1,
|
||||
"hidden": 0,
|
||||
"in_filter": 1,
|
||||
"label": "Expense Account",
|
||||
"options": "Account",
|
||||
"print_hide": 1
|
||||
"print_hide": 1,
|
||||
"width": "120px"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
|
||||
@@ -24,8 +24,10 @@ def execute(filters=None):
|
||||
data = []
|
||||
for row in delivery_note_items:
|
||||
selling_amount = flt(row.amount)
|
||||
buying_amount = get_buying_amount(row.item_code, row.warehouse,
|
||||
row.qty, "Delivery Note", row.name, row.item_row, stock_ledger_entries, item_sales_bom)
|
||||
buying_amount = get_buying_amount(row.item_code, row.warehouse, -1*row.qty,
|
||||
"Delivery Note", row.name, row.item_row, stock_ledger_entries, item_sales_bom)
|
||||
buying_amount = buying_amount > 0 and buying_amount or 0
|
||||
|
||||
if selling_amount:
|
||||
gross_profit = selling_amount - buying_amount
|
||||
gross_profit_percent = (gross_profit / selling_amount) * 100.0
|
||||
|
||||
Reference in New Issue
Block a user