mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 18:59:08 +00:00
Merge branch 'edge' of github.com:webnotes/erpnext into webshop
Conflicts: stock/doctype/item/item.txt
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-03-26 11:03:07",
|
||||
"creation": "2013-04-30 12:58:25",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-03-26 12:48:18",
|
||||
"modified": "2013-05-03 14:36:24",
|
||||
"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",
|
||||
@@ -210,12 +212,6 @@
|
||||
"oldfieldtype": "Select",
|
||||
"options": "link:Print Heading"
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "System Manager",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
|
||||
@@ -45,7 +45,7 @@ class DocType(SellingController):
|
||||
|
||||
def validate(self):
|
||||
super(DocType, self).validate()
|
||||
|
||||
self.fetch_missing_values()
|
||||
self.validate_posting_time()
|
||||
self.so_dn_required()
|
||||
self.validate_proj_cust()
|
||||
@@ -137,7 +137,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 \
|
||||
not item.fields.get(fieldname):
|
||||
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 +173,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 doc in self.doclist.get({"parentfield": "entries"}):
|
||||
if doc.fields.get('item_code'):
|
||||
for fieldname, val in self.apply_pos_settings(doc.fields).items():
|
||||
if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)):
|
||||
doc.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:
|
||||
@@ -299,60 +301,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": args.get("warehouse")},
|
||||
"actual_qty"))
|
||||
return ret
|
||||
|
||||
def get_barcode_details(self, barcode):
|
||||
|
||||
@@ -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 = [
|
||||
[
|
||||
|
||||
@@ -187,6 +187,11 @@ 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",
|
||||
@@ -197,6 +202,21 @@ wn.module_page["Accounts"] = [
|
||||
route: "query-report/Ordered Items To Be Billed",
|
||||
doctype: "Sales 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"
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
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 = {}
|
||||
@@ -67,8 +69,7 @@ def get_gl_entries(filters, before_report_date=True):
|
||||
gl_entries = []
|
||||
gl_entries = webnotes.conn.sql("""select * from `tabGL Entry`
|
||||
where ifnull(is_cancelled, 'No') = 'No' %s order by posting_date, account""" %
|
||||
(conditions) % (", ".join(['%s']*len(supplier_accounts))),
|
||||
tuple(supplier_accounts), as_dict=1)
|
||||
(conditions), tuple(supplier_accounts), as_dict=1)
|
||||
return gl_entries
|
||||
|
||||
def get_conditions(filters, before_report_date=True):
|
||||
@@ -79,13 +80,16 @@ def get_conditions(filters, before_report_date=True):
|
||||
supplier_accounts = []
|
||||
if filters.get("account"):
|
||||
supplier_accounts = [filters["account"]]
|
||||
elif filters.get("company"):
|
||||
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)"
|
||||
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:
|
||||
@@ -125,20 +129,4 @@ def get_paid_amount(gle, report_date, entries_after_report_date):
|
||||
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)
|
||||
|
||||
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]
|
||||
return flt(paid_amount)
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import msgprint, _
|
||||
from webnotes.utils import getdate, nowdate, flt, cstr
|
||||
|
||||
def execute(filters=None):
|
||||
@@ -58,8 +59,7 @@ 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) % (", ".join(['%s']*len(customer_accounts))),
|
||||
tuple(customer_accounts), as_dict=1)
|
||||
(conditions), tuple(customer_accounts), as_dict=1)
|
||||
|
||||
def get_conditions(filters, upto_report_date=True):
|
||||
conditions = ""
|
||||
@@ -69,13 +69,16 @@ def get_conditions(filters, upto_report_date=True):
|
||||
customer_accounts = []
|
||||
if filters.get("account"):
|
||||
customer_accounts = [filters["account"]]
|
||||
elif filters.get("company"):
|
||||
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)"
|
||||
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:
|
||||
@@ -96,7 +99,7 @@ def get_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` group by name"""):
|
||||
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
|
||||
|
||||
0
accounts/report/bank_clearance_summary/__init__.py
Normal file
0
accounts/report/bank_clearance_summary/__init__.py
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
@@ -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()
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
@@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-02-22 17:55:23",
|
||||
"creation": "2013-02-25 10:38:57",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-02-23 14:35:28",
|
||||
"modified": "2013-05-01 11:56:43",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
|
||||
@@ -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
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
@@ -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
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
@@ -141,7 +141,6 @@ def get_account_details(invoice_list):
|
||||
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.setdefault(acc.name, "")
|
||||
account_map[acc.name] = acc.parent_account
|
||||
|
||||
return account_map
|
||||
@@ -145,7 +145,6 @@ def get_customer_deatils(invoice_list):
|
||||
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.setdefault(cust.name, "")
|
||||
customer_map[cust.name] = cust.territory
|
||||
|
||||
return customer_map
|
||||
@@ -155,7 +154,6 @@ def get_account_details(invoice_list):
|
||||
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.setdefault(acc.name, "")
|
||||
account_map[acc.name] = acc.parent_account
|
||||
|
||||
return account_map
|
||||
Reference in New Issue
Block a user