Skip to content

Commit

Permalink
Merge branch 'frappe:develop' into fix-india-e_invoice-eway_bill-part…
Browse files Browse the repository at this point in the history
…-a-from-dialog
  • Loading branch information
maharshivpatel authored May 4, 2022
2 parents 7b180c0 + 8535ad4 commit e1c1cac
Show file tree
Hide file tree
Showing 21 changed files with 110 additions and 386 deletions.
1 change: 1 addition & 0 deletions erpnext/accounts/doctype/bank_clearance/bank_clearance.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def get_payment_entries(self):
)
.where(loan_repayment.docstatus == 1)
.where(loan_repayment.clearance_date.isnull())
.where(loan_repayment.repay_from_salary == 0)
.where(loan_repayment.posting_date >= self.from_date)
.where(loan_repayment.posting_date <= self.to_date)
.where(loan_repayment.payment_account.isin([self.bank_account, self.account]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ def get_lr_matching_query(bank_account, amount_condition, filters):
loan_repayment.posting_date,
)
.where(loan_repayment.docstatus == 1)
.where(loan_repayment.repay_from_salary == 0)
.where(loan_repayment.clearance_date.isnull())
.where(loan_repayment.payment_account == bank_account)
)
Expand Down
42 changes: 0 additions & 42 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -824,29 +824,6 @@ frappe.ui.form.on('Sales Invoice', {
}
},

// Healthcare
patient: function(frm) {
if (frappe.boot.active_domains.includes("Healthcare")){
if(frm.doc.patient){
frappe.call({
method: "frappe.client.get_value",
args:{
doctype: "Patient",
filters: {
"name": frm.doc.patient
},
fieldname: "customer"
},
callback:function(r) {
if(r && r.message.customer){
frm.set_value("customer", r.message.customer);
}
}
});
}
}
},

project: function(frm) {
if (frm.doc.project) {
frm.events.add_timesheet_data(frm, {
Expand Down Expand Up @@ -976,25 +953,6 @@ frappe.ui.form.on('Sales Invoice', {
if (frm.doc.is_debit_note) {
frm.set_df_property('return_against', 'label', __('Adjustment Against'));
}

if (frappe.boot.active_domains.includes("Healthcare")) {
frm.set_df_property("patient", "hidden", 0);
frm.set_df_property("patient_name", "hidden", 0);
frm.set_df_property("ref_practitioner", "hidden", 0);
if (cint(frm.doc.docstatus==0) && cur_frm.page.current_view_name!=="pos" && !frm.doc.is_return) {
frm.add_custom_button(__('Healthcare Services'), function() {
get_healthcare_services_to_invoice(frm);
},__("Get Items From"));
frm.add_custom_button(__('Prescriptions'), function() {
get_drugs_to_invoice(frm);
},__("Get Items From"));
}
}
else {
frm.set_df_property("patient", "hidden", 1);
frm.set_df_property("patient_name", "hidden", 1);
frm.set_df_property("ref_practitioner", "hidden", 1);
}
},

create_invoice_discounting: function(frm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def get_loan_entries(filters):
posting_date = (loan_doc.posting_date).as_("posting_date")
account = loan_doc.payment_account

entries = (
query = (
frappe.qb.from_(loan_doc)
.select(
ConstantColumn(doctype).as_("payment_document"),
Expand All @@ -217,9 +217,12 @@ def get_loan_entries(filters):
.where(account == filters.get("account"))
.where(posting_date <= getdate(filters.get("report_date")))
.where(ifnull(loan_doc.clearance_date, "4000-01-01") > getdate(filters.get("report_date")))
.run(as_dict=1)
)

if doctype == "Loan Repayment":
query.where(loan_doc.repay_from_salary == 0)

entries = query.run(as_dict=1)
loan_docs.extend(entries)

return loan_docs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,19 @@ frappe.query_reports["Supplier Quotation Comparison"] = {
onload: (report) => {
// Create a button for setting the default supplier
report.page.add_inner_button(__("Select Default Supplier"), () => {
let reporter = frappe.query_reports["Quoted Item Comparison"];
let reporter = frappe.query_reports["Supplier Quotation Comparison"];

//Always make a new one so that the latest values get updated
reporter.make_default_supplier_dialog(report);
}, 'Tools');
}, __("Tools"));

},
make_default_supplier_dialog: (report) => {
// Get the name of the item to change
if(!report.data) return;

let filters = report.get_values();
let item_code = filters.item;
let item_code = filters.item_code;

// Get a list of the suppliers (with a blank as well) for the user to select
let suppliers = $.map(report.data, (row, idx)=>{ return row.supplier_name })
Expand All @@ -152,7 +152,7 @@ frappe.query_reports["Supplier Quotation Comparison"] = {
]
});

dialog.set_primary_action("Set Default Supplier", () => {
dialog.set_primary_action(__("Set Default Supplier"), () => {
let values = dialog.get_values();
if(values) {
// Set the default_supplier field of the appropriate Item to the selected supplier
Expand Down
7 changes: 0 additions & 7 deletions erpnext/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@
"Holiday List",
]

domains = {
"Distribution": "erpnext.domains.distribution",
"Manufacturing": "erpnext.domains.manufacturing",
"Retail": "erpnext.domains.retail",
"Services": "erpnext.domains.services",
}

website_generators = ["Item Group", "Website Item", "BOM", "Sales Partner", "Job Opening"]

website_context = {
Expand Down
5 changes: 0 additions & 5 deletions erpnext/loan_management/loan_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@

frappe.ui.form.on(cur_frm.doctype, {
refresh: function(frm) {
if (!frappe.boot.active_domains.includes("Non Profit")) {
frm.set_df_property('applicant_type', 'options', ['Employee', 'Customer']);
frm.refresh_field('applicant_type');
}

if (['Loan Disbursement', 'Loan Repayment', 'Loan Interest Accrual', 'Loan Write Off'].includes(frm.doc.doctype)
&& frm.doc.docstatus > 0) {

Expand Down
14 changes: 10 additions & 4 deletions erpnext/payroll/doctype/salary_slip/salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,19 @@ def get_unmarked_days(self, include_holidays_in_total_working_days):
if joining_date and (getdate(self.start_date) < joining_date <= getdate(self.end_date)):
start_date = joining_date
unmarked_days = self.get_unmarked_days_based_on_doj_or_relieving(
unmarked_days, include_holidays_in_total_working_days, self.start_date, joining_date
unmarked_days,
include_holidays_in_total_working_days,
self.start_date,
add_days(joining_date, -1),
)

if relieving_date and (getdate(self.start_date) <= relieving_date < getdate(self.end_date)):
end_date = relieving_date
unmarked_days = self.get_unmarked_days_based_on_doj_or_relieving(
unmarked_days, include_holidays_in_total_working_days, relieving_date, self.end_date
unmarked_days,
include_holidays_in_total_working_days,
add_days(relieving_date, 1),
self.end_date,
)

# exclude days for which attendance has been marked
Expand All @@ -407,10 +413,10 @@ def get_unmarked_days_based_on_doj_or_relieving(
from erpnext.hr.doctype.employee.employee import is_holiday

if include_holidays_in_total_working_days:
unmarked_days -= date_diff(end_date, start_date)
unmarked_days -= date_diff(end_date, start_date) + 1
else:
# exclude only if not holidays
for days in range(date_diff(end_date, start_date)):
for days in range(date_diff(end_date, start_date) + 1):
date = add_days(end_date, -days)
if not is_holiday(self.employee, date):
unmarked_days -= 1
Expand Down
70 changes: 68 additions & 2 deletions erpnext/payroll/doctype/salary_slip/test_salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,79 @@ def test_payment_days_based_on_attendance(self):
},
)
def test_payment_days_for_mid_joinee_including_holidays(self):
from erpnext.hr.doctype.holiday_list.holiday_list import is_holiday

no_of_days = self.get_no_of_days()
month_start_date, month_end_date = get_first_day(nowdate()), get_last_day(nowdate())

new_emp_id = make_employee("test_payment_days_based_on_joining_date@salary.com")
joining_date, relieving_date = add_days(month_start_date, 3), add_days(month_end_date, -5)

for days in range(date_diff(month_end_date, month_start_date) + 1):
date = add_days(month_start_date, days)
mark_attendance(new_emp_id, date, "Present", ignore_validate=True)

# Case 1: relieving in mid month
frappe.db.set_value(
"Employee",
new_emp_id,
{"date_of_joining": month_start_date, "relieving_date": relieving_date, "status": "Active"},
)

new_ss = make_employee_salary_slip(
"test_payment_days_based_on_joining_date@salary.com",
"Monthly",
"Test Payment Based On Attendence",
)
self.assertEqual(new_ss.payment_days, no_of_days[0] - 5)

# Case 2: joining in mid month
frappe.db.set_value(
"Employee",
new_emp_id,
{"date_of_joining": joining_date, "relieving_date": month_end_date, "status": "Active"},
)

frappe.delete_doc("Salary Slip", new_ss.name, force=True)
new_ss = make_employee_salary_slip(
"test_payment_days_based_on_joining_date@salary.com",
"Monthly",
"Test Payment Based On Attendence",
)
self.assertEqual(new_ss.payment_days, no_of_days[0] - 3)

# Case 3: joining and relieving in mid-month
frappe.db.set_value(
"Employee",
new_emp_id,
{"date_of_joining": joining_date, "relieving_date": relieving_date, "status": "Left"},
)

frappe.delete_doc("Salary Slip", new_ss.name, force=True)
new_ss = make_employee_salary_slip(
"test_payment_days_based_on_joining_date@salary.com",
"Monthly",
"Test Payment Based On Attendence",
)

self.assertEqual(new_ss.total_working_days, no_of_days[0])
self.assertEqual(new_ss.payment_days, no_of_days[0] - 8)

@change_settings(
"Payroll Settings",
{
"payroll_based_on": "Attendance",
"consider_unmarked_attendance_as": "Absent",
"include_holidays_in_total_working_days": True,
},
)
def test_payment_days_for_mid_joinee_including_holidays_and_unmarked_days(self):
# tests mid month joining and relieving along with unmarked days
from erpnext.hr.doctype.holiday_list.holiday_list import is_holiday

no_of_days = self.get_no_of_days()
month_start_date, month_end_date = get_first_day(nowdate()), get_last_day(nowdate())

new_emp_id = make_employee("test_payment_days_based_on_joining_date@salary.com")
joining_date, relieving_date = add_days(month_start_date, 3), add_days(month_end_date, -5)
holidays = 0

for days in range(date_diff(relieving_date, joining_date) + 1):
Expand All @@ -150,6 +210,12 @@ def test_payment_days_for_mid_joinee_including_holidays(self):
else:
holidays += 1

frappe.db.set_value(
"Employee",
new_emp_id,
{"date_of_joining": joining_date, "relieving_date": relieving_date, "status": "Left"},
)

new_ss = make_employee_salary_slip(
"test_payment_days_based_on_joining_date@salary.com",
"Monthly",
Expand Down
30 changes: 0 additions & 30 deletions erpnext/public/js/setup_wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,6 @@ frappe.setup.on("before_load", function () {
});

erpnext.setup.slides_settings = [
{
// Domain
name: 'domain',
title: __('Select your Domains'),
fields: [
{
fieldname: 'domains',
label: __('Domains'),
fieldtype: 'MultiCheck',
options: [
{ "label": __("Distribution"), "value": "Distribution" },
{ "label": __("Manufacturing"), "value": "Manufacturing" },
{ "label": __("Retail"), "value": "Retail" },
{ "label": __("Services"), "value": "Services" },
{ "label": __("Healthcare (beta)"), "value": "Healthcare" },
{ "label": __("Non Profit (beta)"), "value": "Non Profit" }
], reqd: 1
},
],
// help: __('Select the nature of your business.'),
validate: function () {
if (this.values.domains.length === 0) {
frappe.msgprint(__("Please select at least one domain."));
return false;
}
frappe.setup.domains = this.values.domains;
return true;
},
},

{
// Brand
name: 'brand',
Expand Down
20 changes: 18 additions & 2 deletions erpnext/selling/doctype/sales_order/sales_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ frappe.ui.form.on("Sales Order", {
frm.set_value('transaction_date', frappe.datetime.get_today())
}
erpnext.queries.setup_queries(frm, "Warehouse", function() {
return erpnext.queries.warehouse(frm.doc);
return {
filters: [
["Warehouse", "company", "in", ["", cstr(frm.doc.company)]],
]
};
});

frm.set_query('project', function(doc, cdt, cdn) {
Expand All @@ -77,7 +81,19 @@ frappe.ui.form.on("Sales Order", {
}
});

erpnext.queries.setup_warehouse_query(frm);
frm.set_query('warehouse', 'items', function(doc, cdt, cdn) {
let row = locals[cdt][cdn];
let query = {
filters: [
["Warehouse", "company", "in", ["", cstr(frm.doc.company)]],
]
};
if (row.item_code) {
query.query = "erpnext.controllers.queries.warehouse_query";
query.filters.push(["Bin", "item_code", "=", row.item_code]);
}
return query;
});

frm.ignore_doctypes_on_cancel_all = ['Purchase Order'];
},
Expand Down
7 changes: 3 additions & 4 deletions erpnext/setup/doctype/company/company.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,8 @@
},
{
"fieldname": "domain",
"fieldtype": "Link",
"label": "Domain",
"options": "Domain"
"fieldtype": "Data",
"label": "Domain"
},
{
"fieldname": "parent_company",
Expand Down Expand Up @@ -748,7 +747,7 @@
"image_field": "company_logo",
"is_tree": 1,
"links": [],
"modified": "2022-01-25 10:33:16.826067",
"modified": "2022-04-27 10:33:16.826067",
"modified_by": "Administrator",
"module": "Setup",
"name": "Company",
Expand Down
1 change: 0 additions & 1 deletion erpnext/setup/setup_wizard/operations/company_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def create_fiscal_year_and_company(args):
"country": args.get("country"),
"create_chart_of_accounts_based_on": "Standard Template",
"chart_of_accounts": args.get("chart_of_accounts"),
"domain": args.get("domains")[0],
}
).insert()

Expand Down
3 changes: 0 additions & 3 deletions erpnext/setup/setup_wizard/operations/defaults_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ def set_default_settings(args):
system_settings.email_footer_address = args.get("company_name")
system_settings.save()

domain_settings = frappe.get_single("Domain Settings")
domain_settings.set_active_domains(args.get("domains"))

stock_settings = frappe.get_doc("Stock Settings")
stock_settings.item_naming_by = "Item Code"
stock_settings.valuation_method = "FIFO"
Expand Down
Loading

0 comments on commit e1c1cac

Please sign in to comment.