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

Conflicts:
	stock/doctype/purchase_receipt/purchase_receipt.js
This commit is contained in:
Rushabh Mehta 2013-07-15 20:57:26 +02:00
commit 2861e25fb8
694 changed files with 8668 additions and 10570 deletions

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2010-08-08 17:09:35",
"modified_by": "Administrator",
"modified": "2012-04-03 12:49:50"
"modified": "2013-07-04 12:49:50"
},
{
"name": "__common__",
@ -120,4 +120,4 @@
"to_table": "Purchase Taxes and Charges",
"validation_logic": "docstatus =1"
}
]
]

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2010-08-08 17:09:35",
"modified_by": "Administrator",
"modified": "2012-04-03 12:49:50"
"modified": "2013-07-04 12:49:50"
},
{
"name": "__common__",
@ -141,4 +141,4 @@
"to_table": "Purchase Taxes and Charges",
"validation_logic": "docstatus=1"
}
]
]

View File

@ -187,7 +187,7 @@ class DocType:
sql("""delete from `tabGL Entry` where account = %s and
ifnull(is_cancelled, 'No') = 'Yes'""", self.doc.name)
def on_rename(self, new, old):
def on_rename(self, new, old, merge=False):
company_abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
parts = new.split(" - ")

View File

@ -66,6 +66,6 @@ class DocType:
vouchers.append(d.voucher_id)
if vouchers:
msgprint("Clearance Date updated in %s" % vouchers)
msgprint("Clearance Date updated in %s" % ", ".join(vouchers))
else:
msgprint("Clearance Date not mentioned")

View File

@ -17,16 +17,12 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt, getdate
from webnotes.model.doc import make_autoname
from webnotes.model.bean import getlist
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series + '.#####')
def validate(self):
"""Validate invoice that c-form is applicable
and no other c-form is received for that"""

View File

@ -1,6 +1,6 @@
[
{
"creation": "2013-01-30 12:49:46",
"creation": "2013-03-07 14:48:29",
"docstatus": 0,
"modified": "2013-02-13 11:29:18",
"modified_by": "Administrator",
@ -24,17 +24,13 @@
"permlevel": 0
},
{
"create": 1,
"doctype": "DocPerm",
"name": "__common__",
"parent": "C-Form",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1,
"submit": 0,
"write": 1
"submit": 0
},
{
"doctype": "DocType",
@ -156,15 +152,6 @@
"print_hide": 0,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "file_list",
"fieldtype": "Text",
"hidden": 1,
"label": "File List",
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "amended_from",
@ -176,11 +163,28 @@
"read_only": 1
},
{
"create": 1,
"doctype": "DocPerm",
"role": "Accounts User"
"permlevel": 0,
"report": 1,
"role": "Accounts User",
"write": 1
},
{
"create": 1,
"doctype": "DocPerm",
"role": "Accounts Manager"
"permlevel": 0,
"report": 1,
"role": "Accounts Manager",
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"role": "All"
}
]

View File

@ -29,7 +29,7 @@ class DocType(DocTypeNestedSet):
def autoname(self):
company_abbr = webnotes.conn.sql("select abbr from tabCompany where name=%s",
self.doc.company_name)[0][0]
self.doc.name = self.doc.cost_center_name + ' - ' + company_abbr
self.doc.name = self.doc.cost_center_name.strip() + ' - ' + company_abbr
def validate_mandatory(self):
if not self.doc.group_or_ledger:
@ -81,13 +81,13 @@ class DocType(DocTypeNestedSet):
"""
Cost Center name must be unique
"""
if (self.doc.__islocal or not self.doc.name) and webnotes.conn.sql("select name from `tabCost Center` where cost_center_name = %s and company_name=%s", (self.doc.cost_center_name, self.doc.company_name)):
if (self.doc.fields.get("__islocal") or not self.doc.name) and webnotes.conn.sql("select name from `tabCost Center` where cost_center_name = %s and company_name=%s", (self.doc.cost_center_name, self.doc.company_name)):
msgprint("Cost Center Name already exists, please rename", raise_exception=1)
self.validate_mandatory()
self.validate_budget_details()
def on_rename(self, new, old):
def on_rename(self, new, old, merge=False):
company_abbr = webnotes.conn.get_value("Company", self.doc.company_name, "abbr")
parts = new.split(" - ")

View File

@ -42,9 +42,9 @@ class DocType:
self.check_negative_balance(adv_adj)
# Update outstanding amt on against voucher
if self.doc.against_voucher and self.doc.against_voucher_type not in \
('Journal Voucher','POS') and update_outstanding == 'Yes':
self.update_outstanding_amt()
if self.doc.against_voucher and self.doc.against_voucher_type != "POS" \
and update_outstanding == 'Yes':
self.update_outstanding_amt()
def check_mandatory(self):
mandatory = ['account','remarks','voucher_type','voucher_no','fiscal_year','company']
@ -108,8 +108,8 @@ class DocType:
and not 'Accounts Manager' in webnotes.user.get_roles():
msgprint(_("Account") + ": " + self.doc.account + _(" has been freezed. \
Only Accounts Manager can do transaction against this account"), raise_exception=1)
if ret and ret[0]["company"] != self.doc.company:
if self.doc.is_cancelled in ("No", None) and ret and ret[0]["company"] != self.doc.company:
msgprint(_("Account") + ": " + self.doc.account + _(" does not belong to the company") \
+ ": " + self.doc.company, raise_exception=1)
@ -124,9 +124,10 @@ class DocType:
return self.cost_center_company[self.doc.cost_center]
if self.doc.cost_center and _get_cost_center_company() != self.doc.company:
msgprint(_("Cost Center") + ": " + self.doc.cost_center \
+ _(" does not belong to the company") + ": " + self.doc.company, raise_exception=True)
if self.doc.is_cancelled in ("No", None) and \
self.doc.cost_center and _get_cost_center_company() != self.doc.company:
msgprint(_("Cost Center") + ": " + self.doc.cost_center \
+ _(" does not belong to the company") + ": " + self.doc.company, raise_exception=True)
def check_freezing_date(self, adv_adj):
"""
@ -159,20 +160,29 @@ class DocType:
def update_outstanding_amt(self):
# get final outstanding amt
bal = flt(sql("""select sum(debit) - sum(credit) from `tabGL Entry`
where against_voucher=%s and against_voucher_type=%s
and ifnull(is_cancelled,'No') = 'No'""",
(self.doc.against_voucher, self.doc.against_voucher_type))[0][0] or 0.0)
if self.doc.against_voucher_type=='Purchase Invoice':
# amount to debit
where against_voucher=%s and against_voucher_type=%s and account = %s
and ifnull(is_cancelled,'No') = 'No'""", (self.doc.against_voucher,
self.doc.against_voucher_type, self.doc.account))[0][0] or 0.0)
if self.doc.against_voucher_type == 'Purchase Invoice':
bal = -bal
elif self.doc.against_voucher_type == "Journal Voucher":
against_voucher_amount = flt(webnotes.conn.sql("""select sum(debit) - sum(credit)
from `tabGL Entry` where voucher_type = 'Journal Voucher' and voucher_no = %s
and account = %s""", (self.doc.against_voucher, self.doc.account))[0][0])
bal = against_voucher_amount + bal
if against_voucher_amount < 0:
bal = -bal
# Validation : Outstanding can not be negative
if bal < 0 and self.doc.is_cancelled == 'No':
msgprint(_("Outstanding for Voucher ") + self.doc.against_voucher +
_(" will become ") + fmt_money(bal) + _("Outstanding cannot be less than zero. \
_(" will become ") + fmt_money(bal) + _(". Outstanding cannot be less than zero. \
Please match exact outstanding."), raise_exception=1)
# Update outstanding amt on against voucher
sql("update `tab%s` set outstanding_amount=%s where name='%s'"%
(self.doc.against_voucher_type, bal, self.doc.against_voucher))
if self.doc.against_voucher_type in ["Sales Invoice", "Purchase Invoice"]:
sql("update `tab%s` set outstanding_amount=%s where name='%s'"%
(self.doc.against_voucher_type, bal, self.doc.against_voucher))

View File

@ -34,15 +34,12 @@ class DocType(AccountsController):
self.credit_days_global = -1
self.is_approving_authority = -1
def autoname(self):
if not self.doc.naming_series:
webnotes.msgprint("""Naming Series is mandatory""", raise_exception=1)
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
def validate(self):
if not self.doc.is_opening:
self.doc.is_opening='No'
self.doc.clearance_date = None
self.validate_debit_credit()
self.validate_cheque_info()
self.validate_entries_for_advance()

View File

@ -122,119 +122,4 @@ test_records = [
"parentfield": "entries",
"cost_center": "_Test Cost Center - _TC"
}],
]
#
#
# import webnotes.model
# from webnotes.utils import nowdate, flt, add_days
# from accounts.utils import get_fiscal_year, get_balance_on
#
# company = webnotes.conn.get_default("company")
# abbr = webnotes.conn.get_value("Company", company, "abbr")
#
# data = {
# "expense_account": {
# "doctype": "Account",
# "account_name": "Test Expense",
# "parent_account": "Direct Expenses - %s" % abbr,
# "company": company,
# "debit_or_credit": "Debit",
# "is_pl_account": "Yes",
# "group_or_ledger": "Ledger"
# },
# "supplier_account": {
# "doctype": "Account",
# "account_name": "Test Supplier",
# "parent_account": "Accounts Payable - %s" % abbr,
# "company": company,
# "debit_or_credit": "Credit",
# "is_pl_account": "No",
# "group_or_ledger": "Ledger"
# },
# "test_cost_center": {
# "doctype": "Cost Center",
# "cost_center_name": "Test Cost Center",
# "parent_cost_center": "Root - %s" % abbr,
# "company_name": company,
# "group_or_ledger": "Ledger",
# "company_abbr": abbr
# },
# "journal_voucher": [
# {
# "doctype": "Journal Voucher",
# "voucher_type": "Journal Entry",
# "naming_series": "JV",
# "posting_date": nowdate(),
# "remark": "Test Journal Voucher",
# "fiscal_year": get_fiscal_year(nowdate())[0],
# "company": company
# },
# {
# "doctype": "Journal Voucher Detail",
# "parentfield": "entries",
# "account": "Test Expense - %s" % abbr,
# "debit": 5000,
# "cost_center": "Test Cost Center - %s" % abbr,
# },
# {
# "doctype": "Journal Voucher Detail",
# "parentfield": "entries",
# "account": "Test Supplier - %s" % abbr,
# "credit": 5000,
# },
# ]
# }
#
# def get_name(s):
# return s + " - " + abbr
#
# class TestJournalVoucher(unittest.TestCase):
# def setUp(self):
# webnotes.conn.begin()
#
# # create a dummy account
# webnotes.model.insert([data["expense_account"]])
# webnotes.model.insert([data["supplier_account"]])
# webnotes.model.insert([data["test_cost_center"]])
#
# def tearDown(self):
# webnotes.conn.rollback()
#
# def test_save_journal_voucher(self):
# expense_ac_balance = get_balance_on(get_name("Test Expense"), nowdate())
# supplier_ac_balance = get_balance_on(get_name("Test Supplier"), nowdate())
#
# dl = webnotes.model.insert(data["journal_voucher"])
# dl.submit()
# dl.load_from_db()
#
# # test submitted jv
# self.assertTrue(webnotes.conn.exists("Journal Voucher", dl.doclist[0].name))
# for d in dl.doclist[1:]:
# self.assertEquals(webnotes.conn.get_value("Journal Voucher Detail",
# d.name, "parent"), dl.doclist[0].name)
#
# # test gl entry
# gle = webnotes.conn.sql("""select account, debit, credit
# from `tabGL Entry` where voucher_no = %s order by account""",
# dl.doclist[0].name)
#
# self.assertEquals((gle[0][0], flt(gle[0][1]), flt(gle[0][2])),
# ('Test Expense - %s' % abbr, 5000.0, 0.0))
# self.assertEquals((gle[1][0], flt(gle[1][1]), flt(gle[1][2])),
# ('Test Supplier - %s' % abbr, 0.0, 5000.0))
#
# # check balance as on today
# self.assertEqual(get_balance_on(get_name("Test Expense"), nowdate()),
# expense_ac_balance + 5000)
# self.assertEqual(get_balance_on(get_name("Test Supplier"), nowdate()),
# supplier_ac_balance + 5000)
#
# # check previous balance
# self.assertEqual(get_balance_on(get_name("Test Expense"), add_days(nowdate(), -1)), 0)
]

View File

@ -1,68 +1,68 @@
[
{
"owner": "harshada@webnotestech.com",
"creation": "2012-12-04 17:49:20",
"docstatus": 0,
"creation": "2012-07-03 13:30:49",
"modified": "2013-04-19 10:59:05",
"modified_by": "Administrator",
"modified": "2012-12-04 16:33:37"
"owner": "harshada@webnotestech.com"
},
{
"name": "__common__",
"allow_rename": 1,
"autoname": "field:mode_of_payment",
"module": "Accounts",
"doctype": "DocType",
"document_type": "Master"
"document_type": "Master",
"module": "Accounts",
"name": "__common__"
},
{
"doctype": "DocField",
"name": "__common__",
"parent": "Mode of Payment",
"doctype": "DocField",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0,
"parentfield": "fields"
"read_only": 0
},
{
"parent": "Mode of Payment",
"read": 1,
"doctype": "DocPerm",
"cancel": 1,
"name": "__common__",
"amend": 0,
"create": 1,
"submit": 0,
"write": 1,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Mode of Payment",
"parentfield": "permissions",
"parenttype": "DocType",
"role": "Accounts Manager",
"report": 1,
"permlevel": 0,
"parentfield": "permissions"
"read": 1,
"report": 1,
"role": "Accounts Manager",
"submit": 0,
"write": 1
},
{
"name": "Mode of Payment",
"doctype": "DocType"
"doctype": "DocType",
"name": "Mode of Payment"
},
{
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "Mode of Payment",
"oldfieldname": "mode_of_payment",
"fieldname": "mode_of_payment",
"fieldtype": "Data",
"label": "Mode of Payment",
"oldfieldname": "mode_of_payment",
"oldfieldtype": "Data",
"reqd": 1
},
{
"doctype": "DocField",
"label": "Company",
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
"options": "Company"
},
{
"description": "Default Bank / Cash account will be automatically updated in POS Invoice when this mode is selected.",
"doctype": "DocField",
"label": "Default Account",
"fieldname": "default_account",
"fieldtype": "Link",
"label": "Default Account",
"options": "Account"
},
{

View File

@ -50,6 +50,7 @@ cur_frm.fields_dict.voucher_no.get_query = function(doc) {
where against_voucher_type = '%(dt)s' \
and against_voucher = gle.voucher_no \
and voucher_no != gle.voucher_no \
and account = gle.account \
and ifnull(is_cancelled, 'No') = 'No') != \
abs(ifnull(gle.debit, 0) - ifnull(gle.credit, 0)) \
ORDER BY gle.posting_date DESC, gle.voucher_no DESC LIMIT 50",

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-26 11:03:07",
"creation": "2013-05-09 13:16:11",
"docstatus": 0,
"modified": "2013-03-26 12:48:18",
"modified": "2013-05-23 12:52:09",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -40,6 +40,7 @@
"doctype": "DocField",
"fieldname": "user",
"fieldtype": "Link",
"in_list_view": 1,
"label": "User",
"oldfieldname": "user",
"oldfieldtype": "Link",
@ -99,6 +100,7 @@
"doctype": "DocField",
"fieldname": "company",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Company",
"oldfieldname": "company",
"oldfieldtype": "Link",
@ -211,12 +213,14 @@
"options": "link:Print Heading"
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "System Manager",
"write": 1
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Accounts Manager",

View File

@ -326,7 +326,7 @@ class DocType(BuyingController):
against_accounts.append(stock_not_billed_account)
elif not item.expense_head:
msgprint(_("""Expense account is mandatory for item: """) + item.item_code,
msgprint(_("""Expense account is mandatory for item: """) + (item.item_code or item.item_name),
raise_exception=1)
elif item.expense_head not in against_accounts:
@ -464,15 +464,16 @@ class DocType(BuyingController):
# if auto inventory accounting enabled and stock item,
# then do stock related gl entries
# expense will be booked in sales invoice
stock_item_and_auto_inventory_accounting = True
valuation_amt = (flt(item.amount) + flt(item.item_tax_amount) +
flt(item.rm_supp_cost))
gl_entries.append(
self.get_gl_dict({
"account": stock_account,
"against": self.doc.credit_to,
"debit": flt(item.valuation_rate) * flt(item.conversion_factor) \
* flt(item.qty),
"debit": valuation_amt,
"remarks": self.doc.remarks or "Accounting Entry for Stock"
})
)

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-07 13:16:13",
"creation": "2013-05-07 13:50:30",
"docstatus": 0,
"modified": "2013-03-22 18:17:14",
"modified": "2013-05-13 11:12:56",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -43,6 +43,7 @@
"fieldname": "column_break0",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -56,6 +57,7 @@
"oldfieldtype": "Select",
"options": "BILL\nBILLJ",
"print_hide": 1,
"read_only": 0,
"report_hide": 0,
"reqd": 1
},
@ -70,6 +72,7 @@
"oldfieldtype": "Link",
"options": "Account",
"print_hide": 1,
"read_only": 0,
"reqd": 1,
"search_index": 1
},
@ -82,7 +85,8 @@
"oldfieldname": "supplier",
"oldfieldtype": "Link",
"options": "Supplier",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -133,6 +137,7 @@
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"read_only": 0,
"reqd": 0,
"width": "50%"
},
@ -148,6 +153,7 @@
"oldfieldname": "posting_date",
"oldfieldtype": "Date",
"print_hide": 1,
"read_only": 0,
"reqd": 1,
"search_index": 1
},
@ -161,6 +167,7 @@
"oldfieldname": "bill_no",
"oldfieldtype": "Data",
"print_hide": 1,
"read_only": 0,
"reqd": 1,
"search_index": 1
},
@ -173,6 +180,7 @@
"oldfieldname": "bill_date",
"oldfieldtype": "Date",
"print_hide": 1,
"read_only": 0,
"reqd": 0,
"search_index": 1
},
@ -181,7 +189,8 @@
"fieldname": "items",
"fieldtype": "Section Break",
"label": "Items",
"oldfieldtype": "Section Break"
"oldfieldtype": "Section Break",
"read_only": 0
},
{
"allow_on_submit": 1,
@ -191,25 +200,29 @@
"label": "Entries",
"oldfieldname": "entries",
"oldfieldtype": "Table",
"options": "Purchase Invoice Item"
"options": "Purchase Invoice Item",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "section_break0",
"fieldtype": "Section Break"
"fieldtype": "Section Break",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "recalculate",
"fieldtype": "Button",
"label": "Recalculate",
"oldfieldtype": "Button"
"oldfieldtype": "Button",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "section_break_17",
"fieldtype": "Section Break",
"options": "Simple"
"options": "Simple",
"read_only": 0
},
{
"description": "Select Items from Purchase Order",
@ -220,7 +233,8 @@
"oldfieldname": "purchase_order_main",
"oldfieldtype": "Link",
"options": "Purchase Order",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"description": "Select Items from Purchase Receipt",
@ -231,7 +245,8 @@
"oldfieldname": "purchase_receipt_main",
"oldfieldtype": "Link",
"options": "Purchase Receipt",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -239,13 +254,15 @@
"fieldtype": "Button",
"label": "Get Items",
"oldfieldtype": "Button",
"options": "pull_details"
"options": "pull_details",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "currency_price_list",
"fieldtype": "Section Break",
"label": "Currency & Price List"
"label": "Currency & Price List",
"read_only": 0
},
{
"doctype": "DocField",
@ -255,7 +272,8 @@
"oldfieldname": "currency",
"oldfieldtype": "Select",
"options": "Currency",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"default": "1",
@ -266,12 +284,14 @@
"label": "Exchange Rate",
"oldfieldname": "conversion_rate",
"oldfieldtype": "Currency",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break2",
"fieldtype": "Column Break"
"fieldtype": "Column Break",
"read_only": 0
},
{
"description": "Consider this Price List for fetching rate. (only which have \"For Buying\" as checked)",
@ -280,7 +300,8 @@
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"depends_on": "price_list_name",
@ -289,7 +310,8 @@
"fieldtype": "Link",
"label": "Price List Currency",
"options": "Currency",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"depends_on": "price_list_name",
@ -297,7 +319,8 @@
"fieldname": "plc_conversion_rate",
"fieldtype": "Float",
"label": "Price List Exchange Rate",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"description": "Add / Edit Taxes and Charges",
@ -305,7 +328,8 @@
"fieldname": "taxes",
"fieldtype": "Section Break",
"label": "Taxes",
"oldfieldtype": "Section Break"
"oldfieldtype": "Section Break",
"read_only": 0
},
{
"doctype": "DocField",
@ -315,7 +339,8 @@
"oldfieldname": "purchase_other_charges",
"oldfieldtype": "Link",
"options": "Purchase Taxes and Charges Master",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -324,7 +349,8 @@
"label": "Get Tax Detail",
"oldfieldtype": "Button",
"options": "get_purchase_tax_details",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -333,7 +359,8 @@
"label": "Purchase Taxes and Charges",
"oldfieldname": "purchase_tax_details",
"oldfieldtype": "Table",
"options": "Purchase Taxes and Charges"
"options": "Purchase Taxes and Charges",
"read_only": 0
},
{
"doctype": "DocField",
@ -341,7 +368,8 @@
"fieldtype": "Button",
"label": "Calculate Tax",
"oldfieldtype": "Button",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -349,7 +377,8 @@
"fieldtype": "HTML",
"label": "Tax Calculation",
"oldfieldtype": "HTML",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -366,7 +395,8 @@
"doctype": "DocField",
"fieldname": "contact_section",
"fieldtype": "Section Break",
"label": "Contact Info"
"label": "Contact Info",
"read_only": 0
},
{
"depends_on": "eval:doc.supplier",
@ -374,12 +404,14 @@
"fieldname": "supplier_address",
"fieldtype": "Link",
"label": "Supplier Address",
"options": "Address"
"options": "Address",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "col_break23",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -389,14 +421,16 @@
"fieldtype": "Link",
"label": "Contact Person",
"options": "Contact",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "totals",
"fieldtype": "Section Break",
"label": "Totals",
"oldfieldtype": "Section Break"
"oldfieldtype": "Section Break",
"read_only": 0
},
{
"doctype": "DocField",
@ -499,6 +533,7 @@
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
"read_only": 0,
"width": "50%"
},
{
@ -564,7 +599,8 @@
"label": "Write Off Amount",
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"depends_on": "eval:flt(doc.write_off_amount)!=0",
@ -574,7 +610,8 @@
"label": "Write Off Account",
"no_copy": 1,
"options": "Account",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"depends_on": "eval:flt(doc.write_off_amount)!=0",
@ -583,8 +620,9 @@
"fieldtype": "Link",
"label": "Write Off Cost Center",
"no_copy": 1,
"options": "Account",
"print_hide": 1
"options": "Cost Center",
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -596,6 +634,7 @@
"oldfieldname": "against_expense_account",
"oldfieldtype": "Small Text",
"print_hide": 1,
"read_only": 0,
"report_hide": 0
},
{
@ -604,7 +643,8 @@
"fieldtype": "Section Break",
"label": "Advances",
"oldfieldtype": "Section Break",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -613,7 +653,8 @@
"label": "Get Advances Paid",
"oldfieldtype": "Button",
"options": "get_advances",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -624,7 +665,8 @@
"oldfieldname": "advance_allocation_details",
"oldfieldtype": "Table",
"options": "Purchase Invoice Advance",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -632,7 +674,8 @@
"fieldtype": "Section Break",
"label": "More Info",
"oldfieldtype": "Section Break",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"default": "No",
@ -646,6 +689,7 @@
"oldfieldtype": "Select",
"options": "No\nYes",
"print_hide": 1,
"read_only": 0,
"search_index": 1
},
{
@ -657,6 +701,7 @@
"oldfieldname": "aging_date",
"oldfieldtype": "Date",
"print_hide": 1,
"read_only": 0,
"search_index": 0
},
{
@ -682,6 +727,7 @@
"oldfieldtype": "Link",
"options": "Print Heading",
"print_hide": 1,
"read_only": 0,
"report_hide": 1
},
{
@ -694,6 +740,7 @@
"oldfieldname": "due_date",
"oldfieldtype": "Date",
"print_hide": 0,
"read_only": 0,
"search_index": 1
},
{
@ -703,12 +750,14 @@
"label": "Mode of Payment",
"oldfieldname": "mode_of_payment",
"oldfieldtype": "Select",
"options": "link:Mode of Payment"
"options": "link:Mode of Payment",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break_63",
"fieldtype": "Column Break"
"fieldtype": "Column Break",
"read_only": 0
},
{
"doctype": "DocField",
@ -720,6 +769,7 @@
"oldfieldtype": "Link",
"options": "Company",
"print_hide": 1,
"read_only": 0,
"search_index": 1
},
{
@ -732,6 +782,7 @@
"oldfieldtype": "Select",
"options": "link:Fiscal Year",
"print_hide": 1,
"read_only": 0,
"search_index": 1
},
{
@ -755,17 +806,9 @@
"oldfieldname": "remarks",
"oldfieldtype": "Text",
"print_hide": 1,
"read_only": 0,
"reqd": 0
},
{
"doctype": "DocField",
"fieldname": "file_list",
"fieldtype": "Text",
"hidden": 1,
"label": "File List",
"no_copy": 1,
"print_hide": 1
},
{
"amend": 1,
"cancel": 1,
@ -776,8 +819,40 @@
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 1,
"doctype": "DocPerm",
"role": "Purchase User",
"submit": 0,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "supplier",
"role": "Supplier"
"role": "Supplier",
"submit": 0,
"write": 0
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Accounts Manager",
"submit": 1,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"role": "Auditor",
"submit": 0,
"write": 0
}
]

View File

@ -1,9 +1,9 @@
// render
wn.listview_settings['Purchase Invoice'] = {
add_fields: ["`tabPurchase Invoice`.grand_total", "`tabPurchase Invoice`.outstanding_amount"],
add_columns: [{"content":"outstanding_amount", width:"10%", type:"bar-graph", label: "Paid"}],
add_columns: [{"content":"paid_amount", width:"10%", type:"bar-graph", label: "Paid"}],
prepare_data: function(data) {
data.outstanding_amount = ((flt(data.grand_total) -
flt(data.outstanding_amount)) / flt(data.grand_total)) * 100;
data.paid_amount = flt(data.grand_total) ? (((flt(data.grand_total) -
flt(data.outstanding_amount)) / flt(data.grand_total)) * 100) : 0;
}
};

View File

@ -72,7 +72,38 @@ class TestPurchaseInvoice(unittest.TestCase):
["Stock Received But Not Billed - _TC", 750.0, 0],
["_Test Account Shipping Charges - _TC", 100.0, 0],
["_Test Account VAT - _TC", 120.0, 0],
["Expenses Included In Valuation - _TC", 0, 250.0]
["Expenses Included In Valuation - _TC", 0, 250.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_gl_entries_with_aia_for_non_stock_items(self):
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_inventory_accounting")), 1)
pi = webnotes.bean(copy=test_records[1])
pi.doclist[1].item_code = "_Test Non Stock Item"
pi.doclist[1].expense_head = "_Test Account Cost for Goods Sold - _TC"
pi.doclist.pop(2)
pi.doclist.pop(3)
pi.run_method("calculate_taxes_and_totals")
pi.insert()
pi.submit()
gl_entries = webnotes.conn.sql("""select account, debit, credit
from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s
order by account asc""", pi.doc.name, as_dict=1)
self.assertTrue(gl_entries)
expected_values = sorted([
["_Test Supplier - _TC", 0, 620],
["_Test Account Cost for Goods Sold - _TC", 500.0, 0],
["_Test Account VAT - _TC", 120.0, 0],
])
for i, gle in enumerate(gl_entries):
@ -106,7 +137,6 @@ class TestPurchaseInvoice(unittest.TestCase):
self.assertEqual(tax.account_head, expected_values[i][0])
self.assertEqual(tax.tax_amount, expected_values[i][1])
self.assertEqual(tax.total, expected_values[i][2])
# print tax.account_head, tax.tax_amount, tax.item_wise_tax_detail
expected_values = [
["_Test Item Home Desktop 100", 90, 59],
@ -142,7 +172,6 @@ class TestPurchaseInvoice(unittest.TestCase):
self.assertEqual(tax.account_head, expected_values[i][0])
self.assertEqual(tax.tax_amount, expected_values[i][1])
self.assertEqual(tax.total, expected_values[i][2])
# print tax.account_head, tax.tax_amount, tax.item_wise_tax_detail
expected_values = [
["_Test FG Item", 90, 7059],

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-04-10 08:35:38",
"creation": "2013-04-19 11:00:07",
"docstatus": 0,
"modified": "2013-04-17 14:05:20",
"modified": "2013-05-22 12:01:56",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -224,6 +224,7 @@
"fieldtype": "Link",
"in_filter": 1,
"label": "Pur Order",
"no_copy": 1,
"oldfieldname": "purchase_order",
"oldfieldtype": "Link",
"options": "Purchase Order",
@ -238,6 +239,7 @@
"hidden": 1,
"in_filter": 1,
"label": "Purchase Order Item",
"no_copy": 1,
"oldfieldname": "po_detail",
"oldfieldtype": "Data",
"print_hide": 1,
@ -250,6 +252,7 @@
"fieldtype": "Link",
"in_filter": 1,
"label": "Pur Receipt",
"no_copy": 1,
"oldfieldname": "purchase_receipt",
"oldfieldtype": "Link",
"options": "Purchase Receipt",
@ -264,6 +267,7 @@
"hidden": 1,
"in_filter": 1,
"label": "PR Detail",
"no_copy": 1,
"oldfieldname": "pr_detail",
"oldfieldtype": "Data",
"print_hide": 1,

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-26 06:51:12",
"creation": "2013-04-19 11:00:06",
"docstatus": 0,
"modified": "2013-04-17 14:05:19",
"modified": "2013-05-07 11:23:56",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -35,6 +35,7 @@
"oldfieldname": "category",
"oldfieldtype": "Select",
"options": "Valuation and Total\nValuation\nTotal",
"read_only": 0,
"reqd": 1
},
{
@ -45,6 +46,7 @@
"oldfieldname": "charge_type",
"oldfieldtype": "Select",
"options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total",
"read_only": 0,
"reqd": 1
},
{
@ -55,6 +57,7 @@
"oldfieldname": "account_head",
"oldfieldtype": "Link",
"options": "Account",
"read_only": 0,
"reqd": 1
},
{
@ -65,7 +68,8 @@
"label": "Cost Center",
"oldfieldname": "cost_center",
"oldfieldtype": "Link",
"options": "Cost Center"
"options": "Cost Center",
"read_only": 0
},
{
"doctype": "DocField",
@ -75,17 +79,18 @@
"oldfieldname": "description",
"oldfieldtype": "Small Text",
"print_width": "300px",
"read_only": 0,
"reqd": 1,
"width": "300px"
},
{
"doctype": "DocField",
"fieldname": "rate",
"fieldtype": "Currency",
"fieldtype": "Float",
"label": "Rate",
"oldfieldname": "rate",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"read_only": 0,
"reqd": 0
},
{
@ -96,6 +101,7 @@
"oldfieldname": "tax_amount",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"read_only": 0,
"reqd": 0
},
{
@ -115,7 +121,8 @@
"hidden": 0,
"label": "Enter Row",
"oldfieldname": "row_id",
"oldfieldtype": "Data"
"oldfieldtype": "Data",
"read_only": 0
},
{
"default": "Add",
@ -126,6 +133,7 @@
"oldfieldname": "add_deduct_tax",
"oldfieldtype": "Select",
"options": "Add\nDeduct",
"read_only": 0,
"reqd": 1
},
{
@ -149,6 +157,7 @@
"oldfieldname": "parenttype",
"oldfieldtype": "Data",
"print_hide": 1,
"read_only": 0,
"search_index": 0
},
{
@ -163,6 +172,7 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"read_only": 0,
"report_hide": 1
},
{
@ -177,6 +187,7 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"read_only": 0,
"report_hide": 1
}
]

View File

@ -147,7 +147,7 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) {
d.account_head = '';
}
else if(d.account_head && d.charge_type) {
arg = "{'charge_type' : '" + d.charge_type +"', 'account_head' : '" + d.account_head + "'}";
arg = "{'charge_type' : '" + d.charge_type + "', 'account_head' : '" + d.account_head + "'}";
get_server_fields('get_rate', arg, 'purchase_tax_details', doc, cdt, cdn, 1);
}
refresh_field('account_head',d.name,'purchase_tax_details');

View File

@ -26,11 +26,11 @@ sql = webnotes.conn.sql
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
# Get Tax Rate if account type is Tax
# ===================================================================
def get_rate(self, arg):
return get_obj('Purchase Common').get_rate(arg, self)
# Get Tax Rate if account type is Tax
# ===================================================================
def get_rate(self, arg):
return get_obj('Purchase Common').get_rate(arg, self)

View File

@ -159,7 +159,6 @@ cur_frm.cscript.update_stock = function(doc, dt, dn) {
cur_frm.cscript.hide_fields(doc, dt, dn);
}
cur_frm.cscript.warehouse = function(doc, cdt , cdn) {
var d = locals[cdt][cdn];
if (!d.item_code) { msgprint("please enter item code first"); return };

View File

@ -30,7 +30,6 @@ from webnotes import _, msgprint
month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
from controllers.selling_controller import SellingController
class DocType(SellingController):
@ -40,12 +39,9 @@ class DocType(SellingController):
self.tname = 'Sales Invoice Item'
self.fname = 'entries'
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
def validate(self):
super(DocType, self).validate()
self.fetch_missing_values()
self.validate_posting_time()
self.so_dn_required()
self.validate_proj_cust()
@ -78,9 +74,11 @@ class DocType(SellingController):
self.set_aging_date()
self.set_against_income_account()
self.validate_c_form()
self.validate_rate_with_refdoc()
self.validate_time_logs_are_submitted()
self.validate_recurring_invoice()
def on_submit(self):
if cint(self.doc.is_pos) == 1:
if cint(self.doc.update_stock) == 1:
@ -137,7 +135,27 @@ class DocType(SellingController):
def on_update_after_submit(self):
self.validate_recurring_invoice()
self.convert_to_recurring()
def fetch_missing_values(self):
# fetch contact and address details for customer, if they are not mentioned
if not (self.doc.contact_person and self.doc.customer_address):
for fieldname, val in self.get_default_address_and_contact("customer").items():
if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname):
self.doc.fields[fieldname] = val
# fetch missing item values
for item in self.doclist.get({"parentfield": "entries"}):
if item.fields.get("item_code"):
ret = get_obj('Sales Common').get_item_details(item.fields, self)
for fieldname, value in ret.items():
if self.meta.get_field(fieldname, parentfield="entries") and \
item.fields.get(fieldname) is None:
item.fields[fieldname] = value
# fetch pos details, if they are not fetched
if cint(self.doc.is_pos):
self.set_pos_fields(for_validate=True)
def update_time_log_batch(self, sales_invoice):
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
if d.time_log_batch:
@ -153,60 +171,42 @@ class DocType(SellingController):
webnotes.msgprint(_("Time Log Batch status must be 'Submitted'") + ":" + d.time_log_batch,
raise_exception=True)
def set_pos_fields(self):
def set_pos_fields(self, for_validate=False):
"""Set retail related fields from pos settings"""
pos = self.pos_details
if pos:
val = webnotes.conn.sql("""select name from `tabAccount`
where name = %s and docstatus != 2""",
(cstr(self.doc.customer) + " - " + self.get_company_abbr()))
val = val and val[0][0] or ''
if not val: val = pos[0]['customer_account'] or ''
if cint(self.doc.is_pos) != 1:
return
if self.pos_settings:
pos = self.pos_settings[0]
self.doc.conversion_rate = flt(pos.conversion_rate)
if not self.doc.debit_to:
webnotes.conn.set(self.doc,'debit_to',val)
lst = ['territory', 'naming_series', 'currency', 'charge', 'letter_head', 'tc_name',
'price_list_name', 'company', 'select_print_heading', 'cash_bank_account']
self.doc.debit_to = self.doc.customer and webnotes.conn.get_value("Account", {
"name": self.doc.customer + " - " + self.get_company_abbr(),
"docstatus": ["!=", 2]
}) or pos.customer_account
for i in lst:
self.doc.fields[i] = pos[0][i] or ''
for fieldname in ('territory', 'naming_series', 'currency', 'charge', 'letter_head', 'tc_name',
'price_list_name', 'company', 'select_print_heading', 'cash_bank_account'):
if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)):
self.doc.fields[fieldname] = pos.get(fieldname)
self.set_pos_item_values()
self.doc.conversion_rate = flt(pos[0]['conversion_rate']) or 0
# set pos values in items
for item in self.doclist.get({"parentfield": "entries"}):
if item.fields.get('item_code'):
for fieldname, val in self.apply_pos_settings(item.fields).items():
if (not for_validate) or (for_validate and not item.fields.get(fieldname)):
item.fields[fieldname] = val
#fetch terms
if self.doc.tc_name:
# fetch terms
if self.doc.tc_name and not self.doc.terms:
self.get_tc_details()
#fetch charges
if self.doc.charge:
# fetch charges
if self.doc.charge and not len(self.doclist.get({"parentfield": "other_charges"})):
self.get_other_charges()
def set_pos_item_values(self):
"""Set default values related to pos for previously created sales invoice."""
if cint(self.doc.is_pos) == 1:
dtl = self.pos_details
for d in getlist(self.doclist,'entries'):
# overwrite if mentioned in item
item = webnotes.conn.sql("""select default_income_account,
default_sales_cost_center, default_warehouse, purchase_account
from tabItem where name = %s""", (d.item_code,), as_dict=1)
d.income_account = (item and item[0]['default_income_account']) \
or (dtl and dtl[0]['income_account']) or d.income_account
d.cost_center = (item and item[0]['default_sales_cost_center']) \
or (dtl and dtl[0]['cost_center']) or d.cost_center
d.warehouse = (item and item[0]['default_warehouse']) \
or (dtl and dtl[0]['warehouse']) or d.warehouse
d.expense_account = (item and item[0].purchase_account) \
or (dtl and dtl[0].expense_account) or d.expense_account
def get_customer_account(self):
"""Get Account Head to which amount needs to be Debited based on Customer"""
if not self.doc.company:
@ -215,8 +215,9 @@ class DocType(SellingController):
if self.doc.customer:
acc_head = webnotes.conn.sql("""select name from `tabAccount`
where (name = %s or (master_name = %s and master_type = 'customer'))
and docstatus != 2""",
(cstr(self.doc.customer) + " - " + self.get_company_abbr(), self.doc.customer))
and docstatus != 2 and company = %s""",
(cstr(self.doc.customer) + " - " + self.get_company_abbr(),
self.doc.customer, self.doc.company))
if acc_head and acc_head[0][0]:
return acc_head[0][0]
@ -299,60 +300,59 @@ class DocType(SellingController):
args = args and json.loads(args) or {}
if args.get('item_code'):
ret = get_obj('Sales Common').get_item_details(args, self)
return self.get_pos_details(args, ret)
else:
for doc in self.doclist:
if cint(self.doc.is_pos) == 1 and self.pos_settings:
ret = self.apply_pos_settings(args, ret)
return ret
elif cint(self.doc.is_pos) == 1 and self.pos_settings:
for doc in self.doclist.get({"parentfield": "entries"}):
if doc.fields.get('item_code'):
arg = {
'item_code':doc.fields.get('item_code'),
'income_account':doc.fields.get('income_account'),
'cost_center': doc.fields.get('cost_center'),
'warehouse': doc.fields.get('warehouse'),
'expense_account': doc.fields.get('expense_account'),
}
ret = self.get_pos_details(arg)
ret = self.apply_pos_settings(doc.fields)
for r in ret:
if not doc.fields.get(r):
doc.fields[r] = ret[r]
@property
def pos_details(self):
if not hasattr(self, "_pos_details"):
def pos_settings(self):
if not hasattr(self, "_pos_settings"):
dtl = webnotes.conn.sql("""select * from `tabPOS Setting` where user = %s
and company = %s""", (webnotes.session['user'], self.doc.company), as_dict=1)
if not dtl:
dtl = webnotes.conn.sql("""select * from `tabPOS Setting`
where ifnull(user,'') = '' and company = %s""", self.doc.company, as_dict=1)
self._pos_details = dtl
self._pos_settings = dtl
return self._pos_details
return self._pos_settings
def get_pos_details(self, args, ret = {}):
if args['item_code'] and cint(self.doc.is_pos) == 1:
dtl = self.pos_details
item = webnotes.conn.sql("""select default_income_account, default_sales_cost_center,
default_warehouse, purchase_account from tabItem where name = %s""",
args['item_code'], as_dict=1)
ret['income_account'] = item and item[0].get('default_income_account') \
or (dtl and dtl[0].get('income_account') or args.get('income_account'))
ret['cost_center'] = item and item[0].get('default_sales_cost_center') \
or (dtl and dtl[0].get('cost_center') or args.get('cost_center'))
def apply_pos_settings(self, args, ret=None):
if not ret: ret = {}
pos = self.pos_settings[0]
item = webnotes.conn.sql("""select default_income_account, default_sales_cost_center,
default_warehouse, purchase_account from tabItem where name = %s""",
args.get('item_code'), as_dict=1)
if item:
item = item[0]
ret['warehouse'] = item and item[0].get('default_warehouse') \
or (dtl and dtl[0].get('warehouse') or args.get('warehouse'))
ret.update({
"income_account": item.get("default_income_account") \
or pos.get("income_account") or args.get("income_account"),
"cost_center": item.get("default_sales_cost_center") \
or pos.get("cost_center") or args.get("cost_center"),
"warehouse": item.get("default_warehouse") \
or pos.get("warehouse") or args.get("warehouse"),
"expense_account": item.get("purchase_account") \
or pos.get("expense_account") or args.get("expense_account")
})
ret['expense_account'] = item and item[0].get('purchase_account') \
or (dtl and dtl[0].get('expense_account') or args.get('expense_account'))
if ret['warehouse']:
actual_qty = webnotes.conn.sql("""select actual_qty from `tabBin`
where item_code = %s and warehouse = %s""",
(args['item_code'], ret['warehouse']))
ret['actual_qty']= actual_qty and flt(actual_qty[0][0]) or 0
if ret.get("warehouse"):
ret["actual_qty"] = flt(webnotes.conn.get_value("Bin",
{"item_code": args.get("item_code"), "warehouse": ret.get("warehouse")},
"actual_qty"))
return ret
def get_barcode_details(self, barcode):
@ -433,17 +433,6 @@ class DocType(SellingController):
from accounts.utils import reconcile_against_document
reconcile_against_document(lst)
def validate_customer(self):
""" Validate customer name with SO and DN"""
for d in getlist(self.doclist,'entries'):
dt = d.delivery_note and 'Delivery Note' or d.sales_order and 'Sales Order' or ''
if dt:
dt_no = d.delivery_note or d.sales_order
cust = webnotes.conn.sql("select customer from `tab%s` where name = %s" % (dt, '%s'), dt_no)
if cust and cstr(cust[0][0]) != cstr(self.doc.customer):
msgprint("Customer %s does not match with customer of %s: %s." %(self.doc.customer, dt, dt_no), raise_exception=1)
def validate_customer_account(self):
"""Validates Debit To Account and Customer Matches"""
if self.doc.customer and self.doc.debit_to and not cint(self.doc.is_pos):
@ -453,6 +442,19 @@ class DocType(SellingController):
(not acc_head and (self.doc.debit_to != cstr(self.doc.customer) + " - " + self.get_company_abbr())):
msgprint("Debit To: %s do not match with Customer: %s for Company: %s.\n If both correctly entered, please select Master Type \
and Master Name in account master." %(self.doc.debit_to, self.doc.customer,self.doc.company), raise_exception=1)
def validate_customer(self):
""" Validate customer name with SO and DN"""
if self.doc.customer:
for d in getlist(self.doclist,'entries'):
dt = d.delivery_note and 'Delivery Note' or d.sales_order and 'Sales Order' or ''
if dt:
dt_no = d.delivery_note or d.sales_order
cust = webnotes.conn.get_value(dt, dt_no, "customer")
if cust and cstr(cust) != cstr(self.doc.customer):
msgprint("Customer %s does not match with customer of %s: %s."
%(self.doc.customer, dt, dt_no), raise_exception=1)
def validate_debit_acc(self):
@ -554,6 +556,21 @@ class DocType(SellingController):
webnotes.conn.set(self.doc, 'c_form_no', '')
def validate_rate_with_refdoc(self):
"""Validate values with reference document with previous document"""
for d in self.doclist.get({"parentfield": "entries"}):
if d.so_detail:
self.check_value("Sales Order", d.sales_order, d.so_detail,
d.export_rate, d.item_code)
if d.dn_detail:
self.check_value("Delivery Note", d.delivery_note, d.dn_detail,
d.export_rate, d.item_code)
def check_value(self, ref_dt, ref_dn, ref_item_dn, val, item_code):
ref_val = webnotes.conn.get_value(ref_dt + " Item", ref_item_dn, "export_rate")
if flt(ref_val, 2) != flt(val, 2):
msgprint(_("Rate is not matching with ") + ref_dt + ": " + ref_dn +
_(" for item: ") + item_code, raise_exception=True)
def update_current_stock(self):
for d in getlist(self.doclist, 'entries'):

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-22 18:37:25",
"creation": "2013-04-19 11:00:14",
"docstatus": 0,
"modified": "2013-03-22 18:38:13",
"modified": "2013-04-22 11:59:28",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -30,9 +30,7 @@
"parent": "Sales Invoice",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1
"read": 1
},
{
"doctype": "DocType",
@ -44,7 +42,8 @@
"fieldtype": "Section Break",
"label": "Basic Info",
"oldfieldtype": "Section Break",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -52,6 +51,7 @@
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 0,
"read_only": 0,
"width": "50%"
},
{
@ -65,6 +65,7 @@
"oldfieldtype": "Select",
"options": "INV\nINV/10-11/",
"print_hide": 1,
"read_only": 0,
"reqd": 1
},
{
@ -74,7 +75,8 @@
"label": "Is POS",
"oldfieldname": "is_pos",
"oldfieldtype": "Check",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"depends_on": "eval:doc.is_pos==1",
@ -84,7 +86,8 @@
"label": "Update Stock",
"oldfieldname": "update_stock",
"oldfieldtype": "Check",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"description": "The account to which you will pay (have paid) the money to.",
@ -97,6 +100,7 @@
"oldfieldtype": "Link",
"options": "Account",
"print_hide": 1,
"read_only": 0,
"reqd": 1,
"search_index": 1
},
@ -110,7 +114,8 @@
"oldfieldname": "customer",
"oldfieldtype": "Link",
"options": "Customer",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -160,7 +165,8 @@
"doctype": "DocField",
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break"
"oldfieldtype": "Column Break",
"read_only": 0
},
{
"default": "Today",
@ -174,6 +180,7 @@
"oldfieldname": "posting_date",
"oldfieldtype": "Date",
"print_hide": 0,
"read_only": 0,
"reqd": 1,
"search_index": 1
},
@ -188,6 +195,7 @@
"no_copy": 1,
"oldfieldname": "due_date",
"oldfieldtype": "Date",
"read_only": 0,
"reqd": 1,
"search_index": 0
},
@ -198,14 +206,16 @@
"label": "Mode of Payment",
"oldfieldname": "mode_of_payment",
"oldfieldtype": "Select",
"options": "link:Mode of Payment"
"options": "link:Mode of Payment",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "items",
"fieldtype": "Section Break",
"label": "Items",
"oldfieldtype": "Section Break"
"oldfieldtype": "Section Break",
"read_only": 0
},
{
"allow_on_submit": 1,
@ -215,25 +225,29 @@
"label": "Entries",
"oldfieldname": "entries",
"oldfieldtype": "Table",
"options": "Sales Invoice Item"
"options": "Sales Invoice Item",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "sales_bom_help",
"fieldtype": "HTML",
"label": "Sales BOM Help",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "section_break0",
"fieldtype": "Section Break",
"options": "Simple"
"options": "Simple",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "col_break26",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -255,12 +269,14 @@
"fieldtype": "Button",
"label": "Re-Calculate Values",
"oldfieldtype": "Button",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "col_break25",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -272,7 +288,8 @@
"oldfieldname": "sales_order_main",
"oldfieldtype": "Link",
"options": "Sales Order",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"description": "Select Items from Delivery Note",
@ -283,7 +300,8 @@
"oldfieldname": "delivery_note_main",
"oldfieldtype": "Link",
"options": "Delivery Note",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -291,18 +309,21 @@
"fieldtype": "Button",
"label": "Get Items",
"oldfieldtype": "Button",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "currency_section",
"fieldtype": "Section Break",
"label": "Price List and Currency"
"label": "Price List and Currency",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "col_break27",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -314,6 +335,7 @@
"oldfieldtype": "Select",
"options": "link:Price List",
"print_hide": 1,
"read_only": 0,
"reqd": 1
},
{
@ -324,6 +346,7 @@
"label": "Price List Currency",
"options": "Currency",
"print_hide": 1,
"read_only": 0,
"reqd": 1
},
{
@ -333,12 +356,14 @@
"fieldtype": "Float",
"label": "Price List Currency Conversion Rate",
"print_hide": 1,
"read_only": 0,
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "column_break2",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -350,6 +375,7 @@
"oldfieldtype": "Select",
"options": "Currency",
"print_hide": 1,
"read_only": 0,
"reqd": 1
},
{
@ -362,6 +388,7 @@
"oldfieldname": "conversion_rate",
"oldfieldtype": "Currency",
"print_hide": 1,
"read_only": 0,
"reqd": 1
},
{
@ -369,7 +396,8 @@
"fieldname": "taxes",
"fieldtype": "Section Break",
"label": "Taxes and Charges",
"oldfieldtype": "Section Break"
"oldfieldtype": "Section Break",
"read_only": 0
},
{
"doctype": "DocField",
@ -379,7 +407,8 @@
"oldfieldname": "charge",
"oldfieldtype": "Link",
"options": "Sales Taxes and Charges Master",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -387,7 +416,8 @@
"fieldtype": "Button",
"label": "Get Taxes and Charges",
"oldfieldtype": "Button",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"allow_on_submit": 1,
@ -397,7 +427,8 @@
"label": "Taxes and Charges1",
"oldfieldname": "other_charges",
"oldfieldtype": "Table",
"options": "Sales Taxes and Charges"
"options": "Sales Taxes and Charges",
"read_only": 0
},
{
"doctype": "DocField",
@ -405,7 +436,8 @@
"fieldtype": "Button",
"label": "Calculate Taxes and Charges",
"oldfieldtype": "Button",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -424,7 +456,8 @@
"fieldtype": "HTML",
"label": "Taxes and Charges Calculation",
"oldfieldtype": "HTML",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -432,7 +465,8 @@
"fieldtype": "Section Break",
"label": "Totals",
"oldfieldtype": "Section Break",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -440,6 +474,7 @@
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
"read_only": 0,
"width": "50%"
},
{
@ -508,6 +543,7 @@
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
"read_only": 0,
"width": "50%"
},
{
@ -569,12 +605,14 @@
"doctype": "DocField",
"fieldname": "payments_section",
"fieldtype": "Section Break",
"label": "Payments"
"label": "Payments",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break3",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -585,7 +623,8 @@
"oldfieldname": "paid_amount",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -595,12 +634,14 @@
"oldfieldname": "cash_bank_account",
"oldfieldtype": "Link",
"options": "Account",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break4",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -608,7 +649,8 @@
"fieldname": "write_off_outstanding_amount_automatically",
"fieldtype": "Check",
"label": "Write Off Outstanding Amount",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -616,7 +658,8 @@
"fieldtype": "Currency",
"label": "Write Off Amount",
"options": "Company:company:default_currency",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -624,7 +667,8 @@
"fieldtype": "Link",
"label": "Write Off Account",
"options": "Account",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -632,14 +676,16 @@
"fieldtype": "Link",
"label": "Write Off Cost Center",
"options": "Cost Center",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "terms_section_break",
"fieldtype": "Section Break",
"label": "Terms and Conditions",
"oldfieldtype": "Section Break"
"oldfieldtype": "Section Break",
"read_only": 0
},
{
"doctype": "DocField",
@ -649,7 +695,8 @@
"oldfieldname": "tc_name",
"oldfieldtype": "Link",
"options": "Terms and Conditions",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -658,7 +705,8 @@
"label": "Get Terms and Conditions",
"oldfieldtype": "Button",
"options": "get_tc_details",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -667,7 +715,8 @@
"label": "Terms and Conditions HTML",
"oldfieldtype": "HTML",
"options": "You can add Terms and Notes that will be printed in the Transaction",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -675,18 +724,21 @@
"fieldtype": "Text Editor",
"label": "Terms and Conditions Details",
"oldfieldname": "terms",
"oldfieldtype": "Text Editor"
"oldfieldtype": "Text Editor",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "contact_section",
"fieldtype": "Section Break",
"label": "Contact Info"
"label": "Contact Info",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "col_break23",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -695,7 +747,8 @@
"fieldtype": "Link",
"label": "Customer Address",
"options": "Address",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -703,12 +756,14 @@
"fieldtype": "Link",
"label": "Contact Person",
"options": "Contact",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "col_break24",
"fieldtype": "Column Break",
"read_only": 0,
"width": "50%"
},
{
@ -719,6 +774,7 @@
"label": "Territory",
"options": "Territory",
"print_hide": 1,
"read_only": 0,
"reqd": 1,
"search_index": 0
},
@ -730,6 +786,7 @@
"label": "Customer Group",
"options": "Customer Group",
"print_hide": 1,
"read_only": 0,
"search_index": 0
},
{
@ -738,7 +795,8 @@
"fieldtype": "Section Break",
"label": "More Info",
"oldfieldtype": "Section Break",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -746,6 +804,7 @@
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
"read_only": 0,
"width": "50%"
},
{
@ -760,6 +819,7 @@
"oldfieldtype": "Select",
"options": "No\nYes",
"print_hide": 1,
"read_only": 0,
"search_index": 0
},
{
@ -770,7 +830,8 @@
"label": "Aging Date",
"oldfieldname": "aging_date",
"oldfieldtype": "Date",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -780,7 +841,8 @@
"no_copy": 1,
"oldfieldname": "posting_time",
"oldfieldtype": "Time",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"allow_on_submit": 1,
@ -791,7 +853,8 @@
"oldfieldname": "letter_head",
"oldfieldtype": "Select",
"options": "link:Letter Head",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -801,6 +864,7 @@
"no_copy": 1,
"options": "No\nYes",
"print_hide": 1,
"read_only": 0,
"report_hide": 0
},
{
@ -822,7 +886,8 @@
"oldfieldname": "campaign",
"oldfieldtype": "Link",
"options": "Campaign",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"description": "Track this Sales Invoice against any Project",
@ -834,6 +899,7 @@
"oldfieldname": "project_name",
"oldfieldtype": "Link",
"options": "Project",
"read_only": 0,
"search_index": 1
},
{
@ -847,6 +913,7 @@
"oldfieldtype": "Link",
"options": "Print Heading",
"print_hide": 1,
"read_only": 0,
"report_hide": 1
},
{
@ -854,7 +921,8 @@
"fieldname": "column_break8",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -864,7 +932,8 @@
"oldfieldname": "source",
"oldfieldtype": "Select",
"options": "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -876,6 +945,7 @@
"oldfieldtype": "Link",
"options": "Company",
"print_hide": 1,
"read_only": 0,
"reqd": 1,
"search_index": 0
},
@ -890,6 +960,7 @@
"oldfieldtype": "Select",
"options": "link:Fiscal Year",
"print_hide": 1,
"read_only": 0,
"reqd": 1,
"search_index": 0
},
@ -914,7 +985,8 @@
"no_copy": 1,
"oldfieldname": "amendment_date",
"oldfieldtype": "Date",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"depends_on": "eval:!doc.__islocal",
@ -936,6 +1008,7 @@
"oldfieldname": "remarks",
"oldfieldtype": "Text",
"print_hide": 1,
"read_only": 0,
"reqd": 0
},
{
@ -944,7 +1017,8 @@
"fieldtype": "Section Break",
"label": "Advances",
"oldfieldtype": "Section Break",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -953,7 +1027,8 @@
"label": "Get Advances Received",
"oldfieldtype": "Button",
"options": "get_advances",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -963,14 +1038,16 @@
"oldfieldname": "advance_adjustment_details",
"oldfieldtype": "Table",
"options": "Sales Invoice Advance",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "packing_list",
"fieldtype": "Section Break",
"label": "Packing List",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -978,7 +1055,8 @@
"fieldtype": "Table",
"label": "Packing Details",
"options": "Delivery Note Packing Item",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -986,7 +1064,8 @@
"fieldtype": "Section Break",
"label": "Sales Team",
"oldfieldtype": "Section Break",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -994,6 +1073,7 @@
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
"read_only": 0,
"width": "50%"
},
{
@ -1005,7 +1085,8 @@
"oldfieldname": "sales_partner",
"oldfieldtype": "Link",
"options": "Sales Partner",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -1013,6 +1094,7 @@
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
"read_only": 0,
"width": "50%"
},
{
@ -1022,7 +1104,8 @@
"label": "Commission Rate (%)",
"oldfieldname": "commission_rate",
"oldfieldtype": "Currency",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -1032,14 +1115,16 @@
"oldfieldname": "total_commission",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "section_break2",
"fieldtype": "Section Break",
"options": "Simple",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -1049,7 +1134,8 @@
"oldfieldname": "sales_team",
"oldfieldtype": "Table",
"options": "Sales Team",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"depends_on": "eval:doc.docstatus<2",
@ -1057,13 +1143,15 @@
"fieldname": "recurring_invoice",
"fieldtype": "Section Break",
"label": "Recurring Invoice",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "column_break11",
"fieldtype": "Column Break",
"print_hide": 1,
"read_only": 0,
"width": "50%"
},
{
@ -1075,7 +1163,8 @@
"fieldtype": "Check",
"label": "Convert into Recurring Invoice",
"no_copy": 1,
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"allow_on_submit": 1,
@ -1087,7 +1176,8 @@
"label": "Recurring Type",
"no_copy": 1,
"options": "Monthly\nQuarterly\nHalf-yearly\nYearly",
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"allow_on_submit": 1,
@ -1098,7 +1188,8 @@
"fieldtype": "Int",
"label": "Repeat on Day of Month",
"no_copy": 1,
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"allow_on_submit": 1,
@ -1109,7 +1200,8 @@
"fieldtype": "Date",
"label": "Invoice Period From Date",
"no_copy": 1,
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"allow_on_submit": 1,
@ -1120,7 +1212,8 @@
"fieldtype": "Date",
"label": "Invoice Period To Date",
"no_copy": 1,
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -1128,6 +1221,7 @@
"fieldtype": "Column Break",
"no_copy": 0,
"print_hide": 1,
"read_only": 0,
"width": "50%"
},
{
@ -1139,7 +1233,8 @@
"fieldtype": "Small Text",
"label": "Notification Email Address",
"no_copy": 1,
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"depends_on": "eval:doc.convert_into_recurring_invoice==1",
@ -1172,7 +1267,8 @@
"fieldtype": "Date",
"label": "End Date",
"no_copy": 1,
"print_hide": 1
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
@ -1184,22 +1280,16 @@
"oldfieldname": "against_income_account",
"oldfieldtype": "Small Text",
"print_hide": 1,
"read_only": 0,
"report_hide": 1
},
{
"doctype": "DocField",
"fieldname": "file_list",
"fieldtype": "Text",
"hidden": 1,
"label": "File List",
"no_copy": 1,
"print_hide": 1
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Accounts User",
"submit": 1,
"write": 1
@ -1207,6 +1297,8 @@
{
"doctype": "DocPerm",
"match": "customer",
"permlevel": 0,
"report": 1,
"role": "Customer"
}
},
]

View File

@ -1,9 +1,10 @@
// render
wn.listview_settings['Sales Invoice'] = {
add_fields: ["`tabSales Invoice`.grand_total", "`tabSales Invoice`.outstanding_amount"],
add_columns: [{"content":"outstanding_amount", width:"10%", type:"bar-graph"}],
add_columns: [{"content":"paid_amount", width:"10%", type:"bar-graph",
label: "Payment Received"}],
prepare_data: function(data) {
data.outstanding_amount = (flt(data.grand_total) -
flt(data.outstanding_amount)) / flt(data.grand_total) * 100;
data.paid_amount = flt(data.grand_total) ? (((flt(data.grand_total) -
flt(data.outstanding_amount)) / flt(data.grand_total)) * 100) : 0;
}
};

View File

@ -90,6 +90,9 @@ class TestSalesInvoice(unittest.TestCase):
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
old_default_company = webnotes.conn.get_default("company")
webnotes.conn.set_default("company", "_Test Company")
self._insert_purchase_receipt()
self._insert_pos_settings()
@ -106,7 +109,8 @@ class TestSalesInvoice(unittest.TestCase):
# check stock ledger entries
sle = webnotes.conn.sql("""select * from `tabStock Ledger Entry`
where voucher_type = 'Sales Invoice' and voucher_no = %s""", si.doc.name, as_dict=1)[0]
where voucher_type = 'Sales Invoice' and voucher_no = %s""",
si.doc.name, as_dict=1)[0]
self.assertTrue(sle)
self.assertEquals([sle.item_code, sle.warehouse, sle.actual_qty],
["_Test Item", "_Test Warehouse", -5.0])
@ -145,6 +149,7 @@ class TestSalesInvoice(unittest.TestCase):
self.assertEquals(gl_count[0][0], 16)
webnotes.defaults.set_global_default("auto_inventory_accounting", 0)
webnotes.conn.set_default("company", old_default_company)
def test_sales_invoice_gl_entry_with_aii_no_item_code(self):
webnotes.defaults.set_global_default("auto_inventory_accounting", 1)
@ -337,7 +342,7 @@ class TestSalesInvoice(unittest.TestCase):
# change posting date but keep recuring day to be today
si7 = webnotes.bean(copy=base_si.doclist)
si7.doc.fields.update({
"posting_date": add_to_date(today, days=-3)
"posting_date": add_to_date(today, days=-1)
})
si7.insert()
si7.submit()
@ -345,7 +350,7 @@ class TestSalesInvoice(unittest.TestCase):
# setting so that _test function works
si7.doc.posting_date = today
self._test_recurring_invoice(si7, True)
def _test_recurring_invoice(self, base_si, first_and_last_day):
from webnotes.utils import add_months, get_last_day, getdate
from accounts.doctype.sales_invoice.sales_invoice import manage_recurring_invoices
@ -361,7 +366,8 @@ class TestSalesInvoice(unittest.TestCase):
manage_recurring_invoices(next_date=next_date, commit=False)
recurred_invoices = webnotes.conn.sql("""select name from `tabSales Invoice`
where recurring_id=%s and docstatus=1 order by name desc""", base_si.doc.recurring_id)
where recurring_id=%s and docstatus=1 order by name desc""",
base_si.doc.recurring_id)
self.assertEquals(i+2, len(recurred_invoices))
@ -395,7 +401,7 @@ class TestSalesInvoice(unittest.TestCase):
for i in xrange(count):
base_si = _test(i)
test_dependencies = ["Journal Voucher", "POS Setting"]
test_dependencies = ["Journal Voucher", "POS Setting", "Contact", "Address"]
test_records = [
[

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-04-10 08:35:44",
"creation": "2013-06-04 11:02:19",
"docstatus": 0,
"modified": "2013-04-17 14:05:20",
"modified": "2013-06-26 14:33:21",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -243,7 +243,8 @@
"oldfieldname": "serial_no",
"oldfieldtype": "Small Text",
"print_hide": 0,
"read_only": 0
"read_only": 0,
"reqd": 0
},
{
"doctype": "DocField",
@ -305,6 +306,7 @@
"fieldtype": "Link",
"in_filter": 1,
"label": "Sales Order",
"no_copy": 1,
"oldfieldname": "sales_order",
"oldfieldtype": "Link",
"options": "Sales Order",
@ -319,6 +321,7 @@
"hidden": 1,
"in_filter": 1,
"label": "SO Detail ",
"no_copy": 1,
"oldfieldname": "so_detail",
"oldfieldtype": "Data",
"print_hide": 1,
@ -331,6 +334,7 @@
"fieldtype": "Link",
"in_filter": 1,
"label": "Delivery Note",
"no_copy": 1,
"oldfieldname": "delivery_note",
"oldfieldtype": "Link",
"options": "Delivery Note",
@ -345,6 +349,7 @@
"hidden": 1,
"in_filter": 1,
"label": "DN Detail",
"no_copy": 1,
"oldfieldname": "dn_detail",
"oldfieldtype": "Data",
"print_hide": 1,

View File

@ -131,7 +131,7 @@ erpnext.AccountsChart = Class.extend({
if (wn.model.can_read(this.ctype) !== -1) {
node_links.push('<a onclick="erpnext.account_chart.open();">Edit</a>');
}
if (data.expandable) {
if (data.expandable && wn.boot.profile.in_create.indexOf(this.ctype) !== -1) {
node_links.push('<a onclick="erpnext.account_chart.new_node();">Add Child</a>');
} else if (this.ctype === 'Account' && wn.boot.profile.can_read.indexOf("GL Entry") !== -1) {
node_links.push('<a onclick="erpnext.account_chart.show_ledger();">View Ledger</a>');

View File

@ -139,6 +139,26 @@ wn.module_page["Accounts"] = [
"page":"Financial Statements",
"label": wn._("Financial Statements")
},
{
"label":wn._("Accounts Receivable"),
route: "query-report/Accounts Receivable",
doctype: "Sales Invoice"
},
{
"label":wn._("Accounts Payable"),
route: "query-report/Accounts Payable",
doctype: "Purchase Invoice"
},
{
"label":wn._("Sales Register"),
route: "query-report/Sales Register",
doctype: "Sales Invoice"
},
{
"label":wn._("Purchase Register"),
route: "query-report/Purchase Register",
doctype: "Purchase Invoice"
},
]
},
{
@ -150,11 +170,6 @@ wn.module_page["Accounts"] = [
"label":wn._("Financial Analytics"),
page: "financial-analytics"
},
{
"label":wn._("Trend Analyzer"),
route: "Report/Profile/Trend Analyzer",
doctype: "Sales Invoice"
},
{
"label":wn._("Gross Profit"),
route: "query-report/Gross Profit",
@ -167,16 +182,86 @@ wn.module_page["Accounts"] = [
right: true,
icon: "icon-list",
items: [
{
"label":wn._("Bank Reconciliation Statement"),
route: "query-report/Bank Reconciliation Statement",
doctype: "Journal Voucher"
},
{
"label":wn._("Delivered Items To Be Billed"),
route: "query-report/Delivered Items To Be Billed",
doctype: "Sales Invoice"
},
{
"label":wn._("Received Items To Be Billed"),
route: "query-report/Received Items To Be Billed",
doctype: "Purchase Invoice"
},
{
"label":wn._("Ordered Items To Be Billed"),
route: "query-report/Ordered Items To Be Billed",
doctype: "Sales Invoice"
},
{
"label":wn._("Purchase Order Items To Be Billed"),
route: "query-report/Purchase Order Items To Be Billed",
doctype: "Purchase Invoice"
},
{
"label":wn._("Bank Clearance Summary"),
route: "query-report/Bank Clearance Summary",
doctype: "Journal Voucher"
},
{
"label":wn._("Payment Collection With Ageing"),
route: "query-report/Payment Collection With Ageing",
doctype: "Journal Voucher"
},
{
"label":wn._("Payment Made With Ageing"),
route: "query-report/Payment Made With Ageing",
doctype: "Journal Voucher"
},
{
"label":wn._("Sales Partners Commission"),
route: "query-report/Sales Partners Commission",
doctype: "Sales Invoice"
},
{
"label":wn._("Customer Account Head"),
route: "query-report/Customer Account Head",
doctype: "Account"
},
{
"label":wn._("Supplier Account Head"),
route: "query-report/Supplier Account Head",
doctype: "Account"
},
{
"label":wn._("Item-wise Sales Register"),
route: "query-report/Item-wise Sales Register",
doctype: "Sales Invoice"
},
{
"label":wn._("Item-wise Purchase Register"),
route: "query-report/Item-wise Purchase Register",
doctype: "Purchase Invoice"
},
{
"label":wn._("Budget Variance Report"),
route: "query-report/Budget Variance Report",
doctype: "Cost Center"
},
{
"label":wn._("Purchase Invoice Trends"),
route: "query-report/Purchase Invoice Trends",
doctype: "Purchase Invoice"
},
{
"label":wn._("Sales Invoice Trends"),
route: "query-report/Sales Invoice Trends",
doctype: "Sales Invoice"
},
]
}
]

View File

@ -68,6 +68,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
];
},
filters: [
{fieldtype:"Select", label: "Company", link:"Company", default_value: "Select Company...",
filter: function(val, item, opts) {
@ -96,6 +97,7 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date);
}},
{fieldtype: "Check", label: "Group by Ledger"},
{fieldtype: "Check", label: "Group by Voucher"},
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
{fieldtype:"Button", label: "Reset Filters"}
],
@ -116,9 +118,14 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
me.filter_inputs.group_by_ledger
.parent().toggle(!!(me.account_by_name[$(this).val()]
&& me.account_by_name[$(this).val()].group_or_ledger==="Group"));
me.filter_inputs.group_by_voucher
.parent().toggle(!!(me.account_by_name[$(this).val()]
&& me.account_by_name[$(this).val()].group_or_ledger==="Ledger"));
});
this.trigger_refresh_on_change(["group_by_ledger"]);
this.trigger_refresh_on_change(["group_by_voucher"]);
},
setup_account_filter: function(company_filter) {
var me = this;
@ -139,12 +146,14 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
init_filter_values: function() {
this._super();
this.filter_inputs.group_by_ledger.parent().toggle(false);
this.filter_inputs.group_by_voucher.parent().toggle(false);
this.filter_inputs.company.change();
this.filter_inputs.account.change();
},
apply_filters_from_route: function() {
this._super();
this.filter_inputs.group_by_ledger.parent().toggle(false);
this.filter_inputs.group_by_voucher.parent().toggle(false);
this.filter_inputs.company.change();
this.filter_inputs.account.change();
},
@ -186,7 +195,6 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
var totals = this.make_summary_row("Totals", this.account);
var grouped_ledgers = {};
$.each(data, function(i, item) {
if((me.is_default("company") ? true : me.apply_filter(item, "company")) &&
(me.account ? me.is_child_account(me.account, item.account)
@ -197,13 +205,21 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
if(!grouped_ledgers[item.account]) {
grouped_ledgers[item.account] = {
entries: [],
entries_group_by_voucher: {},
opening: me.make_summary_row("Opening", item.account),
totals: me.make_summary_row("Totals", item.account),
closing: me.make_summary_row("Closing (Opening + Totals)",
item.account)
};
}
if(!grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]) {
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no] = {
row: {},
totals: {"debit": 0, "credit": 0}
}
}
if(date < from_date || item.is_opening=="Yes") {
opening.debit += item.debit;
opening.credit += item.credit;
@ -216,9 +232,12 @@ 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]
.totals.credit += item.credit;
}
if(me.account) {
if(item.account) {
item.against_account = me.voucher_accounts[item.voucher_type + ":"
+ item.voucher_no][(item.debit > 0 ? "credits" : "debits")].join(", ");
}
@ -226,6 +245,11 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
if(me.apply_filters(item) && item.is_opening=="No") {
out.push(item);
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 = jQuery.extend({}, item);
}
}
}
});
@ -243,6 +267,11 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
out = this.group_data_by_ledger(grouped_ledgers);
}
if(this.account_by_name[this.account].group_or_ledger==="Ledger"
&& this.group_by_voucher) {
out = this.group_data_by_voucher(grouped_ledgers);
}
opening = me.get_balance(me.account_by_name[me.account].debit_or_credit, opening)
closing = me.get_balance(me.account_by_name[me.account].debit_or_credit, closing)
@ -285,6 +314,27 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
return [{id: "_blank_first", _no_format: true, debit: "", credit: ""}].concat(out);
},
group_data_by_voucher: function(grouped_ledgers) {
var me = this;
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),
function(j, voucher) {
voucher_dict = grouped_ledgers[account].entries_group_by_voucher[voucher];
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_grouped_by_" + voucher
out = out.concat(voucher_dict.row);
}
});
}
});
return [{id: "_blank_first", _no_format: true, debit: "", credit: ""}].concat(out);
},
get_balance: function(debit_or_credit, balance) {
if(debit_or_credit == "Debit") {
balance.debit -= balance.credit; balance.credit = 0;

View File

@ -1,7 +1,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes import _
from webnotes.utils import flt, comma_and
from webnotes.utils import flt, comma_and, cstr
import webnotes.defaults
@webnotes.whitelist()
@ -31,13 +31,12 @@ def get_template():
"3. Naming Series Options: %(naming_options)s"
"4. Voucher Type Options: %(voucher_type)s"%(extra_note)s
"-------Common Values-----------"
"Company:","%(default_company)s"
"Company:",
"--------Data----------"
%(columns)s
''' % {
"template_type": template_type,
"user_fmt": webnotes.defaults.get_global_default('date_format'),
"default_company": webnotes.conn.get_default("company"),
"naming_options": naming_options.replace("\n", ", "),
"voucher_type": voucher_type.replace("\n", ", "),
"extra_note": extra_note,
@ -49,14 +48,29 @@ def get_template():
@webnotes.whitelist()
def upload():
from webnotes.utils.datautils import read_csv_content_from_uploaded_file
rows = read_csv_content_from_uploaded_file()
common_values = get_common_values(rows)
company_abbr = webnotes.conn.get_value("Company", common_values.company, "abbr")
data, start_idx = get_data(rows, company_abbr)
messages = []
try:
from webnotes.utils.datautils import read_csv_content_from_uploaded_file
rows = read_csv_content_from_uploaded_file()
common_values = get_common_values(rows)
company_abbr = webnotes.conn.get_value("Company", common_values.company, "abbr")
if not company_abbr:
webnotes.msgprint(_("Company is missing or entered incorrect value"), raise_exception=1)
data, start_idx = get_data(rows, company_abbr, rows[0][0])
except Exception, e:
err_msg = webnotes.message_log and "<br>".join(webnotes.message_log) or cstr(e)
messages.append("""<p style='color: red'>%s</p>""" % (err_msg or "No message"))
webnotes.errprint(webnotes.getTraceback())
webnotes.message_log = []
return messages
return import_vouchers(common_values, data, start_idx, rows[0][0])
def map_fields(field_list, source, target):
for f in field_list:
@ -70,9 +84,8 @@ def import_vouchers(common_values, data, start_idx, import_type):
from webnotes.model.bean import Bean
from accounts.utils import get_fiscal_year
from webnotes.utils.dateutils import parse_date
messages = []
def get_account_details(account):
acc_details = webnotes.conn.sql("""select is_pl_account,
master_name from tabAccount where name=%s""", account, as_dict=1)
@ -113,8 +126,9 @@ def import_vouchers(common_values, data, start_idx, import_type):
if d.ref_number:
if not d.ref_date:
raise webnotes.ValidationError, \
"""Ref Date is Mandatory if Ref Number is specified"""
webnotes.msgprint(_("Ref Date is Mandatory if Ref Number is specified"),
raise_exception=1)
d.ref_date = parse_date(d.ref_date)
d.company = common_values.company
@ -176,7 +190,7 @@ def import_vouchers(common_values, data, start_idx, import_type):
webnotes.conn.commit()
except Exception, e:
webnotes.conn.rollback()
err_msg = webnotes.message_log and "<br>".join(webnotes.message_log) or unicode(e)
err_msg = webnotes.message_log and "<br>".join(webnotes.message_log) or cstr(e)
messages.append("""<p style='color: red'>[row #%s] %s failed: %s</p>"""
% ((start_idx + 1) + i, jv.name or "", err_msg or "No message"))
messages.append("<p style='color: red'>All transactions rolled back</p>")
@ -199,10 +213,11 @@ def get_common_values(rows):
return common_values
def get_data(rows, company_abbr):
def get_data(rows, company_abbr, import_type):
start_row = 0
data = []
start_row_idx = 0
accounts = None
for i in xrange(len(rows)):
r = rows[i]
if r[0]:
@ -240,16 +255,22 @@ def get_data(rows, company_abbr):
raise Exception, """Column No(s). %s %s empty. \
Please remove them and try again.""" % (comma_and(empty_columns),
len(empty_columns)==1 and "is" or "are")
columns = [c.replace(" ", "_").lower() for c in rows[i+1]
if not c.endswith(" - " + company_abbr)]
accounts = [c for c in rows[i+1] if c.endswith(" - " + company_abbr)]
if accounts and (len(columns) != rows[i+1].index(accounts[0])):
raise Exception, _("""All account columns should be after \
standard columns and on the right.
If you entered it properly, next probable reason \
could be wrong account name.
Please rectify it in the file and try again.""")
if import_type == "Voucher Import: Multiple Accounts":
accounts = [c for c in rows[i+1] if c.endswith(" - " + company_abbr)]
if not accounts:
webnotes.msgprint(_("""No Account found in csv file,
May be company abbreviation is not correct"""), raise_exception=1)
if accounts and (len(columns) != rows[i+1].index(accounts[0])):
webnotes.msgprint(_("""All account columns should be after \
standard columns and on the right.
If you entered it properly, next probable reason \
could be wrong account name.
Please rectify it in the file and try again."""), raise_exception=1)
return data, start_row_idx

View File

@ -0,0 +1,42 @@
wn.query_reports["Accounts Payable"] = {
"filters": [
{
"fieldname":"company",
"label": "Company",
"fieldtype": "Link",
"options": "Company",
"default": sys_defaults.company
},
{
"fieldname":"account",
"label": "Account",
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
var company = wn.query_report.filters_by_name.company.get_value();
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"debit_or_credit": "Credit",
"company": company,
"master_type": "Supplier"
}
}
}
},
{
"fieldname":"report_date",
"label": "Date",
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"ageing_based_on",
"label": "Ageing Based On",
"fieldtype": "Select",
"options": 'Posting Date' + NEWLINE + 'Due Date',
"default": "Posting Date"
}
]
}

View File

@ -0,0 +1,132 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import getdate, nowdate, flt, cstr
from webnotes import msgprint, _
from accounts.report.accounts_receivable.accounts_receivable import get_ageing_data
def execute(filters=None):
if not filters: filters = {}
columns = get_columns()
entries = get_gl_entries(filters)
entries_after_report_date = [[gle.voucher_type, gle.voucher_no]
for gle in get_gl_entries(filters, before_report_date=False)]
account_supplier_type_map = get_account_supplier_type_map()
pi_map = get_pi_map()
# Age of the invoice on this date
age_on = getdate(filters.get("report_date")) > getdate(nowdate()) \
and nowdate() or filters.get("report_date")
data = []
for gle in entries:
if cstr(gle.against_voucher) == gle.voucher_no or not gle.against_voucher \
or [gle.against_voucher_type, gle.against_voucher] in entries_after_report_date:
if gle.voucher_type == "Purchase Invoice":
pi_info = pi_map.get(gle.voucher_no)
due_date = pi_info.get("due_date")
bill_no = pi_info.get("bill_no")
bill_date = pi_info.get("bill_date")
else:
due_date = bill_no = bill_date = ""
invoiced_amount = gle.credit > 0 and gle.credit or 0
paid_amount = get_paid_amount(gle, filters.get("report_date") or nowdate(),
entries_after_report_date)
outstanding_amount = invoiced_amount - paid_amount
if abs(flt(outstanding_amount)) > 0.01:
row = [gle.posting_date, gle.account, gle.voucher_type, gle.voucher_no,
gle.remarks, account_supplier_type_map.get(gle.account), due_date, bill_no,
bill_date, invoiced_amount, paid_amount, outstanding_amount]
# Ageing
if filters.get("ageing_based_on") == "Due Date":
ageing_based_on_date = due_date
else:
ageing_based_on_date = gle.posting_date
row += get_ageing_data(ageing_based_on_date, age_on, outstanding_amount)
data.append(row)
return columns, data
def get_columns():
return [
"Posting Date:Date:80", "Account:Link/Account:150", "Voucher Type::110",
"Voucher No::120", "Remarks::150", "Supplier Type:Link/Supplier Type:120",
"Due Date:Date:80", "Bill No::80", "Bill Date:Date:80",
"Invoiced Amount:Currency:100", "Paid Amount:Currency:100",
"Outstanding Amount:Currency:100", "Age:Int:50", "0-30:Currency:100",
"30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100"
]
def get_gl_entries(filters, before_report_date=True):
conditions, supplier_accounts = get_conditions(filters, before_report_date)
gl_entries = []
gl_entries = webnotes.conn.sql("""select * from `tabGL Entry`
where ifnull(is_cancelled, 'No') = 'No' %s order by posting_date, account""" %
(conditions), tuple(supplier_accounts), as_dict=1)
return gl_entries
def get_conditions(filters, before_report_date=True):
conditions = ""
if filters.get("company"):
conditions += " and company='%s'" % filters["company"]
supplier_accounts = []
if filters.get("account"):
supplier_accounts = [filters["account"]]
else:
supplier_accounts = webnotes.conn.sql_list("""select name from `tabAccount`
where ifnull(master_type, '') = 'Supplier' and docstatus < 2 %s""" %
conditions, filters)
if supplier_accounts:
conditions += " and account in (%s)" % (", ".join(['%s']*len(supplier_accounts)))
else:
msgprint(_("No Supplier Accounts found. Supplier Accounts are identified based on \
'Master Type' value in account record."), raise_exception=1)
if filters.get("report_date"):
if before_report_date:
conditions += " and posting_date<='%s'" % filters["report_date"]
else:
conditions += " and posting_date>'%s'" % filters["report_date"]
return conditions, supplier_accounts
def get_account_supplier_type_map():
account_supplier_type_map = {}
for each in webnotes.conn.sql("""select t2.name, t1.supplier_type from `tabSupplier` t1,
`tabAccount` t2 where t1.name = t2.master_name group by t2.name"""):
account_supplier_type_map[each[0]] = each[1]
return account_supplier_type_map
def get_pi_map():
""" get due_date from sales invoice """
pi_map = {}
for t in webnotes.conn.sql("""select name, due_date, bill_no, bill_date
from `tabPurchase Invoice`""", as_dict=1):
pi_map[t.name] = t
return pi_map
def get_paid_amount(gle, report_date, entries_after_report_date):
paid_amount = 0
if flt(gle.debit) > 0 and (not gle.against_voucher or
[gle.against_voucher_type, gle.against_voucher] in entries_after_report_date):
paid_amount = gle.debit
elif flt(gle.credit) > 0:
paid_amount = webnotes.conn.sql("""
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) from `tabGL Entry`
where account = %s and posting_date <= %s and against_voucher_type = %s
and against_voucher = %s and name != %s and ifnull(is_cancelled, 'No') = 'No'""",
(gle.account, report_date, gle.voucher_type, gle.voucher_no, gle.name))[0][0]
return flt(paid_amount)

View File

@ -0,0 +1,22 @@
[
{
"creation": "2013-04-22 16:16:03",
"docstatus": 0,
"modified": "2013-04-30 17:55:54",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"add_total_row": 1,
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Purchase Invoice",
"report_name": "Accounts Payable",
"report_type": "Report Builder"
},
{
"doctype": "Report",
"name": "Accounts Payable"
}
]

View File

@ -0,0 +1,42 @@
wn.query_reports["Accounts Receivable"] = {
"filters": [
{
"fieldname":"company",
"label": "Company",
"fieldtype": "Link",
"options": "Company",
"default": sys_defaults.company
},
{
"fieldname":"account",
"label": "Account",
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
var company = wn.query_report.filters_by_name.company.get_value();
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"debit_or_credit": "Debit",
"company": company,
"master_type": "Customer"
}
}
}
},
{
"fieldname":"report_date",
"label": "Date",
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"ageing_based_on",
"label": "Ageing Based On",
"fieldtype": "Select",
"options": 'Posting Date' + NEWLINE + 'Due Date',
"default": "Posting Date"
}
]
}

View File

@ -0,0 +1,135 @@
from __future__ import unicode_literals
import webnotes
from webnotes import msgprint, _
from webnotes.utils import getdate, nowdate, flt, cstr
def execute(filters=None):
if not filters: filters = {}
columns = get_columns()
entries = get_gl_entries(filters)
entries_after_report_date = [[gle.voucher_type, gle.voucher_no]
for gle in get_gl_entries(filters, upto_report_date=False)]
account_territory_map = get_account_territory_map()
si_due_date_map = get_si_due_date_map()
# Age of the invoice on this date
age_on = getdate(filters.get("report_date")) > getdate(nowdate()) \
and nowdate() or filters.get("report_date")
data = []
for gle in entries:
if cstr(gle.against_voucher) == gle.voucher_no or not gle.against_voucher \
or [gle.against_voucher_type, gle.against_voucher] in entries_after_report_date:
due_date = (gle.voucher_type == "Sales Invoice") \
and si_due_date_map.get(gle.voucher_no) or ""
invoiced_amount = gle.debit > 0 and gle.debit or 0
payment_amount = get_payment_amount(gle, filters.get("report_date") or nowdate(),
entries_after_report_date)
outstanding_amount = invoiced_amount - payment_amount
if abs(flt(outstanding_amount)) > 0.01:
row = [gle.posting_date, gle.account, gle.voucher_type, gle.voucher_no,
gle.remarks, due_date, account_territory_map.get(gle.account),
invoiced_amount, payment_amount, outstanding_amount]
# Ageing
if filters.get("ageing_based_on") == "Due Date":
ageing_based_on_date = due_date
else:
ageing_based_on_date = gle.posting_date
row += get_ageing_data(ageing_based_on_date, age_on, outstanding_amount)
data.append(row)
return columns, data
def get_columns():
return [
"Posting Date:Date:80", "Account:Link/Account:150", "Voucher Type::110",
"Voucher No::120", "Remarks::150", "Due Date:Date:80", "Territory:Link/Territory:80",
"Invoiced Amount:Currency:100", "Payment Received:Currency:100",
"Outstanding Amount:Currency:100", "Age:Int:50", "0-30:Currency:100",
"30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100"
]
def get_gl_entries(filters, upto_report_date=True):
conditions, customer_accounts = get_conditions(filters, upto_report_date)
return webnotes.conn.sql("""select * from `tabGL Entry`
where ifnull(is_cancelled, 'No') = 'No' %s order by posting_date, account""" %
(conditions), tuple(customer_accounts), as_dict=1)
def get_conditions(filters, upto_report_date=True):
conditions = ""
if filters.get("company"):
conditions += " and company='%s'" % filters["company"]
customer_accounts = []
if filters.get("account"):
customer_accounts = [filters["account"]]
else:
customer_accounts = webnotes.conn.sql_list("""select name from `tabAccount`
where ifnull(master_type, '') = 'Customer' and docstatus < 2 %s""" %
conditions, filters)
if customer_accounts:
conditions += " and account in (%s)" % (", ".join(['%s']*len(customer_accounts)))
else:
msgprint(_("No Customer Accounts found. Customer Accounts are identified based on \
'Master Type' value in account record."), raise_exception=1)
if filters.get("report_date"):
if upto_report_date:
conditions += " and posting_date<='%s'" % filters["report_date"]
else:
conditions += " and posting_date>'%s'" % filters["report_date"]
return conditions, customer_accounts
def get_account_territory_map():
account_territory_map = {}
for each in webnotes.conn.sql("""select t2.name, t1.territory from `tabCustomer` t1,
`tabAccount` t2 where t1.name = t2.master_name"""):
account_territory_map[each[0]] = each[1]
return account_territory_map
def get_si_due_date_map():
""" get due_date from sales invoice """
si_due_date_map = {}
for t in webnotes.conn.sql("""select name, due_date from `tabSales Invoice`"""):
si_due_date_map[t[0]] = t[1]
return si_due_date_map
def get_payment_amount(gle, report_date, entries_after_report_date):
payment_amount = 0
if flt(gle.credit) > 0 and (not gle.against_voucher or
[gle.against_voucher_type, gle.against_voucher] in entries_after_report_date):
payment_amount = gle.credit
elif flt(gle.debit) > 0:
payment_amount = webnotes.conn.sql("""
select sum(ifnull(credit, 0)) - sum(ifnull(debit, 0)) from `tabGL Entry`
where account = %s and posting_date <= %s and against_voucher_type = %s
and against_voucher = %s and name != %s and ifnull(is_cancelled, 'No') = 'No'""",
(gle.account, report_date, gle.voucher_type, gle.voucher_no, gle.name))[0][0]
return flt(payment_amount)
def get_ageing_data(ageing_based_on_date, age_on, outstanding_amount):
val1 = val2 = val3 = val4 = diff = 0
diff = age_on and ageing_based_on_date \
and (getdate(age_on) - getdate(ageing_based_on_date)).days or 0
if diff <= 30:
val1 = outstanding_amount
elif 30 < diff <= 60:
val2 = outstanding_amount
elif 60 < diff <= 90:
val3 = outstanding_amount
elif diff > 90:
val4 = outstanding_amount
return [diff, val1, val2, val3, val4]

View File

@ -0,0 +1,22 @@
[
{
"creation": "2013-04-16 11:31:13",
"docstatus": 0,
"modified": "2013-05-24 12:02:52",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"add_total_row": 1,
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Sales Invoice",
"report_name": "Accounts Receivable",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Accounts Receivable"
}
]

View File

@ -0,0 +1,32 @@
wn.query_reports["Bank Clearance Summary"] = {
"filters": [
{
"fieldname":"from_date",
"label": "From Date",
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": "To Date",
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"account",
"label": "Bank Account",
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"account_type": "Bank or Cash"
}
}
}
},
]
}

View File

@ -0,0 +1,54 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from webnotes import _, msgprint
def execute(filters=None):
if not filters: filters = {}
columns = get_columns()
data = get_entries(filters)
return columns, data
def get_columns():
return ["Journal Voucher:Link/Journal Voucher:140", "Account:Link/Account:140",
"Posting Date:Date:100", "Clearance Date:Date:110", "Against Account:Link/Account:200",
"Debit:Currency:120", "Credit:Currency:120"
]
def get_conditions(filters):
conditions = ""
if not filters.get("account"):
msgprint(_("Please select Bank Account"), raise_exception=1)
else:
conditions += " and jvd.account = %(account)s"
if filters.get("from_date"): conditions += " and jv.posting_date>=%(from_date)s"
if filters.get("to_date"): conditions += " and jv.posting_date<=%(to_date)s"
return conditions
def get_entries(filters):
conditions = get_conditions(filters)
entries = webnotes.conn.sql("""select jv.name, jvd.account, jv.posting_date,
jv.clearance_date, jvd.against_account, jvd.debit, jvd.credit
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
where jvd.parent = jv.name and jv.docstatus=1 %s
order by jv.name DESC""" % conditions, filters, as_list=1)
return entries

View File

@ -0,0 +1,21 @@
[
{
"creation": "2013-05-01 12:13:25",
"docstatus": 0,
"modified": "2013-05-01 12:13:25",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Journal Voucher",
"report_name": "Bank Clearance Summary",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Bank Clearance Summary"
}
]

View File

@ -0,0 +1,25 @@
wn.query_reports["Bank Reconciliation Statement"] = {
"filters": [
{
"fieldname":"account",
"label": "Bank Account",
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"account_type": "Bank or Cash"
}
}
}
},
{
"fieldname":"report_date",
"label": "Date",
"fieldtype": "Date",
"default": get_today()
},
]
}

View File

@ -0,0 +1,79 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from webnotes import _, msgprint
from webnotes.utils import flt
def execute(filters=None):
if not filters: filters = {}
columns = get_columns()
data = get_entries(filters)
from accounts.utils import get_balance_on
balance_as_per_company = get_balance_on(filters["account"], filters["report_date"])
total_debit, total_credit = 0,0
for d in data:
total_debit += flt(d[4])
total_credit += flt(d[5])
if webnotes.conn.get_value("Account", filters["account"], "debit_or_credit") == 'Debit':
bank_bal = flt(balance_as_per_company) - flt(total_debit) + flt(total_credit)
else:
bank_bal = flt(balance_as_per_company) + flt(total_debit) - flt(total_credit)
data += [
["", "", "", "Balance as per company books", balance_as_per_company, ""],
["", "", "", "Amounts not reflected in bank", total_debit, total_credit],
["", "", "", "Balance as per bank", bank_bal, ""]
]
return columns, data
def get_columns():
return ["Journal Voucher:Link/Journal Voucher:140", "Posting Date:Date:100",
"Clearance Date:Date:110", "Against Account:Link/Account:200",
"Debit:Currency:120", "Credit:Currency:120"
]
def get_conditions(filters):
conditions = ""
if not filters.get("account"):
msgprint(_("Please select Bank Account"), raise_exception=1)
else:
conditions += " and jvd.account = %(account)s"
if not filters.get("report_date"):
msgprint(_("Please select Date on which you want to run the report"), raise_exception=1)
else:
conditions += """ and jv.posting_date <= %(report_date)s
and ifnull(jv.clearance_date, '4000-01-01') > %(report_date)s"""
return conditions
def get_entries(filters):
conditions = get_conditions(filters)
entries = webnotes.conn.sql("""select jv.name, jv.posting_date, jv.clearance_date,
jvd.against_account, jvd.debit, jvd.credit
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
where jvd.parent = jv.name and jv.docstatus=1 and ifnull(jv.cheque_no, '')!= '' %s
order by jv.name DESC""" % conditions, filters, as_list=1)
return entries

View File

@ -0,0 +1,22 @@
[
{
"creation": "2013-04-30 18:30:21",
"docstatus": 0,
"modified": "2013-05-01 10:53:12",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"add_total_row": 0,
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Journal Voucher",
"report_name": "Bank Reconciliation Statement",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Bank Reconciliation Statement"
}
]

View File

@ -0,0 +1,25 @@
wn.query_reports["Budget Variance Report"] = {
"filters": [
{
fieldname: "fiscal_year",
label: "Fiscal Year",
fieldtype: "Link",
options: "Fiscal Year",
default: sys_defaults.fiscal_year
},
{
fieldname: "period",
label: "Period",
fieldtype: "Select",
options: "Monthly\nQuarterly\nHalf-Yearly\nYearly",
default: "Monthly"
},
{
fieldname: "company",
label: "Company",
fieldtype: "Link",
options: "Company",
default: sys_defaults.company
},
]
}

View File

@ -0,0 +1,130 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
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"], 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():
for account, monthwise_data in cost_center_items.items():
row = [cost_center, account]
totals = [0, 0, 0]
for relevant_months in period_month_ranges:
period_data = [0, 0, 0]
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), precision)
period_data[i] += value
totals[i] += value
period_data[2] = period_data[0] - period_data[1]
row += period_data
totals[2] = totals[0] - totals[1]
row += totals
data.append(row)
return columns, sorted(data, key=lambda x: (x[0], x[1]))
def get_columns(filters):
for fieldname in ["fiscal_year", "period", "company"]:
if not filters.get(fieldname):
label = (" ".join(fieldname.split("_"))).title()
msgprint(_("Please specify") + ": " + label,
raise_exception=True)
columns = ["Cost Center:Link/Cost Center:100", "Account:Link/Account:100"]
group_months = False if filters["period"] == "Monthly" else True
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")))
else:
columns.append(label % from_date.strftime("%b"))
return columns + ["Total Target::80", "Total Actual::80", "Total Variance::80"]
#Get cost center & target details
def get_costcenter_target_details(filters):
return webnotes.conn.sql("""select cc.name, cc.distribution_id,
cc.parent_cost_center, bd.account, bd.budget_allocated
from `tabCost Center` cc, `tabBudget Detail` bd
where bd.parent=cc.name and bd.fiscal_year=%s and
cc.company_name=%s and ifnull(cc.distribution_id, '')!=''
order by cc.name""" % ('%s', '%s'),
(filters.get("fiscal_year"), filters.get("company")), as_dict=1)
#Get target distribution details of accounts of cost center
def get_target_distribution_details(filters):
target_details = {}
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""", (filters["fiscal_year"]), as_dict=1):
target_details.setdefault(d.month, d)
return target_details
#Get actual details from gl entry
def get_actual_details(filters):
return webnotes.conn.sql("""select gl.account, gl.debit, gl.credit,
gl.cost_center, MONTHNAME(gl.posting_date) as month_name
from `tabGL Entry` gl, `tabBudget Detail` bd
where gl.fiscal_year=%s and company=%s and is_cancelled='No'
and bd.account=gl.account""" % ('%s', '%s'),
(filters.get("fiscal_year"), filters.get("company")), as_dict=1)
def get_costcenter_account_month_map(filters):
costcenter_target_details = get_costcenter_target_details(filters)
tdd = get_target_distribution_details(filters)
actual_details = get_actual_details(filters)
cam_map = {}
for ccd in costcenter_target_details:
for month in tdd:
cam_map.setdefault(ccd.name, {}).setdefault(ccd.account, {})\
.setdefault(month, webnotes._dict({
"target": 0.0, "actual": 0.0
}))
tav_dict = cam_map[ccd.name][ccd.account][month]
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

View File

@ -0,0 +1,21 @@
[
{
"creation": "2013-06-18 12:56:36",
"docstatus": 0,
"modified": "2013-06-18 12:56:36",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Cost Center",
"report_name": "Budget Variance Report",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Budget Variance Report"
}
]

View File

@ -0,0 +1,49 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
def execute(filters=None):
account_map = get_account_map()
columns = get_columns(account_map)
data = []
customers = webnotes.conn.sql("select name from tabCustomer where docstatus < 2")
for cust in customers:
row = [cust[0]]
for company in sorted(account_map):
row.append(account_map[company].get(cust[0], ''))
data.append(row)
return columns, data
def get_account_map():
accounts = webnotes.conn.sql("""select name, company, master_name
from `tabAccount` where master_type = 'Customer'
and ifnull(master_name, '') != '' and docstatus < 2""", as_dict=1)
account_map = {}
for acc in accounts:
account_map.setdefault(acc.company, {}).setdefault(acc.master_name, {})
account_map[acc.company][acc.master_name] = acc.name
return account_map
def get_columns(account_map):
columns = ["Customer:Link/Customer:120"] + \
[(company + ":Link/Account:120") for company in sorted(account_map)]
return columns

View File

@ -0,0 +1,21 @@
[
{
"creation": "2013-06-03 16:17:34",
"docstatus": 0,
"modified": "2013-06-03 16:17:34",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Account",
"report_name": "Customer Account Head",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Customer Account Head"
}
]

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-02-22 17:55:23",
"creation": "2013-05-02 15:20:25",
"docstatus": 0,
"modified": "2013-02-23 14:35:28",
"modified": "2013-07-08 11:08:23",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -10,7 +10,7 @@
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"query": "select \n `tabDelivery Note`.`name` as \"Delivery Note:Link/Delivery Note:120\",\n`tabDelivery Note`.`customer` as \"Customer:Link/Customer:120\",\n`tabDelivery Note`.`status` as \"Status\",\n `tabDelivery Note`.`posting_date` as \"Date:Date\",\n `tabDelivery Note`.`project_name` as \"Project\",\n `tabDelivery Note Item`.item_code as \"Item:Link/Item:120\",\n `tabDelivery Note Item`.amount as \"Amount:Currency:110\",\n (`tabDelivery Note Item`.billed_amt * ifnull(`tabDelivery Note`.conversion_rate, 1)) as \"Billed Amount:Currency:110\",\n (ifnull(`tabDelivery Note Item`.amount,0) - (ifnull(`tabDelivery Note Item`.billed_amt,0) * ifnull(`tabDelivery Note`.conversion_rate, 1))) as \"Pending Amount:Currency:120\",\n `tabDelivery Note Item`.item_name as \"Item Name::150\",\n `tabDelivery Note Item`.description as \"Description:Data:200\"\nfrom\n `tabDelivery Note`, `tabDelivery Note Item`\nwhere\n `tabDelivery Note Item`.`parent` = `tabDelivery Note`.`name`\n and `tabDelivery Note`.docstatus = 1\n and `tabDelivery Note`.status != \"Stopped\"\n and ifnull(`tabDelivery Note Item`.billed_amt,0) < ifnull(`tabDelivery Note Item`.export_amount,0)\norder by `tabDelivery Note`.posting_date asc",
"query": "select \n `tabDelivery Note`.`name` as \"Delivery Note:Link/Delivery Note:120\",\n`tabDelivery Note`.`customer` as \"Customer:Link/Customer:120\",\n`tabDelivery Note`.`status` as \"Status\",\n `tabDelivery Note`.`posting_date` as \"Date:Date\",\n `tabDelivery Note`.`project_name` as \"Project\",\n `tabDelivery Note Item`.item_code as \"Item:Link/Item:120\",\n `tabDelivery Note Item`.amount as \"Amount:Currency:110\",\n (`tabDelivery Note Item`.billed_amt * ifnull(`tabDelivery Note`.conversion_rate, 1)) as \"Billed Amount:Currency:110\",\n (ifnull(`tabDelivery Note Item`.amount,0) - (ifnull(`tabDelivery Note Item`.billed_amt,0) * ifnull(`tabDelivery Note`.conversion_rate, 1))) as \"Pending Amount:Currency:120\",\n `tabDelivery Note Item`.item_name as \"Item Name::150\",\n `tabDelivery Note Item`.description as \"Description:Data:200\",\n `tabDelivery Note Item`.prevdoc_docname as \"Sales Order:Link/Sales Order:120\",\n `tabDelivery Note Item`.prevdoc_date as \"SO Date:Date:100\",\n `tabDelivery Note`.address_display as \"Customer Address::150\"\nfrom\n `tabDelivery Note`, `tabDelivery Note Item`\nwhere\n `tabDelivery Note Item`.`parent` = `tabDelivery Note`.`name`\n and `tabDelivery Note`.docstatus = 1\n and `tabDelivery Note`.status != \"Stopped\"\n and ifnull(`tabDelivery Note Item`.billed_amt,0) < ifnull(`tabDelivery Note Item`.export_amount,0)\norder by `tabDelivery Note`.posting_date asc",
"ref_doctype": "Sales Invoice",
"report_name": "Delivered Items To Be Billed",
"report_type": "Query Report"

View File

@ -0,0 +1,39 @@
wn.query_reports["Item-wise Purchase Register"] = {
"filters": [
{
"fieldname":"from_date",
"label": "From Date",
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": "To Date",
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname": "item_code",
"label": "Item",
"fieldtype": "Link",
"options": "Item",
},
{
"fieldname":"account",
"label": "Account",
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"debit_or_credit": "Credit",
"master_type": "Supplier"
}
}
}
}
]
}

View File

@ -0,0 +1,73 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
def execute(filters=None):
if not filters: filters = {}
columns = get_columns()
item_list = get_items(filters)
aii_account_map = get_aii_accounts()
data = []
for d in item_list:
expense_head = d.expense_head or aii_account_map.get(d.company)
data.append([d.item_code, d.item_name, d.item_group, d.name, d.posting_date,
d.supplier_name, d.credit_to, d.project_name, d.company, d.purchase_order,
d.purchase_receipt, expense_head, d.qty, d.rate, d.amount])
return columns, data
def get_columns():
return ["Item Code:Link/Item:120", "Item Name::120", "Item Group:Link/Item Group:100",
"Invoice:Link/Purchase Invoice:120", "Posting Date:Date:80", "Supplier:Link/Customer:120",
"Supplier Account:Link/Account:120", "Project:Link/Project:80", "Company:Link/Company:100",
"Purchase Order:Link/Purchase Order:100", "Purchase Receipt:Link/Purchase Receipt:100",
"Expense Account:Link/Account:140", "Qty:Float:120", "Rate:Currency:120",
"Amount:Currency:120"]
def get_conditions(filters):
conditions = ""
if filters.get("account"): conditions += " and pi.credit_to = %(account)s"
if filters.get("item_code"): conditions += " and pi_item.item_code = %(item_code)s"
if filters.get("from_date"): conditions += " and pi.posting_date>=%(from_date)s"
if filters.get("to_date"): conditions += " and pi.posting_date<=%(to_date)s"
return conditions
def get_items(filters):
conditions = get_conditions(filters)
return webnotes.conn.sql("""select pi.name, pi.posting_date, pi.credit_to, pi.company,
pi.supplier, pi.remarks, pi_item.item_code, pi_item.item_name, pi_item.item_group,
pi_item.project_name, pi_item.purchase_order, pi_item.purchase_receipt,
pi_item.expense_head, pi_item.qty, pi_item.rate, pi_item.amount, pi.supplier_name
from `tabPurchase Invoice` pi, `tabPurchase Invoice Item` pi_item
where pi.name = pi_item.parent and pi.docstatus = 1 %s
order by pi.posting_date desc, pi_item.item_code desc""" % conditions, filters, as_dict=1)
def get_aii_accounts():
aii_account_map = {}
for d in webnotes.conn.sql("select name, stock_received_but_not_billed from tabCompany",
as_dict=1):
aii_account_map.setdefault(d.name, d.stock_received_but_not_billed)
return aii_account_map

View File

@ -0,0 +1,22 @@
[
{
"creation": "2013-06-05 15:37:30",
"docstatus": 0,
"modified": "2013-06-05 15:37:30",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"add_total_row": 1,
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Purchase Invoice",
"report_name": "Item-wise Purchase Register",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Item-wise Purchase Register"
}
]

View File

@ -0,0 +1,39 @@
wn.query_reports["Item-wise Sales Register"] = {
"filters": [
{
"fieldname":"from_date",
"label": "From Date",
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": "To Date",
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname": "item_code",
"label": "Item",
"fieldtype": "Link",
"options": "Item",
},
{
"fieldname":"account",
"label": "Account",
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"debit_or_credit": "Debit",
"master_type": "Customer"
}
}
}
}
]
}

View File

@ -0,0 +1,66 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
def execute(filters=None):
if not filters: filters = {}
columns = get_columns()
item_list = get_items(filters)
data = []
for d in item_list:
data.append([d.item_code, d.item_name, d.item_group, d.name, d.posting_date,
d.customer_name, d.debit_to, d.territory, d.project_name, d.company, d.sales_order,
d.delivery_note, d.income_account, d.qty, d.basic_rate, d.amount])
return columns, data
def get_columns():
return [
"Item Code:Link/Item:120", "Item Name::120", "Item Group:Link/Item Group:100",
"Invoice:Link/Sales Invoice:120", "Posting Date:Date:80", "Customer:Link/Customer:120",
"Customer Account:Link/Account:120", "Territory:Link/Territory:80",
"Project:Link/Project:80", "Company:Link/Company:100", "Sales Order:Link/Sales Order:100",
"Delivery Note:Link/Delivery Note:100", "Income Account:Link/Account:140",
"Qty:Float:120", "Rate:Currency:120", "Amount:Currency:120"
]
def get_conditions(filters):
conditions = ""
if filters.get("account"): conditions += " and si.debit_to = %(account)s"
if filters.get("item_code"): conditions += " and si_item.item_code = %(item_code)s"
if filters.get("from_date"): conditions += " and si.posting_date>=%(from_date)s"
if filters.get("to_date"): conditions += " and si.posting_date<=%(to_date)s"
return conditions
def get_items(filters):
conditions = get_conditions(filters)
return webnotes.conn.sql("""select si.name, si.posting_date, si.debit_to, si.project_name,
si.customer, si.remarks, si.territory, si.company, si_item.item_code, si_item.item_name,
si_item.item_group, si_item.sales_order, si_item.delivery_note, si_item.income_account,
si_item.qty, si_item.basic_rate, si_item.amount, si.customer_name
from `tabSales Invoice` si, `tabSales Invoice Item` si_item
where si.name = si_item.parent and si.docstatus = 1 %s
order by si.posting_date desc, si_item.item_code desc""" % conditions, filters, as_dict=1)

View File

@ -0,0 +1,22 @@
[
{
"creation": "2013-05-13 17:50:55",
"docstatus": 0,
"modified": "2013-05-13 17:50:55",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"add_total_row": 1,
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Sales Invoice",
"report_name": "Item-wise Sales Register",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Item-wise Sales Register"
}
]

View File

@ -0,0 +1,42 @@
wn.query_reports["Payment Collection With Ageing"] = {
"filters": [
{
"fieldname": "from_date",
"label": "From Date",
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": "To Date",
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"account",
"label": "Customer Account",
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
var company = wn.query_report.filters_by_name.company.get_value();
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"debit_or_credit": "Debit",
"company": company,
"master_type": "Customer"
}
}
}
},
{
"fieldname":"company",
"label": "Company",
"fieldtype": "Link",
"options": "Company",
"default": sys_defaults.company
},
]
}

View File

@ -0,0 +1,90 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from webnotes import msgprint, _
from accounts.report.accounts_receivable.accounts_receivable import get_ageing_data
def execute(filters=None):
if not filters: filters = {}
columns = get_columns()
entries = get_entries(filters)
si_posting_date_map = get_si_posting_date_map()
data = []
for d in entries:
against_invoice_date = d.against_invoice and si_posting_date_map[d.against_invoice] or ""
row = [d.name, d.account, d.posting_date, d.against_invoice, against_invoice_date,
d.debit, d.credit, d.cheque_no, d.cheque_date, d.remark]
if d.against_invoice:
row += get_ageing_data(against_invoice_date, d.posting_date, d.credit or -1*d.debit)
else:
row += ["", "", "", "", ""]
data.append(row)
return columns, data
def get_columns():
return ["Journal Voucher:Link/Journal Voucher:140", "Account:Link/Account:140",
"Posting Date:Date:100", "Against Invoice:Link/Sales Invoice:130",
"Against Invoice Posting Date:Date:130", "Debit:Currency:120", "Credit:Currency:120",
"Reference No::100", "Reference Date:Date:100", "Remarks::150", "Age:Int:40",
"0-30:Currency:100", "30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100"
]
def get_conditions(filters):
conditions = ""
customer_accounts = []
if filters.get("account"):
customer_accounts = [filters["account"]]
else:
cond = filters.get("company") and (" and company = '%s'" % filters["company"]) or ""
customer_accounts = webnotes.conn.sql_list("""select name from `tabAccount`
where ifnull(master_type, '') = 'Customer' and docstatus < 2 %s""" % cond)
if customer_accounts:
conditions += " and jvd.account in (%s)" % (", ".join(['%s']*len(customer_accounts)))
else:
msgprint(_("No Customer Accounts found. Customer Accounts are identified based on \
'Master Type' value in account record."), raise_exception=1)
if filters.get("from_date"): conditions += " and jv.posting_date >= '%s'" % filters["from_date"]
if filters.get("to_date"): conditions += " and jv.posting_date <= '%s'" % filters["to_date"]
return conditions, customer_accounts
def get_entries(filters):
conditions, customer_accounts = get_conditions(filters)
entries = webnotes.conn.sql("""select jv.name, jvd.account, jv.posting_date,
jvd.against_invoice, jvd.debit, jvd.credit, jv.cheque_no, jv.cheque_date, jv.remark
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
where jvd.parent = jv.name and jv.docstatus=1 %s order by jv.name DESC""" %
(conditions), tuple(customer_accounts), as_dict=1)
return entries
def get_si_posting_date_map():
si_posting_date_map = {}
for t in webnotes.conn.sql("""select name, posting_date from `tabSales Invoice`"""):
si_posting_date_map[t[0]] = t[1]
return si_posting_date_map

View File

@ -0,0 +1,22 @@
[
{
"creation": "2013-05-02 12:09:51",
"docstatus": 0,
"modified": "2013-05-02 12:09:51",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"add_total_row": 1,
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Journal Voucher",
"report_name": "Payment Collection With Ageing",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Payment Collection With Ageing"
}
]

View File

@ -0,0 +1,40 @@
wn.query_reports["Payment Made With Ageing"] = {
"filters": [
{
fieldname: "from_date",
label: "From Date",
fieldtype: "Date",
default: wn.defaults.get_user_default("year_start_date"),
},
{
fieldname:"to_date",
label: "To Date",
fieldtype: "Date",
default: get_today()
},
{
fieldname:"account",
label: "Supplier Account",
fieldtype: "Link",
options: "Account",
get_query: function() {
return {
query: "accounts.utils.get_account_list",
filters: {
is_pl_account: "No",
debit_or_credit: "Credit",
company: wn.query_report.filters_by_name.company.get_value(),
master_type: "Supplier"
}
}
}
},
{
fieldname:"company",
label: "Company",
fieldtype: "Link",
options: "Company",
default: sys_defaults.company
},
]
}

View File

@ -0,0 +1,89 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from webnotes import msgprint, _
from accounts.report.accounts_receivable.accounts_receivable import get_ageing_data
def execute(filters=None):
if not filters: filters = {}
columns = get_columns()
entries = get_entries(filters)
pi_posting_date_map = get_pi_posting_date_map()
data = []
for d in entries:
against_voucher_date = d.against_voucher and pi_posting_date_map[d.against_voucher] or ""
row = [d.name, d.account, d.posting_date, d.against_voucher, against_voucher_date,
d.debit, d.credit, d.cheque_no, d.cheque_date, d.remark]
if d.against_voucher:
row += get_ageing_data(against_voucher_date, d.posting_date, d.debit or -1*d.credit)
else:
row += ["", "", "", "", ""]
data.append(row)
return columns, data
def get_columns():
return ["Journal Voucher:Link/Journal Voucher:140", "Account:Link/Account:140",
"Posting Date:Date:100", "Against Invoice:Link/Purchase Invoice:130",
"Against Invoice Posting Date:Date:130", "Debit:Currency:120", "Credit:Currency:120",
"Reference No::100", "Reference Date:Date:100", "Remarks::150", "Age:Int:40",
"0-30:Currency:100", "30-60:Currency:100", "60-90:Currency:100", "90-Above:Currency:100"
]
def get_conditions(filters):
conditions = ""
supplier_accounts = []
if filters.get("account"):
supplier_accounts = [filters["account"]]
else:
cond = filters.get("company") and (" and company = '%s'" % filters["company"]) or ""
supplier_accounts = webnotes.conn.sql_list("""select name from `tabAccount`
where ifnull(master_type, '') = 'Supplier' and docstatus < 2 %s""" % cond)
if supplier_accounts:
conditions += " and jvd.account in (%s)" % (", ".join(['%s']*len(supplier_accounts)))
else:
msgprint(_("No Supplier Accounts found. Supplier Accounts are identified based on \
'Master Type' value in account record."), raise_exception=1)
if filters.get("from_date"): conditions += " and jv.posting_date >= '%s'" % filters["from_date"]
if filters.get("to_date"): conditions += " and jv.posting_date <= '%s'" % filters["to_date"]
return conditions, supplier_accounts
def get_entries(filters):
conditions, supplier_accounts = get_conditions(filters)
entries = webnotes.conn.sql("""select jv.name, jvd.account, jv.posting_date,
jvd.against_voucher, jvd.debit, jvd.credit, jv.cheque_no, jv.cheque_date, jv.remark
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
where jvd.parent = jv.name and jv.docstatus=1 %s order by jv.name DESC""" %
(conditions), tuple(supplier_accounts), as_dict=1)
return entries
def get_pi_posting_date_map():
pi_posting_date_map = {}
for t in webnotes.conn.sql("""select name, posting_date from `tabPurchase Invoice`"""):
pi_posting_date_map[t[0]] = t[1]
return pi_posting_date_map

View File

@ -0,0 +1,22 @@
[
{
"creation": "2013-05-02 12:10:21",
"docstatus": 0,
"modified": "2013-05-02 12:10:21",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"add_total_row": 1,
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Journal Voucher",
"report_name": "Payment Made With Ageing",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Payment Made With Ageing"
}
]

View File

@ -0,0 +1,5 @@
wn.require("app/js/purchase_trends_filters.js");
wn.query_reports["Purchase Invoice Trends"] = {
filters: get_filters()
}

View File

@ -14,11 +14,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#check mendatory
from __future__ import unicode_literals
if not filter_values.get('posting_date') or not filter_values.get('posting_date1'):
msgprint("Please select From Posting Date and To Posting Date in 'Set Filters' section")
raise Exception
else:
from_date = filter_values.get('posting_date')
to_date = filter_values.get('posting_date1')
import webnotes
from controllers.trends import get_columns,get_data
def execute(filters=None):
if not filters: filters ={}
data = []
conditions = get_columns(filters, "Purchase Invoice")
data = get_data(filters, conditions)
return conditions["columns"], data

View File

@ -0,0 +1,21 @@
[
{
"creation": "2013-06-13 18:46:55",
"docstatus": 0,
"modified": "2013-06-13 18:46:55",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Purchase Invoice",
"report_name": "Purchase Invoice Trends",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Purchase Invoice Trends"
}
]

View File

@ -0,0 +1,23 @@
[
{
"creation": "2013-05-28 15:54:16",
"docstatus": 0,
"modified": "2013-05-28 16:02:57",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"add_total_row": 1,
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n `tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order Item`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Order Item`.billed_qty as \"Billed Qty:Float:100\", \n\t(`tabPurchase Order Item`.qty - ifnull(`tabPurchase Order Item`.billed_qty, 0)) as \"Qty to Bill:Float:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Order Item`.billed_qty, 0) < ifnull(`tabPurchase Order Item`.qty, 0)\norder by `tabPurchase Order`.transaction_date asc",
"ref_doctype": "Purchase Invoice",
"report_name": "Purchase Order Items To Be Billed",
"report_type": "Query Report"
},
{
"doctype": "Report",
"name": "Purchase Order Items To Be Billed"
}
]

View File

@ -0,0 +1,42 @@
wn.query_reports["Purchase Register"] = {
"filters": [
{
"fieldname":"from_date",
"label": "From Date",
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": "To Date",
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"account",
"label": "Account",
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
var company = wn.query_report.filters_by_name.company.get_value();
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"debit_or_credit": "Credit",
"company": company,
"master_type": "Supplier"
}
}
}
},
{
"fieldname":"company",
"label": "Company",
"fieldtype": "Link",
"options": "Company",
"default": sys_defaults.company
}
]
}

View File

@ -0,0 +1,179 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt
from webnotes import msgprint, _
def execute(filters=None):
if not filters: filters = {}
invoice_list = get_invoices(filters)
columns, expense_accounts, tax_accounts, renamed_columns = get_columns(invoice_list)
if not invoice_list:
msgprint(_("No record found"))
return columns, invoice_list
invoice_expense_map = get_invoice_expense_map(invoice_list)
invoice_tax_map = get_invoice_tax_map(invoice_list, renamed_columns)
invoice_po_pr_map = get_invoice_po_pr_map(invoice_list)
account_map = get_account_details(invoice_list)
data = []
for inv in invoice_list:
# invoice details
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", [])))
project_name = list(set(invoice_po_pr_map.get(inv.name, {}).get("project_name", [])))
row = [inv.name, inv.posting_date, inv.supplier_name, inv.credit_to,
account_map.get(inv.credit_to), ", ".join(project_name), inv.bill_no, inv.bill_date,
inv.remarks, ", ".join(purchase_order), ", ".join(purchase_receipt)]
# map expense values
for expense_acc in expense_accounts:
row.append(invoice_expense_map.get(inv.name, {}).get(expense_acc))
# net total
row.append(inv.net_total)
# tax account
for tax_acc in tax_accounts:
row.append(invoice_tax_map.get(inv.name, {}).get(tax_acc))
# total tax, grand total, outstanding amount & rounded total
row += [inv.total_tax, inv.grand_total, flt(inv.grand_total, 2), \
inv.outstanding_amount]
data.append(row)
return columns, data
def get_columns(invoice_list):
"""return columns based on filters"""
columns = [
"Invoice:Link/Purchase Invoice:120", "Posting Date:Date:80", "Supplier::120",
"Supplier Account:Link/Account:120", "Account Group:LInk/Account:120",
"Project:Link/Project:80", "Bill No::120", "Bill Date:Date:80", "Remarks::150",
"Purchase Order:Link/Purchase Order:100", "Purchase Receipt:Link/Purchase Receipt:100"
]
expense_accounts = tax_accounts = expense_columns = tax_columns = []
renamed_columns = {}
if invoice_list:
expense_accounts = webnotes.conn.sql_list("""select distinct expense_head
from `tabPurchase Invoice Item` where docstatus = 1 and ifnull(expense_head, '') != ''
and parent in (%s) order by expense_head""" %
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
tax_accounts = webnotes.conn.sql_list("""select distinct account_head
from `tabPurchase Taxes and Charges` where parenttype = 'Purchase Invoice'
and docstatus = 1 and ifnull(account_head, '') != '' and parent in (%s)
order by account_head""" %
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
expense_columns = [(account + ":Currency:120") for account in expense_accounts]
for account in tax_accounts:
if account in expense_accounts:
new_account = account + " (Tax)"
renamed_columns[account] = new_account
tax_columns.append(new_account + ":Currency:120")
else:
tax_columns.append(account + ":Currency:120")
columns = columns + expense_columns + \
["Net Total:Currency:120"] + tax_columns + \
["Total Tax:Currency:120"] + ["Grand Total:Currency:120"] + \
["Rounded Total:Currency:120"] + ["Outstanding Amount:Currency:120"]
return columns, expense_accounts, tax_accounts, renamed_columns
def get_conditions(filters):
conditions = ""
if filters.get("company"): conditions += " and company=%(company)s"
if filters.get("account"): conditions += " and credit_to = %(account)s"
if filters.get("from_date"): conditions += " and posting_date>=%(from_date)s"
if filters.get("to_date"): conditions += " and posting_date<=%(to_date)s"
return conditions
def get_invoices(filters):
conditions = get_conditions(filters)
return webnotes.conn.sql("""select name, posting_date, credit_to, supplier, supplier_name,
bill_no, bill_date, remarks, net_total, total_tax, grand_total, outstanding_amount
from `tabPurchase Invoice` where docstatus = 1 %s
order by posting_date desc, name desc""" % conditions, filters, as_dict=1)
def get_invoice_expense_map(invoice_list):
expense_details = webnotes.conn.sql("""select parent, expense_head, sum(amount) as amount
from `tabPurchase Invoice Item` where parent in (%s) group by parent, expense_head""" %
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
invoice_expense_map = {}
for d in expense_details:
invoice_expense_map.setdefault(d.parent, webnotes._dict()).setdefault(d.expense_head, [])
invoice_expense_map[d.parent][d.expense_head] = flt(d.amount)
return invoice_expense_map
def get_invoice_tax_map(invoice_list, renamed_columns):
tax_details = webnotes.conn.sql("""select parent, account_head, sum(tax_amount) as tax_amount
from `tabPurchase Taxes and Charges` where parent in (%s) group by parent, account_head""" %
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
invoice_tax_map = {}
for d in tax_details:
account = renamed_columns.get(d.account_head) or d.account_head
invoice_tax_map.setdefault(d.parent, webnotes._dict()).setdefault(account, [])
invoice_tax_map[d.parent][account] = flt(d.tax_amount)
return invoice_tax_map
def get_invoice_po_pr_map(invoice_list):
pi_items = webnotes.conn.sql("""select parent, purchase_order, purchase_receipt,
project_name from `tabPurchase Invoice Item` where parent in (%s)
and (ifnull(purchase_order, '') != '' or ifnull(purchase_receipt, '') != '')""" %
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
invoice_po_pr_map = {}
for d in pi_items:
if d.purchase_order:
invoice_po_pr_map.setdefault(d.parent, webnotes._dict()).setdefault(
"purchase_order", []).append(d.purchase_order)
if d.purchase_receipt:
invoice_po_pr_map.setdefault(d.parent, webnotes._dict()).setdefault(
"purchase_receipt", []).append(d.purchase_receipt)
if d.project_name:
invoice_po_pr_map.setdefault(d.parent, webnotes._dict()).setdefault(
"project_name", []).append(d.project_name)
return invoice_po_pr_map
def get_account_details(invoice_list):
account_map = {}
accounts = list(set([inv.credit_to for inv in invoice_list]))
for acc in webnotes.conn.sql("""select name, parent_account from tabAccount
where name in (%s)""" % ", ".join(["%s"]*len(accounts)), tuple(accounts), as_dict=1):
account_map[acc.name] = acc.parent_account
return account_map

View File

@ -0,0 +1,22 @@
[
{
"creation": "2013-04-29 16:13:11",
"docstatus": 0,
"modified": "2013-04-30 17:51:19",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"add_total_row": 1,
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Purchase Invoice",
"report_name": "Purchase Register",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Purchase Register"
}
]

View File

@ -0,0 +1,23 @@
[
{
"creation": "2013-05-28 15:57:59",
"docstatus": 0,
"modified": "2013-05-28 17:34:05",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"add_total_row": 1,
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"query": "select \n `tabPurchase Receipt`.`name` as \"Purchase Receipt:Link/Purchase Receipt:120\",\n `tabPurchase Receipt`.`posting_date` as \"Date:Date:100\",\n `tabPurchase Receipt`.`supplier` as \"Supplier:Link/Supplier:120\",\n `tabPurchase Receipt Item`.`project_name` as \"Project\",\n\t`tabPurchase Receipt Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Receipt Item`.qty as \"Qty:Float:100\",\n\t`tabPurchase Receipt Item`.billed_qty as \"Billed Qty:Float:100\", \n\t(`tabPurchase Receipt Item`.qty - ifnull(`tabPurchase Receipt Item`.billed_qty, 0)) as \"Qty to Bill:Float:100\",\n\t`tabPurchase Receipt Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Receipt Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Receipt`, `tabPurchase Receipt Item`\nwhere\n\t`tabPurchase Receipt Item`.`parent` = `tabPurchase Receipt`.`name`\n\tand `tabPurchase Receipt`.docstatus = 1\n\tand `tabPurchase Receipt`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Receipt Item`.billed_qty, 0) < ifnull(`tabPurchase Receipt Item`.qty, 0)\norder by `tabPurchase Receipt`.posting_date asc",
"ref_doctype": "Purchase Invoice",
"report_name": "Received Items To Be Billed",
"report_type": "Query Report"
},
{
"doctype": "Report",
"name": "Received Items To Be Billed"
}
]

View File

@ -0,0 +1,5 @@
wn.require("app/js/sales_trends_filters.js");
wn.query_reports["Sales Invoice Trends"] = {
filters: get_filters()
}

View File

@ -0,0 +1,27 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from controllers.trends import get_columns,get_data
def execute(filters=None):
if not filters: filters ={}
data = []
conditions = get_columns(filters, "Sales Invoice")
data = get_data(filters, conditions)
return conditions["columns"], data

View File

@ -0,0 +1,21 @@
[
{
"creation": "2013-06-13 18:44:21",
"docstatus": 0,
"modified": "2013-06-13 18:44:21",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Sales Invoice",
"report_name": "Sales Invoice Trends",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Sales Invoice Trends"
}
]

View File

@ -0,0 +1,22 @@
[
{
"creation": "2013-05-06 12:28:23",
"docstatus": 0,
"modified": "2013-05-06 12:41:15",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"query": "SELECT\n sales_partner as \"Sales Partner:Link/Sales Partner:150\",\n\tsum(net_total) as \"Invoiced Amount (Exculsive Tax):Currency:210\",\n\tsum(total_commission) as \"Total Commission:Currency:150\",\n\tsum(total_commission)*100/sum(net_total) as \"Average Commission Rate:Currency:170\"\nFROM\n\t`tabSales Invoice`\nWHERE\n\tdocstatus = 1 and ifnull(net_total, 0) > 0 and ifnull(total_commission, 0) > 0\nGROUP BY\n\tsales_partner\nORDER BY\n\t\"Total Commission:Currency:120\"",
"ref_doctype": "Sales Invoice",
"report_name": "Sales Partners Commission",
"report_type": "Query Report"
},
{
"doctype": "Report",
"name": "Sales Partners Commission"
}
]

View File

@ -0,0 +1,42 @@
wn.query_reports["Sales Register"] = {
"filters": [
{
"fieldname":"from_date",
"label": "From Date",
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": "To Date",
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"account",
"label": "Account",
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
var company = wn.query_report.filters_by_name.company.get_value();
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"debit_or_credit": "Debit",
"company": company,
"master_type": "Customer"
}
}
}
},
{
"fieldname":"company",
"label": "Company",
"fieldtype": "Link",
"options": "Company",
"default": sys_defaults.company
}
]
}

View File

@ -0,0 +1,184 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt
from webnotes import msgprint, _
def execute(filters=None):
if not filters: filters = {}
invoice_list = get_invoices(filters)
columns, income_accounts, tax_accounts, renamed_columns = get_columns(invoice_list)
if not invoice_list:
msgprint(_("No record found"))
return columns, invoice_list
invoice_income_map = get_invoice_income_map(invoice_list)
invoice_tax_map = get_invoice_tax_map(invoice_list, renamed_columns)
invoice_so_dn_map = get_invoice_so_dn_map(invoice_list)
customer_map = get_customer_deatils(invoice_list)
account_map = get_account_details(invoice_list)
data = []
for inv in invoice_list:
# invoice details
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_name, inv.debit_to,
account_map.get(inv.debit_to), customer_map.get(inv.customer), inv.project_name,
inv.remarks, ", ".join(sales_order), ", ".join(delivery_note)]
# map income values
for income_acc in income_accounts:
row.append(invoice_income_map.get(inv.name, {}).get(income_acc))
# net total
row.append(inv.net_total)
# tax account
for tax_acc in tax_accounts:
row.append(invoice_tax_map.get(inv.name, {}).get(tax_acc))
# 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)
return columns, data
def get_columns(invoice_list):
"""return columns based on filters"""
columns = [
"Invoice:Link/Sales Invoice:120", "Posting Date:Date:80", "Customer::120",
"Customer Account:Link/Account:120", "Account Group:LInk/Account:120",
"Territory:Link/Territory:80", "Project:Link/Project:80",
"Remarks::150", "Sales Order:Link/Sales Order:100", "Delivery Note:Link/Delivery Note:100"
]
income_accounts = tax_accounts = income_columns = tax_columns = []
renamed_columns = {}
if invoice_list:
income_accounts = webnotes.conn.sql_list("""select distinct income_account
from `tabSales Invoice Item` where docstatus = 1 and parent in (%s)
order by income_account""" %
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
tax_accounts = webnotes.conn.sql_list("""select distinct account_head
from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice'
and docstatus = 1 and ifnull(tax_amount, 0) > 0
and parent in (%s) order by account_head""" %
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
income_columns = [(account + ":Currency:120") for account in income_accounts]
for account in tax_accounts:
if account in income_accounts:
new_account = account + " (Tax)"
renamed_columns[account] = new_account
tax_columns.append(new_account + ":Currency:120")
else:
tax_columns.append(account + ":Currency:120")
columns = columns + income_columns + ["Net Total:Currency:120"] + tax_columns + \
["Total Tax:Currency:120"] + ["Grand Total:Currency:120"] + \
["Rounded Total:Currency:120"] + ["Outstanding Amount:Currency:120"]
return columns, income_accounts, tax_accounts, renamed_columns
def get_conditions(filters):
conditions = ""
if filters.get("company"): conditions += " and company=%(company)s"
if filters.get("account"): conditions += " and debit_to = %(account)s"
if filters.get("from_date"): conditions += " and posting_date >= %(from_date)s"
if filters.get("to_date"): conditions += " and posting_date <= %(to_date)s"
return conditions
def get_invoices(filters):
conditions = get_conditions(filters)
return webnotes.conn.sql("""select name, posting_date, debit_to, project_name, customer,
customer_name, 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)
def get_invoice_income_map(invoice_list):
income_details = webnotes.conn.sql("""select parent, income_account, sum(amount) as amount
from `tabSales Invoice Item` where parent in (%s) group by parent, income_account""" %
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
invoice_income_map = {}
for d in income_details:
invoice_income_map.setdefault(d.parent, webnotes._dict()).setdefault(d.income_account, [])
invoice_income_map[d.parent][d.income_account] = flt(d.amount)
return invoice_income_map
def get_invoice_tax_map(invoice_list, renamed_columns):
tax_details = webnotes.conn.sql("""select parent, account_head, sum(tax_amount) as tax_amount
from `tabSales Taxes and Charges` where parent in (%s) group by parent, account_head""" %
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
invoice_tax_map = {}
for d in tax_details:
account = renamed_columns.get(d.account_head) or d.account_head
invoice_tax_map.setdefault(d.parent, webnotes._dict()).setdefault(account, [])
invoice_tax_map[d.parent][account] = flt(d.tax_amount)
return invoice_tax_map
def get_invoice_so_dn_map(invoice_list):
si_items = webnotes.conn.sql("""select parent, sales_order, delivery_note
from `tabSales Invoice Item` where parent in (%s)
and (ifnull(sales_order, '') != '' or ifnull(delivery_note, '') != '')""" %
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
invoice_so_dn_map = {}
for d in si_items:
if d.sales_order:
invoice_so_dn_map.setdefault(d.parent, webnotes._dict()).setdefault(
"sales_order", []).append(d.sales_order)
if d.delivery_note:
invoice_so_dn_map.setdefault(d.parent, webnotes._dict()).setdefault(
"delivery_note", []).append(d.delivery_note)
return invoice_so_dn_map
def get_customer_deatils(invoice_list):
customer_map = {}
customers = list(set([inv.customer for inv in invoice_list]))
for cust in webnotes.conn.sql("""select name, territory from `tabCustomer`
where name in (%s)""" % ", ".join(["%s"]*len(customers)), tuple(customers), as_dict=1):
customer_map[cust.name] = cust.territory
return customer_map
def get_account_details(invoice_list):
account_map = {}
accounts = list(set([inv.debit_to for inv in invoice_list]))
for acc in webnotes.conn.sql("""select name, parent_account from tabAccount
where name in (%s)""" % ", ".join(["%s"]*len(accounts)), tuple(accounts), as_dict=1):
account_map[acc.name] = acc.parent_account
return account_map

View File

@ -0,0 +1,22 @@
[
{
"creation": "2013-04-23 18:15:29",
"docstatus": 0,
"modified": "2013-04-30 17:53:10",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"add_total_row": 1,
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Sales Invoice",
"report_name": "Sales Register",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Sales Register"
}
]

View File

@ -0,0 +1,49 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
def execute(filters=None):
account_map = get_account_map()
columns = get_columns(account_map)
data = []
suppliers = webnotes.conn.sql("select name from tabSupplier where docstatus < 2")
for supplier in suppliers:
row = [supplier[0]]
for company in sorted(account_map):
row.append(account_map[company].get(supplier[0], ''))
data.append(row)
return columns, data
def get_account_map():
accounts = webnotes.conn.sql("""select name, company, master_name
from `tabAccount` where master_type = 'Supplier'
and ifnull(master_name, '') != '' and docstatus < 2""", as_dict=1)
account_map = {}
for acc in accounts:
account_map.setdefault(acc.company, {}).setdefault(acc.master_name, {})
account_map[acc.company][acc.master_name] = acc.name
return account_map
def get_columns(account_map):
columns = ["Supplier:Link/Supplier:120"] + \
[(company + ":Link/Account:120") for company in sorted(account_map)]
return columns

View File

@ -0,0 +1,21 @@
[
{
"creation": "2013-06-04 12:56:17",
"docstatus": 0,
"modified": "2013-06-04 12:56:46",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Report",
"is_standard": "Yes",
"name": "__common__",
"ref_doctype": "Account",
"report_name": "Supplier Account Head",
"report_type": "Script Report"
},
{
"doctype": "Report",
"name": "Supplier Account Head"
}
]

View File

@ -1,37 +0,0 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
report.customize_filters = function() {
this.hide_all_filters();
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Company'].df.filter_hide = 0;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'From Posting Date'].df.filter_hide = 1;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df.filter_hide = 0;
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Account'].df.filter_hide = 0;
this.add_filter({fieldname:'aging_based_on', label:'Aging Based On', fieldtype:'Select', options:NEWLINE+'Aging Date'+NEWLINE+'Due Date',ignore : 1, parent:'Purchase Invoice', report_default:'Aging Date'});
this.add_filter({fieldname:'range_1', label:'Range 1', fieldtype:'Data', ignore : 1, parent:'GL Entry', report_default:30});
this.add_filter({fieldname:'range_2', label:'Range 2', fieldtype:'Data', ignore : 1, parent:'GL Entry', report_default:45});
this.add_filter({fieldname:'range_3', label:'Range 3', fieldtype:'Data', ignore : 1, parent:'GL Entry', report_default:60});
this.add_filter({fieldname:'range_4', label:'Range 4', fieldtype:'Data', ignore : 1, parent:'GL Entry', report_default:90});
this.filter_fields_dict['GL Entry'+FILTER_SEP +'To Posting Date'].df['report_default']=dateutil.obj_to_str(new Date());
this.filter_fields_dict['GL Entry'+FILTER_SEP +'Company'].df['report_default']=sys_defaults.company;
this.dt.set_no_limit(1);
}
this.mytabs.items['Select Columns'].hide()

View File

@ -1,183 +0,0 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Check mandatory filters
# ------------------------------------------------------------------
from __future__ import unicode_literals
if not filter_values.get('posting_date1'):
msgprint("Please select To Posting Date ")
raise Exception
else:
to_date = filter_values.get('posting_date1')
if not filter_values['range_1'] or not filter_values['range_2'] \
or not filter_values['range_3'] or not filter_values['range_4']:
msgprint("Please select aging ranges in no of days in 'More Filters' ")
raise Exception
# validate Range
range_list = ['range_1','range_2','range_3','range_4']
for r in range(len(range_list)-1):
if not cint(filter_values[range_list[r]]) < cint(filter_values[range_list[r + 1]]):
msgprint("Range %s should be less than Range %s." % (cstr(r+1),cstr(r+2)))
raise Exception
# Add columns
# ------------------------------------------------------------------
data = [['Aging Date','Date','80px',''],
['Account','Data','120px',''],
['Against Voucher Type','Data','120px',''],
['Against Voucher','Data','120px',''],
['Voucher Type','Data','120px',''],
['Voucher No','Data','120px',''],
['Remarks','Data','160px',''],
['Supplier Type', 'Data', '80px', ''],
['Due Date', 'Data', '80px', ''],
['Bill No','Data','80px',''],
['Bill Date','Data','80px',''],
['Opening Amt','Currency','120px',''],
['Outstanding Amt','Currency','120px',''],
['Age (Days)', 'Currency', '150px', ''],
['0-'+cstr(filter_values['range_1']),'Currency','100px',''],
[cstr(cint(filter_values['range_1']) + 1)+ '-' +cstr(filter_values['range_2']),'Currency','100px',''],
[cstr(cint(filter_values['range_2']) + 1)+ '-' +cstr(filter_values['range_3']),'Currency','100px',''],
[cstr(cint(filter_values['range_3']) + 1)+ '-' +cstr(filter_values['range_4']),'Currency','100px',''],
[cstr(filter_values['range_4']) + '-Above','Currency','100px','']]
for d in data:
colnames.append(d[0])
coltypes.append(d[1])
colwidths.append(d[2])
coloptions.append(d[3])
col_idx[d[0]] = len(colnames)-1
# ageing based on
# ------------------------------------------------------------------
aging_based_on = 'Aging Date'
if filter_values.has_key('aging_based_on') and filter_values['aging_based_on']:
aging_based_on = filter_values['aging_based_on'].split(NEWLINE)[-1]
if len(res) > 2000 and from_export == 0:
msgprint("""This is a very large report and cannot be shown in the browser
as it is likely to make your browser very slow.
Please select Account or click on 'Export' to open in excel""", raise_exception=1)
# get supplier type
supp_type_dict = {}
for each in sql("""select t2.name, t1.supplier_type from tabSupplier t1, tabAccount t2
where t1.name = t2.account_name group by t2.name"""):
supp_type_dict[each[0]] = each[1]
# get due_date, bill_no, bill_date from PV
pv_dict = {}
for t in sql("""select name, due_date, bill_no, bill_date
from `tabPurchase Invoice` group by name"""):
pv_dict[t[0]] = [cstr(t[1]), t[2], cstr(t[3])]
# pv after to-date
pv_after_to_date = [d[0] for d in sql("""select distinct name from `tabPurchase Invoice`
where posting_date > %s and docstatus = 1""", (to_date,))]
from webnotes.utils import nowdate
out = []
total_booking_amt, total_outstanding_amt = 0,0
for r in res:
outstanding_amt, due_date, bill_no, bill_date, cond = 0, '','','', ''
booking_amt = r.pop(7)
# supplier type
r.append(supp_type_dict.get(r[col_idx['Account']], ''))
if r[col_idx['Voucher Type']] == 'Purchase Invoice':
r += pv_dict.get(r[col_idx['Voucher No']], ['', '', ''])
else:
r += ['', '', '']
# if entry against Purchase Invoice
if r[col_idx['Against Voucher']] and r[col_idx['Voucher Type']] == 'Purchase Invoice':
cond = " and ifnull(against_voucher, '') = '%s'" % r[col_idx['Against Voucher']]
# if entry against JV & and not adjusted within period
elif r[col_idx['Against Voucher Type']] == 'Purchase Invoice' \
and r[col_idx['Against Voucher']] in pv_after_to_date:
booking_amt = 0
cond = """ and voucher_no = '%s' and ifnull(against_voucher, '') = '%s'""" \
% (r[col_idx['Voucher No']], r[col_idx['Against Voucher']])
# if un-adjusted
elif not r[col_idx['Against Voucher']]:
booking_amt = 0
cond = """ and ((voucher_no = '%s' and ifnull(against_voucher, '') = '')
or (ifnull(against_voucher, '') = '%s' and voucher_type = 'Journal Voucher'))""" \
% (r[col_idx['Voucher No']], r[col_idx['Voucher No']])
if cond:
outstanding_amt = flt(sql("""select sum(ifnull(credit, 0))-sum(ifnull(debit, 0))
from `tabGL Entry` where account = %s and ifnull(is_cancelled, 'No') = 'No'
and posting_date <= %s %s"""
% ('%s', '%s', cond), (r[col_idx['Account']], to_date,))[0][0] or 0)
# add to total outstanding
total_outstanding_amt += flt(outstanding_amt)
# add to total booking amount
if outstanding_amt and r[col_idx['Voucher Type']] == 'Purchase Invoice' \
and r[col_idx['Against Voucher']]:
total_booking_amt += flt(booking_amt)
r += [booking_amt, outstanding_amt]
# split into date ranges
val_l1 = val_l2 = val_l3 = val_l4 = val_l5_above= 0
if r[col_idx[aging_based_on]]:
if getdate(to_date) > getdate(nowdate()):
to_date = nowdate()
diff = (getdate(to_date) - getdate(r[col_idx[aging_based_on]])).days
if diff < cint(filter_values['range_1']):
val_l1 = outstanding_amt
if diff >= cint(filter_values['range_1']) and diff < cint(filter_values['range_2']):
val_l2 = outstanding_amt
if diff >= cint(filter_values['range_2']) and diff < cint(filter_values['range_3']):
val_l3 = outstanding_amt
if diff >= cint(filter_values['range_3']) and diff < cint(filter_values['range_4']):
val_l4 = outstanding_amt
if diff >= cint(filter_values['range_4']):
val_l5_above = outstanding_amt
r += [diff, val_l1, val_l2, val_l3, val_l4, val_l5_above]
# Only show that entry which has outstanding
if abs(flt(outstanding_amt)) > 0.001:
out.append(r)
if len(out) > 300 and from_export == 0:
msgprint("This is a very large report and cannot be shown in the browser as it is likely to make your browser very slow.Please select Account or click on 'Export' to open in excel")
raise Exception
# Append Extra rows to RES
# ------------------------------------------------------------------
t_row = ['' for i in range(len(colnames))]
t_row[col_idx['Voucher No']] = 'Total'
t_row[col_idx['Opening Amt']] = total_booking_amt
t_row[col_idx['Outstanding Amt']] = total_outstanding_amt
out.append(t_row)

View File

@ -1,16 +0,0 @@
SELECT DISTINCT
`tabGL Entry`.`Aging_date`,`tabGL Entry`.`account`, `tabGL Entry`.`against_voucher_type`,
`tabGL Entry`.`against_voucher`,`tabGL Entry`.`voucher_type`,`tabGL Entry`.`voucher_no`,
`tabGL Entry`.`remarks`, `tabGL Entry`.`credit`
FROM
`tabGL Entry`,`tabAccount`
WHERE
`tabGL Entry`.`posting_date`<= '%(posting_date1)s'
AND `tabGL Entry`.`account` LIKE '%(account)s%%'
AND `tabGL Entry`.`company` LIKE '%(company)s%%'
AND ((ifnull(`tabGL Entry`.`voucher_type`,'') = 'Purchase Invoice'
AND `tabGL Entry`.`credit`>0) OR `tabGL Entry`.voucher_type = 'Journal Voucher')
AND `tabGL Entry`.`is_cancelled` = 'No'
AND `tabAccount`.master_type = 'Supplier'
AND `tabAccount`.name = `tabGL Entry`.account
ORDER BY `tabGL Entry`.`posting_date`

View File

@ -1,26 +0,0 @@
[
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-05-14 18:05:41",
"modified_by": "Administrator",
"modified": "2012-10-17 10:51:41"
},
{
"module": "Accounts",
"standard": "Yes",
"sort_order": "DESC",
"filters": "{\"GL Entry\\u0001Voucher Type\":[\"\"],\"GL Entry\\u0001Is Cancelled\":[\"\"],\"GL Entry\\u0001Is Opening\":[\"\"],\"GL Entry\\u0001Fiscal Year\":[\"\"],\"Purchase Invoice\\u0001Aging Based On\":[\"Aging Date\"],\"GL Entry\\u0001Range 1\":\"30\",\"GL Entry\\u0001Range 2\":\"45\",\"GL Entry\\u0001Range 3\":\"60\",\"GL Entry\\u0001Range 4\":\"90\"}",
"doctype": "Search Criteria",
"doc_type": "GL Entry",
"name": "__common__",
"sort_by": "`tabGL Entry`.`name`",
"page_len": 50,
"criteria_name": "Accounts Payable",
"columns": "GL Entry\u0001Posting Date,GL Entry\u0001Account,GL Entry\u0001Against Voucher,GL Entry\u0001Voucher No"
},
{
"name": "accounts_payable",
"doctype": "Search Criteria"
}
]

Some files were not shown because too many files have changed in this diff Show More