Merge pull request #22734 from deepeshgarg007/custom_cash_flow
fix: Period list api changes for custom cash flow report
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index c7912ce..1cecab7 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -1029,14 +1029,14 @@
if bank_amount:
received_amount = bank_amount
else:
- received_amount = paid_amount * doc.conversion_rate
+ received_amount = paid_amount * doc.get('conversion_rate', 1)
else:
received_amount = abs(outstanding_amount)
if bank_amount:
paid_amount = bank_amount
else:
# if party account currency and bank currency is different then populate paid amount as well
- paid_amount = received_amount * doc.conversion_rate
+ paid_amount = received_amount * doc.get('conversion_rate', 1)
pe = frappe.new_doc("Payment Entry")
pe.payment_type = payment_type
diff --git a/erpnext/accounts/report/financial_statements.html b/erpnext/accounts/report/financial_statements.html
index 50947ec..2bb09cf 100644
--- a/erpnext/accounts/report/financial_statements.html
+++ b/erpnext/accounts/report/financial_statements.html
@@ -44,7 +44,7 @@
</tr>
</thead>
<tbody>
- {% for(let j=0, k=data.length-1; j<k; j++) { %}
+ {% for(let j=0, k=data.length; j<k; j++) { %}
{%
var row = data[j];
var row_class = data[j].parent_account ? "" : "financial-statements-important";
diff --git a/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py b/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py
index 6172a75..8fe16a2 100644
--- a/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py
+++ b/erpnext/crm/report/lead_owner_efficiency/lead_owner_efficiency.py
@@ -17,7 +17,8 @@
{
"fieldname": "lead_owner",
"label": _("Lead Owner"),
- "fieldtype": "Data",
+ "fieldtype": "Link",
+ "options": "User",
"width": "130"
},
{
@@ -68,4 +69,4 @@
"fieldtype": "Float",
"width": "100"
}
- ]
\ No newline at end of file
+ ]
diff --git a/erpnext/hr/doctype/employee_checkin/employee_checkin.json b/erpnext/hr/doctype/employee_checkin/employee_checkin.json
index 75f6997..d34316d 100644
--- a/erpnext/hr/doctype/employee_checkin/employee_checkin.json
+++ b/erpnext/hr/doctype/employee_checkin/employee_checkin.json
@@ -41,8 +41,7 @@
"fieldtype": "Select",
"in_list_view": 1,
"label": "Log Type",
- "options": "\nIN\nOUT",
- "reqd": 1
+ "options": "\nIN\nOUT"
},
{
"fieldname": "shift",
@@ -108,7 +107,7 @@
}
],
"links": [],
- "modified": "2020-01-23 04:57:42.551355",
+ "modified": "2020-07-08 11:02:32.660986",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee Checkin",
diff --git a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.json b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.json
index c797b7e..1192568 100644
--- a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.json
+++ b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.json
@@ -701,7 +701,7 @@
"columns": 0,
"default": "Draft",
"fieldname": "status",
- "fieldtype": "Data",
+ "fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@@ -1001,7 +1001,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-08-21 14:44:44.911402",
+ "modified": "2020-07-15 14:44:44.911402",
"modified_by": "Administrator",
"module": "Maintenance",
"name": "Maintenance Visit",
diff --git a/erpnext/payroll/doctype/additional_salary/additional_salary.js b/erpnext/payroll/doctype/additional_salary/additional_salary.js
index fb42b6f..d56cd4e 100644
--- a/erpnext/payroll/doctype/additional_salary/additional_salary.js
+++ b/erpnext/payroll/doctype/additional_salary/additional_salary.js
@@ -8,8 +8,7 @@
frm.set_query("employee", function() {
return {
filters: {
- company: frm.doc.company,
- status: "Active"
+ company: frm.doc.company
}
};
});
diff --git a/erpnext/payroll/doctype/additional_salary/additional_salary.py b/erpnext/payroll/doctype/additional_salary/additional_salary.py
index e369ba7..ef174bd 100644
--- a/erpnext/payroll/doctype/additional_salary/additional_salary.py
+++ b/erpnext/payroll/doctype/additional_salary/additional_salary.py
@@ -33,12 +33,16 @@
frappe.throw(_("From Date can not be greater than To Date."))
if date_of_joining:
- if getdate(self.payroll_date) < getdate(date_of_joining):
+ if self.payroll_date and getdate(self.payroll_date) < getdate(date_of_joining):
frappe.throw(_("Payroll date can not be less than employee's joining date."))
- elif getdate(self.from_date) < getdate(date_of_joining):
+ elif self.from_date and getdate(self.from_date) < getdate(date_of_joining):
frappe.throw(_("From date can not be less than employee's joining date."))
- elif relieving_date and getdate(self.to_date) > getdate(relieving_date):
+
+ if relieving_date:
+ if self.to_date and getdate(self.to_date) > getdate(relieving_date):
frappe.throw(_("To date can not be greater than employee's relieving date."))
+ if self.payroll_date and getdate(self.payroll_date) > getdate(relieving_date):
+ frappe.throw(_("Payroll date can not be greater than employee's relieving date."))
def get_amount(self, sal_start_date, sal_end_date):
start_date = getdate(sal_start_date)
@@ -107,4 +111,4 @@
existing_salary_components.append(d.salary_component)
- return salary_components_details, additional_salary_details
\ No newline at end of file
+ return salary_components_details, additional_salary_details
diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js
index 5170185..c744266 100644
--- a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js
+++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.js
@@ -3,6 +3,7 @@
frappe.ui.form.on('GSTR 3B Report', {
refresh : function(frm) {
+ frm.doc.__unsaved = 1;
if(!frm.is_new()) {
frm.set_intro(__("Please save the report again to rebuild or update"));
frm.add_custom_button(__('Download JSON'), function() {
@@ -45,10 +46,6 @@
frm.set_df_property('year', 'options', options);
},
- validate: function(frm) {
- frm.dirty();
- },
-
setup: function(frm) {
frm.set_query('company_address', function(doc) {
if(!doc.company) {
diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py
index 6d9b8db..2d306ba 100644
--- a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py
+++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py
@@ -322,7 +322,7 @@
inter_state_supply_tax_mapping[d.name]['samt'] += d.tax_amount
if d.account_head in [d.igst_account for d in self.account_heads]:
- inter_state_supply_tax_mapping[d.name]['samt'] += d.tax_amount
+ inter_state_supply_tax_mapping[d.name]['iamt'] += d.tax_amount
if d.account_head in [d.cess_account for d in self.account_heads]:
inter_state_supply_tax_mapping[d.name]['csamt'] += d.tax_amount
@@ -331,6 +331,7 @@
if d.place_of_supply:
osup_det = self.report_dict["sup_details"]["osup_det"]
osup_det["txval"] = flt(osup_det["txval"] + value['taxable_value'], 2)
+ osup_det["iamt"] = flt(osup_det["iamt"] + value['iamt'], 2)
osup_det["camt"] = flt(osup_det["camt"] + value['camt'], 2)
osup_det["samt"] = flt(osup_det["samt"] + value['samt'], 2)
osup_det["csamt"] = flt(osup_det["csamt"] + value['csamt'], 2)
diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py
index 24bb137..fe7e0c8 100644
--- a/erpnext/regional/india/utils.py
+++ b/erpnext/regional/india/utils.py
@@ -668,6 +668,11 @@
return gst_accounts
def update_grand_total_for_rcm(doc, method):
+ country = frappe.get_cached_value('Company', doc.company, 'country')
+
+ if country != 'India':
+ return
+
if doc.reverse_charge == 'Y':
gst_accounts = get_gst_accounts(doc.company)
gst_account_list = gst_accounts.get('cgst_account') + gst_accounts.get('sgst_account') \
@@ -699,9 +704,10 @@
doc.rounding_adjustment += flt(doc.rounded_total - doc.grand_total,
doc.precision("rounding_adjustment"))
- doc.outstanding_amount = doc.base_rounded_total
+ doc.outstanding_amount = doc.rounded_total or doc.grand_total
doc.in_words = money_in_words(doc.grand_total, doc.currency)
+ doc.set_payment_schedule()
def make_regional_gl_entries(gl_entries, doc):
country = frappe.get_cached_value('Company', doc.company, 'country')
diff --git a/erpnext/regional/report/gstr_1/gstr_1.py b/erpnext/regional/report/gstr_1/gstr_1.py
index 43b1ea8..8885b88 100644
--- a/erpnext/regional/report/gstr_1/gstr_1.py
+++ b/erpnext/regional/report/gstr_1/gstr_1.py
@@ -118,7 +118,7 @@
row.append(invoice_details.get(fieldname))
taxable_value = 0
- if invoice in self.cgst_igst_invoices:
+ if invoice in self.cgst_sgst_invoices:
division_factor = 2
else:
division_factor = 1
@@ -129,6 +129,8 @@
taxable_value += abs(net_amount)
elif not self.item_tax_rate.get(invoice):
taxable_value += abs(net_amount)
+ elif tax_rate:
+ taxable_value += abs(net_amount)
row += [tax_rate or 0, taxable_value]
@@ -227,7 +229,7 @@
self.items_based_on_tax_rate = {}
self.invoice_cess = frappe._dict()
- self.cgst_igst_invoices = []
+ self.cgst_sgst_invoices = []
unidentified_gst_accounts = []
for parent, account, item_wise_tax_detail, tax_amount in self.tax_details:
@@ -251,8 +253,8 @@
tax_rate = tax_amounts[0]
if cgst_or_sgst:
tax_rate *= 2
- if parent not in self.cgst_igst_invoices:
- self.cgst_igst_invoices.append(parent)
+ if parent not in self.cgst_sgst_invoices:
+ self.cgst_sgst_invoices.append(parent)
rate_based_dict = self.items_based_on_tax_rate\
.setdefault(parent, {}).setdefault(tax_rate, [])
diff --git a/erpnext/regional/report/gstr_2/gstr_2.py b/erpnext/regional/report/gstr_2/gstr_2.py
index f326fe0..f899349 100644
--- a/erpnext/regional/report/gstr_2/gstr_2.py
+++ b/erpnext/regional/report/gstr_2/gstr_2.py
@@ -44,30 +44,30 @@
for inv, items_based_on_rate in self.items_based_on_tax_rate.items():
invoice_details = self.invoices.get(inv)
for rate, items in items_based_on_rate.items():
- if inv not in self.igst_invoices:
- rate = rate / 2
- row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items)
- tax_amount = taxable_value * rate / 100
- row += [0, tax_amount, tax_amount]
- else:
- row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items)
- tax_amount = taxable_value * rate / 100
- row += [tax_amount, 0, 0]
+ if rate:
+ if inv not in self.igst_invoices:
+ rate = rate / 2
+ row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items)
+ tax_amount = taxable_value * rate / 100
+ row += [0, tax_amount, tax_amount]
+ else:
+ row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items)
+ tax_amount = taxable_value * rate / 100
+ row += [tax_amount, 0, 0]
+ row += [
+ self.invoice_cess.get(inv),
+ invoice_details.get('eligibility_for_itc'),
+ invoice_details.get('itc_integrated_tax'),
+ invoice_details.get('itc_central_tax'),
+ invoice_details.get('itc_state_tax'),
+ invoice_details.get('itc_cess_amount')
+ ]
+ if self.filters.get("type_of_business") == "CDNR":
+ row.append("Y" if invoice_details.posting_date <= date(2017, 7, 1) else "N")
+ row.append("C" if invoice_details.return_against else "R")
- row += [
- self.invoice_cess.get(inv),
- invoice_details.get('eligibility_for_itc'),
- invoice_details.get('itc_integrated_tax'),
- invoice_details.get('itc_central_tax'),
- invoice_details.get('itc_state_tax'),
- invoice_details.get('itc_cess_amount')
- ]
- if self.filters.get("type_of_business") == "CDNR":
- row.append("Y" if invoice_details.posting_date <= date(2017, 7, 1) else "N")
- row.append("C" if invoice_details.return_against else "R")
-
- self.data.append(row)
+ self.data.append(row)
def get_igst_invoices(self):
self.igst_invoices = []
@@ -86,7 +86,7 @@
conditions += opts[1]
if self.filters.get("type_of_business") == "B2B":
- conditions += "and ifnull(gst_category, '') != 'Overseas' and is_return != 1 "
+ conditions += "and ifnull(gst_category, '') in ('Registered Regular', 'Deemed Export', 'SEZ') and is_return != 1 "
elif self.filters.get("type_of_business") == "CDNR":
conditions += """ and is_return = 1 """
diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py
index a091ac7..c8424f1 100644
--- a/erpnext/stock/doctype/batch/batch.py
+++ b/erpnext/stock/doctype/batch/batch.py
@@ -143,7 +143,7 @@
@frappe.whitelist()
-def get_batch_qty(batch_no=None, warehouse=None, item_code=None):
+def get_batch_qty(batch_no=None, warehouse=None, item_code=None, posting_date=None, posting_time=None):
"""Returns batch actual qty if warehouse is passed,
or returns dict of qty by warehouse if warehouse is None
@@ -155,9 +155,14 @@
out = 0
if batch_no and warehouse:
+ cond = ""
+ if posting_date and posting_time:
+ cond = " and timestamp(posting_date, posting_time) <= timestamp('{0}', '{1}')".format(posting_date,
+ posting_time)
+
out = float(frappe.db.sql("""select sum(actual_qty)
from `tabStock Ledger Entry`
- where warehouse=%s and batch_no=%s""",
+ where warehouse=%s and batch_no=%s {0}""".format(cond),
(warehouse, batch_no))[0][0] or 0)
if batch_no and not warehouse:
diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
index 7c92ac7..3d57f47 100644
--- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
+++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
@@ -720,7 +720,7 @@
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2020-03-11 12:25:06.177894",
+ "modified": "2020-07-20 12:25:06.177894",
"modified_by": "Administrator",
"module": "Stock",
"name": "Delivery Note Item",
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
index dd284e4..ecee97c 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
@@ -74,6 +74,20 @@
, __("Get Items"), __("Update"));
},
+ posting_date: function(frm) {
+ frm.trigger("set_valuation_rate_and_qty_for_all_items");
+ },
+
+ posting_time: function(frm) {
+ frm.trigger("set_valuation_rate_and_qty_for_all_items");
+ },
+
+ set_valuation_rate_and_qty_for_all_items: function(frm) {
+ frm.doc.items.forEach(row => {
+ frm.events.set_valuation_rate_and_qty(frm, row.doctype, row.name);
+ });
+ },
+
set_valuation_rate_and_qty: function(frm, cdt, cdn) {
var d = frappe.model.get_doc(cdt, cdn);
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
index 5e469c2..43fbc00 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -184,8 +184,12 @@
sl_entries = []
has_serial_no = False
+ has_batch_no = False
for row in self.items:
item = frappe.get_doc("Item", row.item_code)
+ if item.has_batch_no:
+ has_batch_no = True
+
if item.has_serial_no or item.has_batch_no:
has_serial_no = True
self.get_sle_for_serialized_items(row, sl_entries)
@@ -222,7 +226,11 @@
if has_serial_no:
sl_entries = self.merge_similar_item_serial_nos(sl_entries)
- self.make_sl_entries(sl_entries)
+ allow_negative_stock = False
+ if has_batch_no:
+ allow_negative_stock = True
+
+ self.make_sl_entries(sl_entries, allow_negative_stock=allow_negative_stock)
if has_serial_no and sl_entries:
self.update_valuation_rate_for_serial_no()
@@ -493,7 +501,7 @@
qty, rate = data
if item_dict.get("has_batch_no"):
- qty = get_batch_qty(batch_no, warehouse) or 0
+ qty = get_batch_qty(batch_no, warehouse, posting_date=posting_date, posting_time=posting_time) or 0
return {
'qty': qty,
diff --git a/erpnext/stock/report/stock_balance/stock_balance.py b/erpnext/stock/report/stock_balance/stock_balance.py
index 74a4f6e..042087a 100644
--- a/erpnext/stock/report/stock_balance/stock_balance.py
+++ b/erpnext/stock/report/stock_balance/stock_balance.py
@@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
-import frappe
+import frappe, erpnext
from frappe import _
from frappe.utils import flt, cint, getdate, now, date_diff
from erpnext.stock.utils import add_additional_uom_columns
@@ -20,6 +20,11 @@
from_date = filters.get('from_date')
to_date = filters.get('to_date')
+ if filters.get("company"):
+ company_currency = erpnext.get_company_currency(filters.get("company"))
+ else:
+ company_currency = frappe.db.get_single_value("Global Defaults", "default_currency")
+
include_uom = filters.get("include_uom")
columns = get_columns(filters)
items = get_items(filters)
@@ -52,6 +57,7 @@
item_reorder_qty = item_reorder_detail_map[item + warehouse]["warehouse_reorder_qty"]
report_data = {
+ 'currency': company_currency,
'item_code': item,
'warehouse': warehouse,
'company': company,
@@ -89,7 +95,6 @@
def get_columns(filters):
"""return columns"""
-
columns = [
{"label": _("Item"), "fieldname": "item_code", "fieldtype": "Link", "options": "Item", "width": 100},
{"label": _("Item Name"), "fieldname": "item_name", "width": 150},
@@ -97,14 +102,14 @@
{"label": _("Warehouse"), "fieldname": "warehouse", "fieldtype": "Link", "options": "Warehouse", "width": 100},
{"label": _("Stock UOM"), "fieldname": "stock_uom", "fieldtype": "Link", "options": "UOM", "width": 90},
{"label": _("Balance Qty"), "fieldname": "bal_qty", "fieldtype": "Float", "width": 100, "convertible": "qty"},
- {"label": _("Balance Value"), "fieldname": "bal_val", "fieldtype": "Currency", "width": 100},
+ {"label": _("Balance Value"), "fieldname": "bal_val", "fieldtype": "Currency", "width": 100, "options": "currency"},
{"label": _("Opening Qty"), "fieldname": "opening_qty", "fieldtype": "Float", "width": 100, "convertible": "qty"},
- {"label": _("Opening Value"), "fieldname": "opening_val", "fieldtype": "Float", "width": 110},
+ {"label": _("Opening Value"), "fieldname": "opening_val", "fieldtype": "Currency", "width": 110, "options": "currency"},
{"label": _("In Qty"), "fieldname": "in_qty", "fieldtype": "Float", "width": 80, "convertible": "qty"},
{"label": _("In Value"), "fieldname": "in_val", "fieldtype": "Float", "width": 80},
{"label": _("Out Qty"), "fieldname": "out_qty", "fieldtype": "Float", "width": 80, "convertible": "qty"},
{"label": _("Out Value"), "fieldname": "out_val", "fieldtype": "Float", "width": 80},
- {"label": _("Valuation Rate"), "fieldname": "val_rate", "fieldtype": "Currency", "width": 90, "convertible": "rate"},
+ {"label": _("Valuation Rate"), "fieldname": "val_rate", "fieldtype": "Currency", "width": 90, "convertible": "rate", "options": "currency"},
{"label": _("Reorder Level"), "fieldname": "reorder_level", "fieldtype": "Float", "width": 80, "convertible": "qty"},
{"label": _("Reorder Qty"), "fieldname": "reorder_qty", "fieldtype": "Float", "width": 80, "convertible": "qty"},
{"label": _("Company"), "fieldname": "company", "fieldtype": "Link", "options": "Company", "width": 100}
diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.py b/erpnext/stock/report/stock_ledger/stock_ledger.py
index a5f92e2..fe8ad71 100644
--- a/erpnext/stock/report/stock_ledger/stock_ledger.py
+++ b/erpnext/stock/report/stock_ledger/stock_ledger.py
@@ -33,7 +33,7 @@
actual_qty += flt(sle.actual_qty, precision)
stock_value += sle.stock_value_difference
- if sle.voucher_type == 'Stock Reconciliation':
+ if sle.voucher_type == 'Stock Reconciliation' and not sle.actual_qty:
actual_qty = sle.qty_after_transaction
stock_value = sle.stock_value
diff --git a/erpnext/support/doctype/issue/issue_list.js b/erpnext/support/doctype/issue/issue_list.js
index 6d702f6..513a8dc 100644
--- a/erpnext/support/doctype/issue/issue_list.js
+++ b/erpnext/support/doctype/issue/issue_list.js
@@ -8,11 +8,11 @@
var method = "erpnext.support.doctype.issue.issue.set_multiple_status";
- listview.page.add_menu_item(__("Set as Open"), function() {
+ listview.page.add_action_item(__("Set as Open"), function() {
listview.call_for_selected_items(method, {"status": "Open"});
});
- listview.page.add_menu_item(__("Set as Closed"), function() {
+ listview.page.add_action_item(__("Set as Closed"), function() {
listview.call_for_selected_items(method, {"status": "Closed"});
});
},
diff --git a/erpnext/www/book-appointment/__init__.py b/erpnext/www/book-appointment/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/www/book-appointment/__init__.py
diff --git a/erpnext/www/book-appointment/verify/__init__.py b/erpnext/www/book-appointment/verify/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/www/book-appointment/verify/__init__.py