Merge branch 'master' of github.com:webnotes/erpnext into responsive

Conflicts:
	patches/december_2012/deprecate_tds.py
	patches/june_2012/reports_list_permission.py
	selling/doctype/sales_bom/locale/_messages_doc.json
	selling/doctype/sales_bom/locale/ar-doc.json
	selling/doctype/sales_bom/locale/de-doc.json
	selling/doctype/sales_bom/locale/es-doc.json
	selling/doctype/sales_bom/locale/fr-doc.json
	selling/doctype/sales_bom/locale/hi-doc.json
	selling/doctype/sales_bom/locale/hr-doc.json
	selling/doctype/sales_bom/locale/nl-doc.json
	selling/doctype/sales_bom/locale/pt-BR-doc.json
	selling/doctype/sales_bom/locale/pt-doc.json
	selling/doctype/sales_bom/locale/sr-doc.json
	selling/doctype/sales_bom/locale/ta-doc.json
	selling/doctype/sales_bom/locale/th-doc.json
	selling/doctype/sales_bom_item/locale/_messages_doc.json
	selling/doctype/sales_bom_item/locale/ar-doc.json
	selling/doctype/sales_bom_item/locale/de-doc.json
	selling/doctype/sales_bom_item/locale/es-doc.json
	selling/doctype/sales_bom_item/locale/fr-doc.json
	selling/doctype/sales_bom_item/locale/hi-doc.json
	selling/doctype/sales_bom_item/locale/hr-doc.json
	selling/doctype/sales_bom_item/locale/nl-doc.json
	selling/doctype/sales_bom_item/locale/pt-BR-doc.json
	selling/doctype/sales_bom_item/locale/pt-doc.json
	selling/doctype/sales_bom_item/locale/sr-doc.json
	selling/doctype/sales_bom_item/locale/ta-doc.json
	selling/doctype/sales_bom_item/locale/th-doc.json
This commit is contained in:
Anand Doshi
2013-06-26 14:07:29 +05:30
30 changed files with 273 additions and 214 deletions

View File

@@ -232,7 +232,6 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
grouped_ledgers[item.account].totals.debit += item.debit;
grouped_ledgers[item.account].totals.credit += item.credit;
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
.totals.debit += item.debit;
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
@@ -248,8 +247,8 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
grouped_ledgers[item.account].entries.push(item);
if(grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no].row){
grouped_ledgers[item.account].
entries_group_by_voucher[item.voucher_no].row = item;
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
.row = jQuery.extend({}, item);
}
}
}
@@ -320,13 +319,14 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
var out = []
$.each(Object.keys(grouped_ledgers).sort(), function(i, account) {
if(grouped_ledgers[account].entries.length) {
$.each(Object.keys(grouped_ledgers[account].entries_group_by_voucher).sort(),
function(j, voucher) {
$.each(Object.keys(grouped_ledgers[account].entries_group_by_voucher),
function(j, voucher) {
voucher_dict = grouped_ledgers[account].entries_group_by_voucher[voucher];
if(voucher_dict.totals.debit || voucher_dict.totals.credit) {
if(voucher_dict &&
(voucher_dict.totals.debit || voucher_dict.totals.credit)) {
voucher_dict.row.debit = voucher_dict.totals.debit;
voucher_dict.row.credit = voucher_dict.totals.credit;
voucher_dict.row.id = "entry" + voucher
voucher_dict.row.id = "entry_grouped_by_" + voucher
out = out.concat(voucher_dict.row);
}
});

View File

@@ -16,18 +16,21 @@
from __future__ import unicode_literals
import webnotes
import calendar
from webnotes import _, msgprint
from webnotes.utils import flt
import time
from accounts.utils import get_fiscal_year
from controllers.trends import get_period_date_ranges, get_period_month_ranges
def execute(filters=None):
if not filters: filters = {}
columns = get_columns(filters)
period_month_ranges = get_period_month_ranges(filters)
period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"])
cam_map = get_costcenter_account_month_map(filters)
precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2
data = []
for cost_center, cost_center_items in cam_map.items():
@@ -39,7 +42,7 @@ def execute(filters=None):
for month in relevant_months:
month_data = monthwise_data.get(month, {})
for i, fieldname in enumerate(["target", "actual", "variance"]):
value = flt(month_data.get(fieldname))
value = flt(month_data.get(fieldname), precision)
period_data[i] += value
totals[i] += value
period_data[2] = period_data[0] - period_data[1]
@@ -61,7 +64,7 @@ def get_columns(filters):
group_months = False if filters["period"] == "Monthly" else True
for from_date, to_date in get_period_date_ranges(filters):
for from_date, to_date in get_period_date_ranges(filters["period"], filters["fiscal_year"]):
for label in ["Target (%s)", "Actual (%s)", "Variance (%s)"]:
if group_months:
columns.append(label % (from_date.strftime("%b") + " - " + to_date.strftime("%b")))
@@ -70,41 +73,6 @@ def get_columns(filters):
return columns + ["Total Target::80", "Total Actual::80", "Total Variance::80"]
def get_period_date_ranges(filters):
from dateutil.relativedelta import relativedelta
year_start_date, year_end_date = get_year_start_end_date(filters)
increment = {
"Monthly": 1,
"Quarterly": 3,
"Half-Yearly": 6,
"Yearly": 12
}.get(filters["period"])
period_date_ranges = []
for i in xrange(1, 13, increment):
period_end_date = year_start_date + relativedelta(months=increment,
days=-1)
period_date_ranges.append([year_start_date, period_end_date])
year_start_date = period_end_date + relativedelta(days=1)
return period_date_ranges
def get_period_month_ranges(filters):
from dateutil.relativedelta import relativedelta
period_month_ranges = []
for start_date, end_date in get_period_date_ranges(filters):
months_in_this_period = []
while start_date <= end_date:
months_in_this_period.append(start_date.strftime("%B"))
start_date += relativedelta(months=1)
period_month_ranges.append(months_in_this_period)
return period_month_ranges
#Get cost center & target details
def get_costcenter_target_details(filters):
return webnotes.conn.sql("""select cc.name, cc.distribution_id,
@@ -122,7 +90,7 @@ def get_target_distribution_details(filters):
for d in webnotes.conn.sql("""select bdd.month, bdd.percentage_allocation \
from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd, \
`tabCost Center` cc where bdd.parent=bd.name and cc.distribution_id=bd.name and \
bd.fiscal_year=%s""" % ('%s'), (filters.get("fiscal_year")), as_dict=1):
bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
target_details.setdefault(d.month, d)
return target_details
@@ -147,22 +115,16 @@ def get_costcenter_account_month_map(filters):
for month in tdd:
cam_map.setdefault(ccd.name, {}).setdefault(ccd.account, {})\
.setdefault(month, webnotes._dict({
"target": 0.0, "actual": 0.0, "variance": 0.0
"target": 0.0, "actual": 0.0
}))
tav_dict = cam_map[ccd.name][ccd.account][month]
tav_dict.target = ccd.budget_allocated*(tdd[month]["percentage_allocation"]/100)
tav_dict.target = flt(ccd.budget_allocated) * \
(tdd[month]["percentage_allocation"]/100)
for ad in actual_details:
if ad.month_name == month and ad.account == ccd.account \
and ad.cost_center == ccd.name:
tav_dict.actual += ad.debit - ad.credit
return cam_map
def get_year_start_end_date(filters):
return webnotes.conn.sql("""select year_start_date,
subdate(adddate(year_start_date, interval 1 year), interval 1 day)
as year_end_date
from `tabFiscal Year`
where name=%s""", filters["fiscal_year"])[0]
return cam_map

View File

@@ -38,11 +38,12 @@ def execute(filters=None):
data = []
for inv in invoice_list:
# invoice details
purchase_order = ", ".join(invoice_po_pr_map.get(inv.name, {}).get("purchase_order", []))
purchase_receipt = ", ".join(invoice_po_pr_map.get(inv.name, {}).get("purchase_receipt", []))
purchase_order = list(set(invoice_po_pr_map.get(inv.name, {}).get("purchase_order", [])))
purchase_receipt = list(set(invoice_po_pr_map.get(inv.name, {}).get("purchase_receipt", [])))
row = [inv.name, inv.posting_date, inv.supplier, inv.credit_to,
account_map.get(inv.credit_to), inv.project_name, inv.bill_no, inv.bill_date,
inv.remarks, purchase_order, purchase_receipt]
inv.remarks, ", ".join(purchase_order), ", ".join(purchase_receipt)]
# map expense values
for expense_acc in expense_accounts:
@@ -55,8 +56,9 @@ def execute(filters=None):
for tax_acc in tax_accounts:
row.append(invoice_tax_map.get(inv.name, {}).get(tax_acc))
# total tax, grand total
row += [inv.total_tax, inv.grand_total]
# total tax, grand total, outstanding amount & rounded total
row += [inv.other_charges_total, inv.grand_total, flt(inv.grand_total, 2), \
inv.outstanding_amount]
data.append(row)
return columns, data
@@ -85,7 +87,8 @@ def get_columns(invoice_list):
columns = columns + [(account + ":Currency:120") for account in expense_accounts] + \
["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \
["Total Tax:Currency:120"] + ["Grand Total:Currency:120"]
["Total Tax:Currency:120"] + ["Grand Total:Currency:120"] + \
["Rounded Total:Currency:120"] + ["Outstanding Amount:Currency:120"]
return columns, expense_accounts, tax_accounts
@@ -102,9 +105,11 @@ def get_conditions(filters):
def get_invoices(filters):
conditions = get_conditions(filters)
return webnotes.conn.sql("""select name, posting_date, credit_to, project_name, supplier,
bill_no, bill_date, remarks, net_total, total_tax, grand_total
from `tabPurchase Invoice` where docstatus = 1 %s
return webnotes.conn.sql("""select pi.name, pi.posting_date, pi.credit_to,
pii.project_name, pi.supplier, pi.bill_no, pi.bill_date, pi.remarks, pi.net_total,
pi.total_tax, pi.grand_total, pi.outstanding_amount
from `tabPurchase Invoice` pi, `tabPurchase Invoice Item` pii
where pii.parent = pi.name and pi.docstatus = 1 %s
order by posting_date desc, name desc""" % conditions, filters, as_dict=1)

View File

@@ -39,12 +39,12 @@ def execute(filters=None):
data = []
for inv in invoice_list:
# invoice details
sales_order = ", ".join(invoice_so_dn_map.get(inv.name, {}).get("sales_order", []))
delivery_note = ", ".join(invoice_so_dn_map.get(inv.name, {}).get("delivery_note", []))
sales_order = list(set(invoice_so_dn_map.get(inv.name, {}).get("sales_order", [])))
delivery_note = list(set(invoice_so_dn_map.get(inv.name, {}).get("delivery_note", [])))
row = [inv.name, inv.posting_date, inv.customer, inv.debit_to,
account_map.get(inv.debit_to), customer_map.get(inv.customer), inv.project_name,
inv.remarks, sales_order, delivery_note]
inv.remarks, ", ".join(sales_order), ", ".join(delivery_note)]
# map income values
for income_acc in income_accounts:
@@ -57,8 +57,8 @@ def execute(filters=None):
for tax_acc in tax_accounts:
row.append(invoice_tax_map.get(inv.name, {}).get(tax_acc))
# total tax, grand total
row += [inv.other_charges_total, inv.grand_total]
# total tax, grand total, outstanding amount & rounded total
row += [inv.other_charges_total, inv.grand_total, inv.rounded_total, inv.outstanding_amount]
data.append(row)
@@ -88,7 +88,8 @@ def get_columns(invoice_list):
columns = columns + [(account + ":Currency:120") for account in income_accounts] + \
["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \
["Total Tax:Currency:120"] + ["Grand Total:Currency:120"]
["Total Tax:Currency:120"] + ["Grand Total:Currency:120"] + \
["Rounded Total:Currency:120"] + ["Outstanding Amount:Currency:120"]
return columns, income_accounts, tax_accounts
@@ -106,7 +107,8 @@ def get_conditions(filters):
def get_invoices(filters):
conditions = get_conditions(filters)
return webnotes.conn.sql("""select name, posting_date, debit_to, project_name, customer,
remarks, net_total, other_charges_total, grand_total from `tabSales Invoice`
remarks, net_total, other_charges_total, grand_total, rounded_total,
outstanding_amount from `tabSales Invoice`
where docstatus = 1 %s order by posting_date desc, name desc""" %
conditions, filters, as_dict=1)