Merge branch 'hotfix'

This commit is contained in:
Sagar Vora 2019-02-05 18:40:38 +05:30
commit 76120309e3
15 changed files with 99 additions and 131 deletions

View File

@ -5,7 +5,7 @@ import frappe
from erpnext.hooks import regional_overrides
from frappe.utils import getdate
__version__ = '11.1.3'
__version__ = '11.1.4'
def get_default_company(user=None):
'''Get default company for user'''

View File

@ -231,7 +231,7 @@ class PurchaseInvoice(BuyingController):
item.expense_account = warehouse_account[item.warehouse]["account"]
else:
item.expense_account = stock_not_billed_account
elif item.is_fixed_asset and d.pr_detail:
elif item.is_fixed_asset and item.pr_detail:
item.expense_account = asset_received_but_not_billed
elif not item.expense_account and for_validate:
throw(_("Expense account is mandatory for item {0}").format(item.item_code or item.item_name))

View File

@ -617,14 +617,14 @@ def get_held_invoices(party_type, party):
def get_outstanding_invoices(party_type, party, account, condition=None, limit=1000):
outstanding_invoices = []
precision = frappe.get_precision("Sales Invoice", "outstanding_amount")
precision = frappe.get_precision("Sales Invoice", "outstanding_amount") or 2
if erpnext.get_party_account_type(party_type) == 'Receivable':
dr_or_cr = "debit_in_account_currency - credit_in_account_currency"
payment_dr_or_cr = "payment_gl_entry.credit_in_account_currency - payment_gl_entry.debit_in_account_currency"
payment_dr_or_cr = "credit_in_account_currency - debit_in_account_currency"
else:
dr_or_cr = "credit_in_account_currency - debit_in_account_currency"
payment_dr_or_cr = "payment_gl_entry.debit_in_account_currency - payment_gl_entry.credit_in_account_currency"
payment_dr_or_cr = "debit_in_account_currency - credit_in_account_currency"
invoice = 'Sales Invoice' if erpnext.get_party_account_type(party_type) == 'Receivable' else 'Purchase Invoice'
held_invoices = get_held_invoices(party_type, party)
@ -632,21 +632,9 @@ def get_outstanding_invoices(party_type, party, account, condition=None, limit=1
invoice_list = frappe.db.sql("""
select
voucher_no, voucher_type, posting_date, ifnull(sum({dr_or_cr}), 0) as invoice_amount,
(
select ifnull(sum({payment_dr_or_cr}), 0)
from `tabGL Entry` payment_gl_entry
where payment_gl_entry.against_voucher_type = invoice_gl_entry.voucher_type
and if(invoice_gl_entry.voucher_type='Journal Entry',
payment_gl_entry.against_voucher = invoice_gl_entry.voucher_no,
payment_gl_entry.against_voucher = invoice_gl_entry.against_voucher)
and payment_gl_entry.party_type = invoice_gl_entry.party_type
and payment_gl_entry.party = invoice_gl_entry.party
and payment_gl_entry.account = invoice_gl_entry.account
and {payment_dr_or_cr} > 0
) as payment_amount
voucher_no, voucher_type, posting_date, ifnull(sum({dr_or_cr}), 0) as invoice_amount
from
`tabGL Entry` invoice_gl_entry
`tabGL Entry`
where
party_type = %(party_type)s and party = %(party)s
and account = %(account)s and {dr_or_cr} > 0
@ -655,11 +643,9 @@ def get_outstanding_invoices(party_type, party, account, condition=None, limit=1
and (against_voucher = '' or against_voucher is null))
or (voucher_type not in ('Journal Entry', 'Payment Entry')))
group by voucher_type, voucher_no
having (invoice_amount - payment_amount) > 0.005
order by posting_date, name {limit_cond}""".format(
dr_or_cr=dr_or_cr,
invoice = invoice,
payment_dr_or_cr=payment_dr_or_cr,
condition=condition or "",
limit_cond = limit_cond
), {
@ -668,25 +654,46 @@ def get_outstanding_invoices(party_type, party, account, condition=None, limit=1
"account": account,
}, as_dict=True)
for d in invoice_list:
if not d.voucher_type == "Purchase Invoice" or d.voucher_no not in held_invoices:
due_date = frappe.db.get_value(
d.voucher_type, d.voucher_no, "posting_date" if party_type == "Employee" else "due_date")
payment_entries = frappe.db.sql("""
select against_voucher_type, against_voucher,
ifnull(sum({payment_dr_or_cr}), 0) as payment_amount
from `tabGL Entry`
where party_type = %(party_type)s and party = %(party)s
and account = %(account)s
and {payment_dr_or_cr} > 0
and against_voucher is not null and against_voucher != ''
group by against_voucher_type, against_voucher
""".format(payment_dr_or_cr=payment_dr_or_cr), {
"party_type": party_type,
"party": party,
"account": account,
}, as_dict=True)
outstanding_invoices.append(
frappe._dict({
'voucher_no': d.voucher_no,
'voucher_type': d.voucher_type,
'posting_date': d.posting_date,
'invoice_amount': flt(d.invoice_amount),
'payment_amount': flt(d.payment_amount),
'outstanding_amount': flt(d.invoice_amount - d.payment_amount, precision),
'due_date': due_date
})
)
pe_map = frappe._dict()
for d in payment_entries:
pe_map.setdefault((d.against_voucher_type, d.against_voucher), d.payment_amount)
for d in invoice_list:
payment_amount = pe_map.get((d.voucher_type, d.voucher_no), 0)
outstanding_amount = flt(d.invoice_amount - payment_amount, precision)
if outstanding_amount > 0.5 / (10**precision):
if not d.voucher_type == "Purchase Invoice" or d.voucher_no not in held_invoices:
due_date = frappe.db.get_value(
d.voucher_type, d.voucher_no, "posting_date" if party_type == "Employee" else "due_date")
outstanding_invoices.append(
frappe._dict({
'voucher_no': d.voucher_no,
'voucher_type': d.voucher_type,
'posting_date': d.posting_date,
'invoice_amount': flt(d.invoice_amount),
'payment_amount': payment_amount,
'outstanding_amount': outstanding_amount,
'due_date': due_date
})
)
outstanding_invoices = sorted(outstanding_invoices, key=lambda k: k['due_date'] or getdate(nowdate()))
return outstanding_invoices
@ -859,5 +866,3 @@ def get_allow_cost_center_in_entry_of_bs_account():
def generator():
return cint(frappe.db.get_value('Accounts Settings', None, 'allow_cost_center_in_entry_of_bs_account'))
return frappe.local_cache("get_allow_cost_center_in_entry_of_bs_account", (), generator, regenerate_if_none=True)

View File

@ -95,6 +95,8 @@ frappe.ui.form.on('Payroll Entry', {
},
setup: function (frm) {
frm.add_fetch('company', 'cost_center', 'cost_center');
frm.set_query("payment_account", function () {
var account_types = ["Bank", "Cash"];
return {

View File

@ -1,5 +1,6 @@
{
"allow_copy": 1,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@ -861,7 +862,8 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "company.cost_center",
"default": ":Company",
"fetch_from": "",
"fieldname": "cost_center",
"fieldtype": "Link",
"hidden": 0,
@ -1189,7 +1191,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-08-21 16:15:45.276711",
"modified": "2019-02-05 10:41:08.865842",
"modified_by": "Administrator",
"module": "HR",
"name": "Payroll Entry",

View File

@ -21,6 +21,8 @@ class TestPayrollEntry(unittest.TestCase):
make_earning_salary_component(setup=True)
make_deduction_salary_component(setup=True)
frappe.db.set_value("HR Settings", None, "email_salary_slip_to_employee", 0)
def test_payroll_entry(self): # pylint: disable=no-self-use
company = erpnext.get_default_company()
for data in frappe.get_all('Salary Component', fields = ["name"]):

View File

@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@ -348,7 +349,7 @@
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"columns": 0,
@ -417,7 +418,7 @@
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"columns": 0,
@ -692,7 +693,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2018-09-20 16:59:33.622652",
"modified": "2019-02-04 14:41:56.030991",
"modified_by": "Administrator",
"module": "HR",
"name": "Salary Detail",

View File

@ -78,39 +78,6 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "operation",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Item operation",
"length": 0,
"no_copy": 0,
"options": "Operation",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
@ -926,38 +893,6 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "allow_alternative_item",
"fieldtype": "Check",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Allow Alternative Item",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
@ -1115,4 +1050,4 @@
"track_changes": 0,
"track_seen": 0,
"track_views": 0
}
}

View File

@ -57,7 +57,7 @@ class JobCard(Document):
.format(d.idx, d.item_code))
if self.get('operation') == d.operation:
child = self.append('items', {
self.append('items', {
'item_code': d.item_code,
'source_warehouse': d.source_warehouse,
'uom': frappe.db.get_value("Item", d.item_code, 'stock_uom'),
@ -108,6 +108,10 @@ class JobCard(Document):
if not self.items:
self.transferred_qty = self.for_quantity if self.docstatus == 1 else 0
doc = frappe.get_doc('Work Order', self.get('work_order'))
if doc.transfer_material_against == 'Work Order' or doc.skip_transfer:
return
if self.items:
self.transferred_qty = frappe.db.get_value('Stock Entry', {
'job_card': self.name,

View File

@ -567,7 +567,7 @@ def get_items_for_material_requests(doc, sales_order=None, company=None):
else:
item_details = get_subitems(doc, data, item_details, bom_no, company,
include_non_stock_items, include_subcontracted_items, 1, planned_qty=planned_qty)
else:
elif data.get('item_code'):
item_master = frappe.get_doc('Item', data['item_code']).as_dict()
purchase_uom = item_master.purchase_uom or item_master.stock_uom
conversion_factor = 0

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals
import frappe
from datetime import datetime
from frappe.utils import getdate
from erpnext.hr.doctype.salary_structure_assignment.salary_structure_assignment import DuplicateAssignment
def execute():
@ -31,14 +32,22 @@ def execute():
where is_active='Yes'
AND employee in (select name from `tabEmployee` where ifNull(status, '') != 'Left')
""".format(cols), as_dict=1)
for d in ss_details:
try:
joining_date, relieving_date = frappe.db.get_value("Employee", d.employee,
["date_of_joining", "relieving_date"])
from_date = d.from_date
if joining_date and getdate(from_date) < joining_date:
from_date = joining_date
elif relieving_date and getdate(from_date) > relieving_date:
continue
s = frappe.new_doc("Salary Structure Assignment")
s.employee = d.employee
s.employee_name = d.employee_name
s.salary_structure = d.salary_structure
s.from_date = d.from_date
s.from_date = from_date
s.to_date = d.to_date if isinstance(d.to_date, datetime) else None
s.base = d.get("base")
s.variable = d.get("variable")

View File

@ -459,7 +459,7 @@ def get_projects_for_collect_progress(frequency, fields):
fields.extend(["name"])
return frappe.get_all("Project", fields = fields,
filters = {'collect_progress': 1, 'frequency': frequency})
filters = {'collect_progress': 1, 'frequency': frequency, 'status': 'Open'})
def send_project_update_email_to_users(project):
doc = frappe.get_doc('Project', project)

View File

@ -53,7 +53,20 @@ export default {
image: null,
sections: [],
menu_items: [
};
},
computed: {
is_own_item() {
let is_own_item = false;
if(this.item) {
if(this.item.hub_seller === hub.settings.hub_seller_name) {
is_own_item = true;
}
}
return is_own_item;
},
menu_items(){
return [
{
label: __('Save Item'),
condition: hub.is_user_registered() && !this.is_own_item,
@ -75,17 +88,6 @@ export default {
action: this.unpublish_item
}
]
};
},
computed: {
is_own_item() {
let is_own_item = false;
if(this.item) {
if(this.item.hub_seller === hub.settings.hub_seller_name) {
is_own_item = true;
}
}
return is_own_item;
},
item_subtitle() {
@ -272,11 +274,11 @@ export default {
},
edit_details() {
//
frappe.msgprint(__('This feature is under development...'));
},
unpublish_item() {
//
frappe.msgprint(__('This feature is under development...'));
}
}
}

View File

@ -13,7 +13,13 @@ def get_data(item_code=None, warehouse=None, item_group=None,
if warehouse:
filters.append(['warehouse', '=', warehouse])
if item_group:
filters.append(['item_group', '=', item_group])
lft, rgt = frappe.db.get_value("Item Group", item_group, ["lft", "rgt"])
items = frappe.db.sql_list("""
select i.name from `tabItem` i
where exists(select name from `tabItem Group`
where name=i.item_group and lft >=%s and rgt<=%s)
""", (lft, rgt))
filters.append(['item_code', 'in', items])
try:
# check if user has any restrictions based on user permissions on warehouse
if DatabaseQuery('Warehouse', user=frappe.session.user).build_match_conditions():

View File

@ -15,7 +15,7 @@
{{ chapter_button() }}
<p><a href="">Leave Chapter</a></p>
{% else %}
{% if frappe.local.request.method=='POST' %}
{% if request.method=='POST' %}
<p>Welcome to chapter {{ chapter.name }}!</p>
{{ chapter_button() }}
{% else %}