diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 3c7b9f346a..120d65f002 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -5,7 +5,7 @@ import frappe
from erpnext.hooks import regional_overrides
from frappe.utils import getdate
-__version__ = '10.1.2'
+__version__ = '10.1.3'
def get_default_company(user=None):
'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 2af30e1956..ee16e4c64a 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -101,6 +101,8 @@ class SalesInvoice(SellingController):
self.set_billing_hours_and_amount()
self.update_timesheet_billing_for_project()
self.set_status()
+ if self.is_pos and not self.is_return:
+ self.verify_payment_amount_is_positive()
def before_save(self):
set_account_for_mode_of_payment(self)
@@ -903,6 +905,11 @@ class SalesInvoice(SellingController):
project.update_billed_amount()
project.save()
+ def verify_payment_amount_is_positive(self):
+ for entry in self.payments:
+ if entry.amount < 0:
+ frappe.throw(_("Row #{0} (Payment Table): Amount must be positive").format(entry.idx))
+
def get_list_context(context=None):
from erpnext.controllers.website_list_for_contact import get_list_context
list_context = get_list_context(context)
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
index b622ab499e..d96fc996bc 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
@@ -1,10 +1,15 @@
-
+{% if(filters.show_pdc_in_print) { %}
+
+{% } %}
{% if(report.report_name === "Accounts Receivable" || report.report_name === "Accounts Payable") { %}
{%= __("Date") %} |
- {%= __("Ref") %} |
+ {%= __("Ref") %} |
+ {% if(!filters.show_pdc_in_print) { %}
{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %} |
+ {% } %}
{%= __("Invoiced Amount") %} |
{% if(!filters.show_pdc_in_print) { %}
{%= __("Paid Amount") %} |
{%= report.report_name === "Accounts Receivable" ? __('Credit Note') : __('Debit Note') %} |
{% } %}
- {%= __("Outstanding Amount") %} |
+ {%= __("Outstanding Amount") %} |
{% if(filters.show_pdc_in_print) { %}
{% if(report.report_name === "Accounts Receivable") { %}
- {%= __("Customer LPO No.") %} |
+ {%= __("Customer LPO No.") %} |
{% } %}
- {%= __("PDC/LC Date") %} |
- {%= __("PDC/LC Ref") %} |
- {%= __("PDC/LC Amount") %} |
+ {%= __("PDC/LC Date") %} |
+ {%= __("PDC/LC Ref") %} |
+ {%= __("PDC/LC Amount") %} |
+ {%= __("Remaining Balance") %} |
{% } %}
{% } else { %}
{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %} |
@@ -115,6 +123,7 @@
{%= dateutil.str_to_user(data[i][__("Posting Date")]) %} |
{%= data[i][__("Voucher Type")] %}
{%= data[i][__("Voucher No")] %} |
+ {% if(!filters.show_pdc_in_print) { %}
{% if(!(filters.customer || filters.supplier)) { %}
{%= data[i][__("Customer")] || data[i][__("Supplier")] %}
@@ -127,6 +136,7 @@
{%= __("Remarks") %}:
{%= data[i][__("Remarks")] %}
|
+ {% } %}
{%= format_currency(data[i]["Invoiced Amount"], data[i]["currency"]) %} |
@@ -147,10 +157,13 @@
{%= frappe.datetime.str_to_user(data[i][__("PDC/LC Date")]) %} |
{%= data[i][__("PDC/LC Ref")] %} |
{%= format_currency(data[i][__("PDC/LC Amount")], data[i]["currency"]) %} |
+ {%= format_currency(data[i][__("Remaining Balance")], data[i]["currency"]) %} |
{% } %}
{% } else { %}
|
+ {% if(!filters.show_pdc_in_print) { %}
|
+ {% } %}
{%= __("Total") %} |
{%= format_currency(data[i]["Invoiced Amount"], data[i]["currency"] ) %} |
@@ -171,6 +184,7 @@
{%= frappe.datetime.str_to_user(data[i][__("PDC/LC Date")]) %} |
{%= data[i][__("PDC/LC Ref")] %} |
{%= format_currency(data[i][__("PDC/LC Amount")], data[i]["currency"]) %} |
+ {%= format_currency(data[i][__("Remaining Balance")], data[i]["currency"]) %} |
{% } %}
{% } %}
{% } else { %}
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index 4f83db1441..02f247b8b0 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -159,7 +159,7 @@ class ReceivablePayableReport(object):
else:
row.append(company_currency)
- pdc = pdc_details.get(gle.voucher_no, {})
+ pdc = pdc_details.get((gle.voucher_no, gle.party), {})
remaining_balance = outstanding_amount - flt(pdc.get("pdc_amount"))
row += [pdc.get("pdc_date"), pdc.get("pdc_ref"),
flt(pdc.get("pdc_amount")), remaining_balance]
@@ -389,25 +389,33 @@ def get_pdc_details(party_type):
on
(pref.parent = pent.name)
where
- pent.docstatus = 0 and pent.reference_date > pent.posting_date
+ pent.docstatus < 2 and pent.reference_date >= pent.posting_date
and pent.party_type = %s
- group by pref.reference_name""", party_type, as_dict=1):
- pdc_details.setdefault(pdc.invoice_no, pdc)
+ group by pent.party, pref.reference_name""", party_type, as_dict=1):
+ pdc_details.setdefault((pdc.invoice_no, pdc.party), pdc)
+
+ if scrub(party_type):
+ amount_field = "jea.debit_in_account_currency + jea.credit_in_account_currency"
+ else:
+ amount_field = "jea.debit + jea.credit"
for pdc in frappe.db.sql("""
select
jea.reference_name as invoice_no, jea.party, jea.party_type,
- max(je.cheque_date) as pdc_date, sum(ifnull(je.total_amount,0)) as pdc_amount,
+ max(je.cheque_date) as pdc_date, sum(ifnull({0},0)) as pdc_amount,
GROUP_CONCAT(je.cheque_no SEPARATOR ', ') as pdc_ref
from
`tabJournal Entry` as je inner join `tabJournal Entry Account` as jea
on
(jea.parent = je.name)
where
- je.docstatus = 0 and je.cheque_date > je.posting_date
+ je.docstatus < 2 and je.cheque_date >= je.posting_date
and jea.party_type = %s
- group by jea.reference_name""", party_type, as_dict=1):
- pdc_details.setdefault(pdc.invoice_no, pdc)
+ group by jea.party, jea.reference_name""".format(amount_field), party_type, as_dict=1):
+ if (pdc.invoice_no, pdc.party) in pdc_details:
+ pdc_details[(pdc.invoice_no, pdc.party)]["pdc_amount"] += pdc.pdc_amount
+ else:
+ pdc_details.setdefault((pdc.invoice_no, pdc.party), pdc)
return pdc_details
diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
index a39b831250..ac9f4ce2ab 100644
--- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
+++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
@@ -105,7 +105,7 @@ def get_conditions(filters):
if filters.get("mode_of_payment"):
conditions += """ and exists(select name from `tabSales Invoice Payment`
- where parent=si.name
+ where parent=`tabSales Invoice`.name
and ifnull(`tabSales Invoice Payment`.mode_of_payment, '') = %(mode_of_payment)s)"""
return conditions
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index 3d94b5ce00..98e961d97f 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -290,7 +290,7 @@ def get_projectwise_timesheet_data(project, parent=None):
cond = "and parent = %(parent)s"
return frappe.db.sql("""select name, parent, billing_hours, billing_amount as billing_amt
- from `tabTimesheet Detail` where docstatus=1 and project = %(project)s {0} and billable = 1
+ from `tabTimesheet Detail` where parenttype = 'Timesheet' and docstatus=1 and project = %(project)s {0} and billable = 1
and sales_invoice is null""".format(cond), {'project': project, 'parent': parent}, as_dict=1)
@frappe.whitelist()
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 084a218005..f1b56d9bd8 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -104,8 +104,8 @@ class SalesOrder(SellingController):
def validate_delivery_date(self):
if self.order_type == 'Sales':
if not self.delivery_date:
- self.delivery_date = max([d.delivery_date for d in self.get("items") if d.delivery_date])
-
+ delivery_date_list = [d.delivery_date for d in self.get("items") if d.delivery_date]
+ self.delivery_date = max(delivery_date_list) if delivery_date_list else None
if self.delivery_date:
for d in self.get("items"):
if not d.delivery_date: