Merge branch 'version-13-hotfix' into mergify/bp/version-13-hotfix/pr-26916

This commit is contained in:
Deepesh Garg
2022-05-26 09:23:46 +05:30
committed by GitHub
4 changed files with 45 additions and 22 deletions

View File

@@ -475,7 +475,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
let row = frappe.get_doc(d.doctype, d.name) let row = frappe.get_doc(d.doctype, d.name)
set_timesheet_detail_rate(row.doctype, row.name, me.frm.doc.currency, row.timesheet_detail) set_timesheet_detail_rate(row.doctype, row.name, me.frm.doc.currency, row.timesheet_detail)
}); });
frm.trigger("calculate_timesheet_totals"); this.frm.trigger("calculate_timesheet_totals");
} }
} }
}); });
@@ -885,27 +885,44 @@ frappe.ui.form.on('Sales Invoice', {
set_timesheet_data: function(frm, timesheets) { set_timesheet_data: function(frm, timesheets) {
frm.clear_table("timesheets") frm.clear_table("timesheets")
timesheets.forEach(timesheet => { timesheets.forEach(async (timesheet) => {
if (frm.doc.currency != timesheet.currency) { if (frm.doc.currency != timesheet.currency) {
frappe.call({ const exchange_rate = await frm.events.get_exchange_rate(
method: "erpnext.setup.utils.get_exchange_rate", frm, timesheet.currency, frm.doc.currency
args: { )
from_currency: timesheet.currency, frm.events.append_time_log(frm, timesheet, exchange_rate)
to_currency: frm.doc.currency
},
callback: function(r) {
if (r.message) {
exchange_rate = r.message;
frm.events.append_time_log(frm, timesheet, exchange_rate);
}
}
});
} else { } else {
frm.events.append_time_log(frm, timesheet, 1.0); frm.events.append_time_log(frm, timesheet, 1.0);
} }
}); });
}, },
async get_exchange_rate(frm, from_currency, to_currency) {
if (
frm.exchange_rates
&& frm.exchange_rates[from_currency]
&& frm.exchange_rates[from_currency][to_currency]
) {
return frm.exchange_rates[from_currency][to_currency];
}
return frappe.call({
method: "erpnext.setup.utils.get_exchange_rate",
args: {
from_currency,
to_currency
},
callback: function(r) {
if (r.message) {
// cache exchange rates
frm.exchange_rates = frm.exchange_rates || {};
frm.exchange_rates[from_currency] = frm.exchange_rates[from_currency] || {};
frm.exchange_rates[from_currency][to_currency] = r.message;
}
}
});
},
append_time_log: function(frm, time_log, exchange_rate) { append_time_log: function(frm, time_log, exchange_rate) {
const row = frm.add_child("timesheets"); const row = frm.add_child("timesheets");
row.activity_type = time_log.activity_type; row.activity_type = time_log.activity_type;
@@ -916,7 +933,7 @@ frappe.ui.form.on('Sales Invoice', {
row.billing_hours = time_log.billing_hours; row.billing_hours = time_log.billing_hours;
row.billing_amount = flt(time_log.billing_amount) * flt(exchange_rate); row.billing_amount = flt(time_log.billing_amount) * flt(exchange_rate);
row.timesheet_detail = time_log.name; row.timesheet_detail = time_log.name;
row.project_name = time_log.project_name; row.project_name = time_log.project_name;
frm.refresh_field("timesheets"); frm.refresh_field("timesheets");
frm.trigger("calculate_timesheet_totals"); frm.trigger("calculate_timesheet_totals");

View File

@@ -198,10 +198,12 @@ def get_loan_entries(filters):
amount_field = (loan_doc.disbursed_amount).as_("credit") amount_field = (loan_doc.disbursed_amount).as_("credit")
posting_date = (loan_doc.disbursement_date).as_("posting_date") posting_date = (loan_doc.disbursement_date).as_("posting_date")
account = loan_doc.disbursement_account account = loan_doc.disbursement_account
salary_condition = loan_doc.docstatus == 1
else: else:
amount_field = (loan_doc.amount_paid).as_("debit") amount_field = (loan_doc.amount_paid).as_("debit")
posting_date = (loan_doc.posting_date).as_("posting_date") posting_date = (loan_doc.posting_date).as_("posting_date")
account = loan_doc.payment_account account = loan_doc.payment_account
salary_condition = loan_doc.repay_from_salary == 0
query = ( query = (
frappe.qb.from_(loan_doc) frappe.qb.from_(loan_doc)
@@ -214,14 +216,12 @@ def get_loan_entries(filters):
posting_date, posting_date,
) )
.where(loan_doc.docstatus == 1) .where(loan_doc.docstatus == 1)
.where(salary_condition)
.where(account == filters.get("account")) .where(account == filters.get("account"))
.where(posting_date <= getdate(filters.get("report_date"))) .where(posting_date <= getdate(filters.get("report_date")))
.where(ifnull(loan_doc.clearance_date, "4000-01-01") > getdate(filters.get("report_date"))) .where(ifnull(loan_doc.clearance_date, "4000-01-01") > getdate(filters.get("report_date")))
) )
if doctype == "Loan Repayment":
query.where(loan_doc.repay_from_salary == 0)
entries = query.run(as_dict=1) entries = query.run(as_dict=1)
loan_docs.extend(entries) loan_docs.extend(entries)
@@ -267,15 +267,17 @@ def get_loan_amount(filters):
amount_field = Sum(loan_doc.disbursed_amount) amount_field = Sum(loan_doc.disbursed_amount)
posting_date = (loan_doc.disbursement_date).as_("posting_date") posting_date = (loan_doc.disbursement_date).as_("posting_date")
account = loan_doc.disbursement_account account = loan_doc.disbursement_account
salary_condition = loan_doc.docstatus == 1
else: else:
amount_field = Sum(loan_doc.amount_paid) amount_field = Sum(loan_doc.amount_paid)
posting_date = (loan_doc.posting_date).as_("posting_date") posting_date = (loan_doc.posting_date).as_("posting_date")
account = loan_doc.payment_account account = loan_doc.payment_account
salary_condition = loan_doc.repay_from_salary == 0
amount = ( amount = (
frappe.qb.from_(loan_doc) frappe.qb.from_(loan_doc)
.select(amount_field) .select(amount_field)
.where(loan_doc.docstatus == 1) .where(loan_doc.docstatus == 1)
.where(salary_condition)
.where(account == filters.get("account")) .where(account == filters.get("account"))
.where(posting_date > getdate(filters.get("report_date"))) .where(posting_date > getdate(filters.get("report_date")))
.where(ifnull(loan_doc.clearance_date, "4000-01-01") <= getdate(filters.get("report_date"))) .where(ifnull(loan_doc.clearance_date, "4000-01-01") <= getdate(filters.get("report_date")))

View File

@@ -263,7 +263,10 @@ def get_report_summary(summary_data, currency):
def get_chart_data(columns, data): def get_chart_data(columns, data):
labels = [d.get("label") for d in columns[2:]] labels = [d.get("label") for d in columns[2:]]
datasets = [ datasets = [
{"name": account.get("account").replace("'", ""), "values": [account.get("total")]} {
"name": account.get("account").replace("'", ""),
"values": [account.get(d.get("fieldname")) for d in columns[2:]],
}
for account in data for account in data
if account.get("parent_account") == None and account.get("currency") if account.get("parent_account") == None and account.get("currency")
] ]

View File

@@ -187,8 +187,9 @@ def get_so_with_invoices(filters):
.on(soi.parent == so.name) .on(soi.parent == so.name)
.join(ps) .join(ps)
.on(ps.parent == so.name) .on(ps.parent == so.name)
.select(so.name)
.distinct()
.select( .select(
so.name,
so.customer, so.customer,
so.transaction_date.as_("submitted"), so.transaction_date.as_("submitted"),
ifelse(datediff(ps.due_date, functions.CurDate()) < 0, "Overdue", "Unpaid").as_("status"), ifelse(datediff(ps.due_date, functions.CurDate()) < 0, "Overdue", "Unpaid").as_("status"),