Merge branch 'develop' into fix-#23231
This commit is contained in:
commit
e6666609e3
@ -68,6 +68,28 @@ frappe.ui.form.on('Asset Repair', {
|
|||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on('Asset Repair Consumed Item', {
|
frappe.ui.form.on('Asset Repair Consumed Item', {
|
||||||
|
item_code: function(frm, cdt, cdn) {
|
||||||
|
var item = locals[cdt][cdn];
|
||||||
|
|
||||||
|
let item_args = {
|
||||||
|
'item_code': item.item_code,
|
||||||
|
'warehouse': frm.doc.warehouse,
|
||||||
|
'qty': item.consumed_quantity,
|
||||||
|
'serial_no': item.serial_no,
|
||||||
|
'company': frm.doc.company
|
||||||
|
};
|
||||||
|
|
||||||
|
frappe.call({
|
||||||
|
method: 'erpnext.stock.utils.get_incoming_rate',
|
||||||
|
args: {
|
||||||
|
args: item_args
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
frappe.model.set_value(cdt, cdn, 'valuation_rate', r.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
consumed_quantity: function(frm, cdt, cdn) {
|
consumed_quantity: function(frm, cdt, cdn) {
|
||||||
var row = locals[cdt][cdn];
|
var row = locals[cdt][cdn];
|
||||||
frappe.model.set_value(cdt, cdn, 'total_value', row.consumed_quantity * row.valuation_rate);
|
frappe.model.set_value(cdt, cdn, 'total_value', row.consumed_quantity * row.valuation_rate);
|
||||||
|
@ -13,12 +13,10 @@
|
|||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"fetch_from": "item.valuation_rate",
|
|
||||||
"fieldname": "valuation_rate",
|
"fieldname": "valuation_rate",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Valuation Rate",
|
"label": "Valuation Rate"
|
||||||
"read_only": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "consumed_quantity",
|
"fieldname": "consumed_quantity",
|
||||||
@ -49,7 +47,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-11-11 18:23:00.492483",
|
"modified": "2022-02-08 17:37:20.028290",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Assets",
|
"module": "Assets",
|
||||||
"name": "Asset Repair Consumed Item",
|
"name": "Asset Repair Consumed Item",
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors and Contributors
|
||||||
# See license.txt
|
# See license.txt
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import add_days, get_first_day, getdate, nowdate
|
from frappe.tests.utils import FrappeTestCase
|
||||||
|
from frappe.utils import add_days, get_first_day, getdate, now_datetime, nowdate
|
||||||
|
|
||||||
from erpnext.hr.doctype.attendance.attendance import (
|
from erpnext.hr.doctype.attendance.attendance import (
|
||||||
get_month_map,
|
get_month_map,
|
||||||
@ -16,7 +15,7 @@ from erpnext.hr.doctype.leave_application.test_leave_application import get_firs
|
|||||||
|
|
||||||
test_records = frappe.get_test_records('Attendance')
|
test_records = frappe.get_test_records('Attendance')
|
||||||
|
|
||||||
class TestAttendance(unittest.TestCase):
|
class TestAttendance(FrappeTestCase):
|
||||||
def test_mark_absent(self):
|
def test_mark_absent(self):
|
||||||
employee = make_employee("test_mark_absent@example.com")
|
employee = make_employee("test_mark_absent@example.com")
|
||||||
date = nowdate()
|
date = nowdate()
|
||||||
@ -74,12 +73,14 @@ class TestAttendance(unittest.TestCase):
|
|||||||
self.assertNotIn(first_sunday, unmarked_days)
|
self.assertNotIn(first_sunday, unmarked_days)
|
||||||
|
|
||||||
def test_unmarked_days_as_per_joining_and_relieving_dates(self):
|
def test_unmarked_days_as_per_joining_and_relieving_dates(self):
|
||||||
first_day = get_first_day(getdate())
|
now = now_datetime()
|
||||||
|
previous_month = now.month - 1
|
||||||
|
first_day = now.replace(day=1).replace(month=previous_month).date()
|
||||||
|
|
||||||
doj = add_days(first_day, 1)
|
doj = add_days(first_day, 1)
|
||||||
relieving_date = add_days(first_day, 5)
|
relieving_date = add_days(first_day, 5)
|
||||||
employee = make_employee('test_unmarked_days_as_per_doj@example.com', date_of_joining=doj,
|
employee = make_employee('test_unmarked_days_as_per_doj@example.com', date_of_joining=doj,
|
||||||
date_of_relieving=relieving_date)
|
relieving_date=relieving_date)
|
||||||
frappe.db.delete('Attendance', {'employee': employee})
|
frappe.db.delete('Attendance', {'employee': employee})
|
||||||
|
|
||||||
attendance_date = add_days(first_day, 2)
|
attendance_date = add_days(first_day, 2)
|
||||||
@ -104,4 +105,4 @@ def get_month_name(date):
|
|||||||
month_number = date.month
|
month_number = date.month
|
||||||
for month, number in get_month_map().items():
|
for month, number in get_month_map().items():
|
||||||
if number == month_number:
|
if number == month_number:
|
||||||
return month
|
return month
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
from frappe.query_builder.functions import Max, Min, Sum
|
||||||
from frappe.utils import (
|
from frappe.utils import (
|
||||||
add_days,
|
add_days,
|
||||||
cint,
|
cint,
|
||||||
@ -567,28 +568,39 @@ def get_leave_balance_on(employee, leave_type, date, to_date=None, consider_all_
|
|||||||
return get_remaining_leaves(allocation, leaves_taken, date, expiry)
|
return get_remaining_leaves(allocation, leaves_taken, date, expiry)
|
||||||
|
|
||||||
def get_leave_allocation_records(employee, date, leave_type=None):
|
def get_leave_allocation_records(employee, date, leave_type=None):
|
||||||
''' returns the total allocated leaves and carry forwarded leaves based on ledger entries '''
|
"""Returns the total allocated leaves and carry forwarded leaves based on ledger entries"""
|
||||||
|
Ledger = frappe.qb.DocType("Leave Ledger Entry")
|
||||||
|
|
||||||
conditions = ("and leave_type='%s'" % leave_type) if leave_type else ""
|
cf_leave_case = frappe.qb.terms.Case().when(Ledger.is_carry_forward == "1", Ledger.leaves).else_(0)
|
||||||
allocation_details = frappe.db.sql("""
|
sum_cf_leaves = Sum(cf_leave_case).as_("cf_leaves")
|
||||||
SELECT
|
|
||||||
SUM(CASE WHEN is_carry_forward = 1 THEN leaves ELSE 0 END) as cf_leaves,
|
new_leaves_case = frappe.qb.terms.Case().when(Ledger.is_carry_forward == "0", Ledger.leaves).else_(0)
|
||||||
SUM(CASE WHEN is_carry_forward = 0 THEN leaves ELSE 0 END) as new_leaves,
|
sum_new_leaves = Sum(new_leaves_case).as_("new_leaves")
|
||||||
MIN(from_date) as from_date,
|
|
||||||
MAX(to_date) as to_date,
|
query = (
|
||||||
leave_type
|
frappe.qb.from_(Ledger)
|
||||||
FROM `tabLeave Ledger Entry`
|
.select(
|
||||||
WHERE
|
sum_cf_leaves,
|
||||||
from_date <= %(date)s
|
sum_new_leaves,
|
||||||
AND to_date >= %(date)s
|
Min(Ledger.from_date).as_("from_date"),
|
||||||
AND docstatus=1
|
Max(Ledger.to_date).as_("to_date"),
|
||||||
AND transaction_type="Leave Allocation"
|
Ledger.leave_type
|
||||||
AND employee=%(employee)s
|
).where(
|
||||||
AND is_expired=0
|
(Ledger.from_date <= date)
|
||||||
AND is_lwp=0
|
& (Ledger.to_date >= date)
|
||||||
{0}
|
& (Ledger.docstatus == 1)
|
||||||
GROUP BY employee, leave_type
|
& (Ledger.transaction_type == "Leave Allocation")
|
||||||
""".format(conditions), dict(date=date, employee=employee), as_dict=1) #nosec
|
& (Ledger.employee == employee)
|
||||||
|
& (Ledger.is_expired == 0)
|
||||||
|
& (Ledger.is_lwp == 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if leave_type:
|
||||||
|
query = query.where((Ledger.leave_type == leave_type))
|
||||||
|
query = query.groupby(Ledger.employee, Ledger.leave_type)
|
||||||
|
|
||||||
|
allocation_details = query.run(as_dict=True)
|
||||||
|
|
||||||
allocated_leaves = frappe._dict()
|
allocated_leaves = frappe._dict()
|
||||||
for d in allocation_details:
|
for d in allocation_details:
|
||||||
|
@ -792,4 +792,4 @@ def get_first_sunday(holiday_list):
|
|||||||
order by holiday_date
|
order by holiday_date
|
||||||
""", (holiday_list, month_start_date, month_end_date))[0][0]
|
""", (holiday_list, month_start_date, month_end_date))[0][0]
|
||||||
|
|
||||||
return first_sunday
|
return first_sunday
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import unittest
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.tests.utils import FrappeTestCase
|
||||||
from frappe.utils import add_days, getdate
|
from frappe.utils import add_days, getdate
|
||||||
|
|
||||||
from erpnext.hr.doctype.employee.test_employee import make_employee
|
from erpnext.hr.doctype.employee.test_employee import make_employee
|
||||||
@ -12,7 +11,7 @@ from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_
|
|||||||
from erpnext.projects.report.project_profitability.project_profitability import execute
|
from erpnext.projects.report.project_profitability.project_profitability import execute
|
||||||
|
|
||||||
|
|
||||||
class TestProjectProfitability(unittest.TestCase):
|
class TestProjectProfitability(FrappeTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
frappe.db.sql('delete from `tabTimesheet`')
|
frappe.db.sql('delete from `tabTimesheet`')
|
||||||
emp = make_employee('test_employee_9@salary.com', company='_Test Company')
|
emp = make_employee('test_employee_9@salary.com', company='_Test Company')
|
||||||
@ -67,6 +66,3 @@ class TestProjectProfitability(unittest.TestCase):
|
|||||||
|
|
||||||
fractional_cost = self.salary_slip.base_gross_pay * utilization
|
fractional_cost = self.salary_slip.base_gross_pay * utilization
|
||||||
self.assertEqual(fractional_cost, row.fractional_cost)
|
self.assertEqual(fractional_cost, row.fractional_cost)
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
frappe.db.rollback()
|
|
||||||
|
@ -156,24 +156,24 @@ def get_data(filters):
|
|||||||
customer_record = customer_details.get(record.customer)
|
customer_record = customer_details.get(record.customer)
|
||||||
item_record = item_details.get(record.item_code)
|
item_record = item_details.get(record.item_code)
|
||||||
row = {
|
row = {
|
||||||
"item_code": record.item_code,
|
"item_code": record.get('item_code'),
|
||||||
"item_name": item_record.item_name,
|
"item_name": item_record.get('item_name'),
|
||||||
"item_group": item_record.item_group,
|
"item_group": item_record.get('item_group'),
|
||||||
"description": record.description,
|
"description": record.get('description'),
|
||||||
"quantity": record.qty,
|
"quantity": record.get('qty'),
|
||||||
"uom": record.uom,
|
"uom": record.get('uom'),
|
||||||
"rate": record.base_rate,
|
"rate": record.get('base_rate'),
|
||||||
"amount": record.base_amount,
|
"amount": record.get('base_amount'),
|
||||||
"sales_order": record.name,
|
"sales_order": record.get('name'),
|
||||||
"transaction_date": record.transaction_date,
|
"transaction_date": record.get('transaction_date'),
|
||||||
"customer": record.customer,
|
"customer": record.get('customer'),
|
||||||
"customer_name": customer_record.customer_name,
|
"customer_name": customer_record.get('customer_name'),
|
||||||
"customer_group": customer_record.customer_group,
|
"customer_group": customer_record.get('customer_group'),
|
||||||
"territory": record.territory,
|
"territory": record.get('territory'),
|
||||||
"project": record.project,
|
"project": record.get('project'),
|
||||||
"delivered_quantity": flt(record.delivered_qty),
|
"delivered_quantity": flt(record.get('delivered_qty')),
|
||||||
"billed_amount": flt(record.billed_amt),
|
"billed_amount": flt(record.get('billed_amt')),
|
||||||
"company": record.company
|
"company": record.get('company')
|
||||||
}
|
}
|
||||||
data.append(row)
|
data.append(row)
|
||||||
|
|
||||||
|
@ -272,9 +272,9 @@ def get_available_item_locations_for_batched_item(item_code, from_warehouses, re
|
|||||||
and IFNULL(batch.`expiry_date`, '2200-01-01') > %(today)s
|
and IFNULL(batch.`expiry_date`, '2200-01-01') > %(today)s
|
||||||
{warehouse_condition}
|
{warehouse_condition}
|
||||||
GROUP BY
|
GROUP BY
|
||||||
`warehouse`,
|
sle.`warehouse`,
|
||||||
`batch_no`,
|
sle.`batch_no`,
|
||||||
`item_code`
|
sle.`item_code`
|
||||||
HAVING `qty` > 0
|
HAVING `qty` > 0
|
||||||
ORDER BY IFNULL(batch.`expiry_date`, '2200-01-01'), batch.`creation`
|
ORDER BY IFNULL(batch.`expiry_date`, '2200-01-01'), batch.`creation`
|
||||||
""".format(warehouse_condition=warehouse_condition), { #nosec
|
""".format(warehouse_condition=warehouse_condition), { #nosec
|
||||||
|
Loading…
x
Reference in New Issue
Block a user