Merge branch 'develop' of https://github.com/frappe/erpnext into develop

This commit is contained in:
Khushal Trivedi 2019-12-09 16:52:24 +05:30
commit c08ce703c9
44 changed files with 470 additions and 180 deletions

View File

@ -332,6 +332,7 @@
"label": "Reference"
},
{
"depends_on": "eval:doc.docstatus==0",
"fieldname": "get_outstanding_invoice",
"fieldtype": "Button",
"label": "Get Outstanding Invoice"
@ -575,7 +576,7 @@
}
],
"is_submittable": 1,
"modified": "2019-11-06 12:59:43.151721",
"modified": "2019-12-08 13:02:30.016610",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Entry",

View File

@ -830,7 +830,11 @@ class PurchaseInvoice(BuyingController):
)
def make_gle_for_rounding_adjustment(self, gl_entries):
if self.rounding_adjustment:
# if rounding adjustment in small and conversion rate is also small then
# base_rounding_adjustment may become zero due to small precision
# eg: rounding_adjustment = 0.01 and exchange rate = 0.05 and precision of base_rounding_adjustment is 2
# then base_rounding_adjustment becomes zero and error is thrown in GL Entry
if self.rounding_adjustment and self.base_rounding_adjustment:
round_off_account, round_off_cost_center = \
get_round_off_account_and_cost_center(self.company)

View File

@ -953,7 +953,7 @@ class SalesInvoice(SellingController):
)
def make_gle_for_rounding_adjustment(self, gl_entries):
if flt(self.rounding_adjustment, self.precision("rounding_adjustment")):
if flt(self.rounding_adjustment, self.precision("rounding_adjustment")) and self.base_rounding_adjustment:
round_off_account, round_off_cost_center = \
get_round_off_account_and_cost_center(self.company)

View File

@ -1,4 +1,5 @@
{
"actions": [],
"autoname": "hash",
"creation": "2013-05-24 19:29:06",
"doctype": "DocType",
@ -43,6 +44,7 @@
"base_amount",
"pricing_rules",
"is_free_item",
"is_fixed_asset",
"section_break_29",
"net_rate",
"net_amount",
@ -708,11 +710,20 @@
"fieldname": "against_blanket_order",
"fieldtype": "Check",
"label": "Against Blanket Order"
},
{
"default": "0",
"fetch_from": "item_code.is_fixed_asset",
"fieldname": "is_fixed_asset",
"fieldtype": "Check",
"label": "Is Fixed Asset",
"read_only": 1
}
],
"idx": 1,
"istable": 1,
"modified": "2019-11-19 14:10:52.865006",
"links": [],
"modified": "2019-12-06 13:17:12.142799",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order Item",

View File

@ -3,18 +3,18 @@
"app": "ERPNext",
"creation": "2019-11-15 14:45:32.626641",
"docstatus": 0,
"doctype": "Setup Wizard Slide",
"doctype": "Onboarding Slide",
"domains": [],
"help_links": [
{
"label": "Supplier",
"label": "Learn More",
"video_id": "zsrrVDk6VBs"
}
],
"idx": 0,
"image_src": "/assets/erpnext/images/illustrations/supplier.png",
"image_src": "/assets/erpnext/images/illustrations/supplier-onboard.png",
"max_count": 3,
"modified": "2019-11-26 18:26:25.498325",
"modified": "2019-12-03 22:53:50.552445",
"modified_by": "Administrator",
"name": "Add A Few Suppliers",
"owner": "Administrator",
@ -44,6 +44,5 @@
],
"slide_order": 50,
"slide_title": "Add A Few Suppliers",
"slide_type": "Create",
"submit_method": ""
"slide_type": "Create"
}

View File

@ -5,9 +5,10 @@
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import date_diff, add_days, getdate
from frappe.utils import date_diff, add_days, getdate, cint
from frappe.model.document import Document
from erpnext.hr.utils import validate_dates, validate_overlap, get_leave_period, get_holidays_for_employee
from erpnext.hr.utils import validate_dates, validate_overlap, get_leave_period, \
get_holidays_for_employee, create_additional_leave_ledger_entry
class CompensatoryLeaveRequest(Document):
@ -25,16 +26,14 @@ class CompensatoryLeaveRequest(Document):
frappe.throw(_("Leave Type is madatory"))
def validate_attendance(self):
query = """select attendance_date, status
from `tabAttendance` where
attendance_date between %(work_from_date)s and %(work_end_date)s
and docstatus=1 and status = 'Present' and employee=%(employee)s"""
attendance = frappe.get_all('Attendance',
filters={
'attendance_date': ['between', (self.work_from_date, self.work_end_date)],
'status': 'Present',
'docstatus': 1,
'employee': self.employee
}, fields=['attendance_date', 'status'])
attendance = frappe.db.sql(query, {
"work_from_date": self.work_from_date,
"work_end_date": self.work_end_date,
"employee": self.employee
}, as_dict=True)
if len(attendance) < date_diff(self.work_end_date, self.work_from_date) + 1:
frappe.throw(_("You are not present all day(s) between compensatory leave request days"))
@ -50,13 +49,19 @@ class CompensatoryLeaveRequest(Document):
date_difference -= 0.5
leave_period = get_leave_period(self.work_from_date, self.work_end_date, company)
if leave_period:
leave_allocation = self.exists_allocation_for_period(leave_period)
leave_allocation = self.get_existing_allocation_for_period(leave_period)
if leave_allocation:
leave_allocation.new_leaves_allocated += date_difference
leave_allocation.submit()
leave_allocation.validate()
leave_allocation.db_set("new_leaves_allocated", leave_allocation.total_leaves_allocated)
leave_allocation.db_set("total_leaves_allocated", leave_allocation.total_leaves_allocated)
# generate additional ledger entry for the new compensatory leaves off
create_additional_leave_ledger_entry(leave_allocation, date_difference, add_days(self.work_end_date, 1))
else:
leave_allocation = self.create_leave_allocation(leave_period, date_difference)
self.db_set("leave_allocation", leave_allocation.name)
self.leave_allocation=leave_allocation.name
else:
frappe.throw(_("There is no leave period in between {0} and {1}").format(self.work_from_date, self.work_end_date))
@ -68,11 +73,16 @@ class CompensatoryLeaveRequest(Document):
leave_allocation = frappe.get_doc("Leave Allocation", self.leave_allocation)
if leave_allocation:
leave_allocation.new_leaves_allocated -= date_difference
if leave_allocation.total_leaves_allocated - date_difference <= 0:
leave_allocation.total_leaves_allocated = 0
leave_allocation.submit()
if leave_allocation.new_leaves_allocated - date_difference <= 0:
leave_allocation.new_leaves_allocated = 0
leave_allocation.validate()
leave_allocation.db_set("new_leaves_allocated", leave_allocation.total_leaves_allocated)
leave_allocation.db_set("total_leaves_allocated", leave_allocation.total_leaves_allocated)
def exists_allocation_for_period(self, leave_period):
# create reverse entry on cancelation
create_additional_leave_ledger_entry(leave_allocation, date_difference * -1, add_days(self.work_end_date, 1))
def get_existing_allocation_for_period(self, leave_period):
leave_allocation = frappe.db.sql("""
select name
from `tabLeave Allocation`
@ -95,17 +105,18 @@ class CompensatoryLeaveRequest(Document):
def create_leave_allocation(self, leave_period, date_difference):
is_carry_forward = frappe.db.get_value("Leave Type", self.leave_type, "is_carry_forward")
allocation = frappe.new_doc("Leave Allocation")
allocation.employee = self.employee
allocation.employee_name = self.employee_name
allocation.leave_type = self.leave_type
allocation.from_date = add_days(self.work_end_date, 1)
allocation.to_date = leave_period[0].to_date
allocation.new_leaves_allocated = date_difference
allocation.total_leaves_allocated = date_difference
allocation.description = self.reason
if is_carry_forward == 1:
allocation.carry_forward = True
allocation.save(ignore_permissions = True)
allocation = frappe.get_doc(dict(
doctype="Leave Allocation",
employee=self.employee,
employee_name=self.employee_name,
leave_type=self.leave_type,
from_date=add_days(self.work_end_date, 1),
to_date=leave_period[0].to_date,
carry_forward=cint(is_carry_forward),
new_leaves_allocated=date_difference,
total_leaves_allocated=date_difference,
description=self.reason
))
allocation.insert(ignore_permissions=True)
allocation.submit()
return allocation

View File

@ -5,37 +5,128 @@ from __future__ import unicode_literals
import frappe
import unittest
from frappe.utils import today, add_months, add_days
from erpnext.hr.doctype.attendance_request.test_attendance_request import get_employee
from erpnext.hr.doctype.leave_period.test_leave_period import create_leave_period
from erpnext.hr.doctype.leave_application.leave_application import get_leave_balance_on
# class TestCompensatoryLeaveRequest(unittest.TestCase):
# def get_compensatory_leave_request(self):
# return frappe.get_doc('Compensatory Leave Request', dict(
# employee = employee,
# work_from_date = today,
# work_to_date = today,
# reason = 'test'
# )).insert()
#
# def test_creation_of_leave_allocation(self):
# employee = get_employee()
# today = get_today()
#
# compensatory_leave_request = self.get_compensatory_leave_request(today)
#
# before = get_leave_balance(employee, compensatory_leave_request.leave_type)
#
# compensatory_leave_request.submit()
#
# self.assertEqual(get_leave_balance(employee, compensatory_leave_request.leave_type), before + 1)
#
# def test_max_compensatory_leave(self):
# employee = get_employee()
# today = get_today()
#
# compensatory_leave_request = self.get_compensatory_leave_request()
#
# frappe.db.set_value('Leave Type', compensatory_leave_request.leave_type, 'max_leaves_allowed', 0)
#
# self.assertRaises(MaxLeavesLimitCrossed, compensatory_leave_request.submit)
#
# frappe.db.set_value('Leave Type', compensatory_leave_request.leave_type, 'max_leaves_allowed', 10)
#
class TestCompensatoryLeaveRequest(unittest.TestCase):
def setUp(self):
frappe.db.sql(''' delete from `tabCompensatory Leave Request`''')
frappe.db.sql(''' delete from `tabLeave Ledger Entry`''')
frappe.db.sql(''' delete from `tabLeave Allocation`''')
frappe.db.sql(''' delete from `tabAttendance` where attendance_date in {0} '''.format((today(), add_days(today(), -1)))) #nosec
create_leave_period(add_months(today(), -3), add_months(today(), 3), "_Test Company")
create_holiday_list()
employee = get_employee()
employee.holiday_list = "_Test Compensatory Leave"
employee.save()
def test_leave_balance_on_submit(self):
''' check creation of leave allocation on submission of compensatory leave request '''
employee = get_employee()
mark_attendance(employee)
compensatory_leave_request = get_compensatory_leave_request(employee.name)
before = get_leave_balance_on(employee.name, compensatory_leave_request.leave_type, today())
compensatory_leave_request.submit()
self.assertEqual(get_leave_balance_on(employee.name, compensatory_leave_request.leave_type, add_days(today(), 1)), before + 1)
def test_leave_allocation_update_on_submit(self):
employee = get_employee()
mark_attendance(employee, date=add_days(today(), -1))
compensatory_leave_request = get_compensatory_leave_request(employee.name, leave_date=add_days(today(), -1))
compensatory_leave_request.submit()
# leave allocation creation on submit
leaves_allocated = frappe.db.get_value('Leave Allocation', {
'name': compensatory_leave_request.leave_allocation
}, ['total_leaves_allocated'])
self.assertEqual(leaves_allocated, 1)
mark_attendance(employee)
compensatory_leave_request = get_compensatory_leave_request(employee.name)
compensatory_leave_request.submit()
# leave allocation updates on submission of second compensatory leave request
leaves_allocated = frappe.db.get_value('Leave Allocation', {
'name': compensatory_leave_request.leave_allocation
}, ['total_leaves_allocated'])
self.assertEqual(leaves_allocated, 2)
def test_creation_of_leave_ledger_entry_on_submit(self):
''' check creation of leave ledger entry on submission of leave request '''
employee = get_employee()
mark_attendance(employee)
compensatory_leave_request = get_compensatory_leave_request(employee.name)
compensatory_leave_request.submit()
filters = dict(transaction_name=compensatory_leave_request.leave_allocation)
leave_ledger_entry = frappe.get_all('Leave Ledger Entry', fields='*', filters=filters)
self.assertEquals(len(leave_ledger_entry), 1)
self.assertEquals(leave_ledger_entry[0].employee, compensatory_leave_request.employee)
self.assertEquals(leave_ledger_entry[0].leave_type, compensatory_leave_request.leave_type)
self.assertEquals(leave_ledger_entry[0].leaves, 1)
# check reverse leave ledger entry on cancellation
compensatory_leave_request.cancel()
leave_ledger_entry = frappe.get_all('Leave Ledger Entry', fields='*', filters=filters, order_by = 'creation desc')
self.assertEquals(len(leave_ledger_entry), 2)
self.assertEquals(leave_ledger_entry[0].employee, compensatory_leave_request.employee)
self.assertEquals(leave_ledger_entry[0].leave_type, compensatory_leave_request.leave_type)
self.assertEquals(leave_ledger_entry[0].leaves, -1)
def get_compensatory_leave_request(employee, leave_date=today()):
prev_comp_leave_req = frappe.db.get_value('Compensatory Leave Request',
dict(leave_type='Compensatory Off',
work_from_date=leave_date,
work_end_date=leave_date,
employee=employee), 'name')
if prev_comp_leave_req:
return frappe.get_doc('Compensatory Leave Request', prev_comp_leave_req)
return frappe.get_doc(dict(
doctype='Compensatory Leave Request',
employee=employee,
leave_type='Compensatory Off',
work_from_date=leave_date,
work_end_date=leave_date,
reason='test'
)).insert()
def mark_attendance(employee, date=today(), status='Present'):
if not frappe.db.exists(dict(doctype='Attendance', employee=employee.name, attendance_date=date, status='Present')):
attendance = frappe.get_doc({
"doctype": "Attendance",
"employee": employee.name,
"attendance_date": date,
"status": status
})
attendance.save()
attendance.submit()
def create_holiday_list():
if frappe.db.exists("Holiday List", "_Test Compensatory Leave"):
return
holiday_list = frappe.get_doc({
"doctype": "Holiday List",
"from_date": add_months(today(), -3),
"to_date": add_months(today(), 3),
"holidays": [
{
"description": "Test Holiday",
"holiday_date": today()
},
{
"description": "Test Holiday 1",
"holiday_date": add_days(today(), -1)
}
],
"holiday_list_name": "_Test Compensatory Leave"
})
holiday_list.save()

View File

@ -69,10 +69,14 @@ class LeaveAllocation(Document):
def validate_allocation_overlap(self):
leave_allocation = frappe.db.sql("""
select name from `tabLeave Allocation`
where employee=%s and leave_type=%s and docstatus=1
and to_date >= %s and from_date <= %s""",
(self.employee, self.leave_type, self.from_date, self.to_date))
SELECT
name
FROM `tabLeave Allocation`
WHERE
employee=%s AND leave_type=%s
AND name <> %s AND docstatus=1
AND to_date >= %s AND from_date <= %s""",
(self.employee, self.leave_type, self.name, self.from_date, self.to_date))
if leave_allocation:
frappe.msgprint(_("{0} already allocated for Employee {1} for period {2} to {3}")

View File

@ -549,10 +549,10 @@ def get_leaves_for_period(employee, leave_type, from_date, to_date):
leave_days += leave_entry.leaves
elif inclusive_period and leave_entry.transaction_type == 'Leave Allocation' \
and not skip_expiry_leaves(leave_entry, to_date):
and leave_entry.is_expired and not skip_expiry_leaves(leave_entry, to_date):
leave_days += leave_entry.leaves
else:
elif leave_entry.transaction_type == 'Leave Application':
if leave_entry.from_date < getdate(from_date):
leave_entry.from_date = from_date
if leave_entry.to_date > getdate(to_date):
@ -579,14 +579,15 @@ def skip_expiry_leaves(leave_entry, date):
def get_leave_entries(employee, leave_type, from_date, to_date):
''' Returns leave entries between from_date and to_date '''
return frappe.db.sql("""
select employee, leave_type, from_date, to_date, leaves, transaction_type, is_carry_forward, transaction_name
from `tabLeave Ledger Entry`
where employee=%(employee)s and leave_type=%(leave_type)s
and docstatus=1
and leaves<0
and (from_date between %(from_date)s and %(to_date)s
or to_date between %(from_date)s and %(to_date)s
or (from_date < %(from_date)s and to_date > %(to_date)s))
SELECT
employee, leave_type, from_date, to_date, leaves, transaction_name, transaction_type,
is_carry_forward, is_expired
FROM `tabLeave Ledger Entry`
WHERE employee=%(employee)s AND leave_type=%(leave_type)s
AND docstatus=1 AND leaves<0
AND (from_date between %(from_date)s AND %(to_date)s
OR to_date between %(from_date)s AND %(to_date)s
OR (from_date < %(from_date)s AND to_date > %(to_date)s))
""", {
"from_date": from_date,
"to_date": to_date,

View File

@ -43,10 +43,18 @@ class TestLeavePeriod(unittest.TestCase):
leave_period.grant_leave_allocation(employee=employee_doc_name)
self.assertEqual(get_leave_balance_on(employee_doc_name, leave_type, today()), 20)
def create_leave_period(from_date, to_date):
def create_leave_period(from_date, to_date, company=None):
leave_period = frappe.db.get_value('Leave Period',
dict(company=company or erpnext.get_default_company(),
from_date=from_date,
to_date=to_date,
is_active=1), 'name')
if leave_period:
return frappe.get_doc("Leave Period", leave_period)
leave_period = frappe.get_doc({
"doctype": "Leave Period",
"company": erpnext.get_default_company(),
"company": company or erpnext.get_default_company(),
"from_date": from_date,
"to_date": to_date,
"is_active": 1

View File

@ -321,11 +321,11 @@ def allocate_earned_leaves():
if new_allocation == allocation.total_leaves_allocated:
continue
allocation.db_set("total_leaves_allocated", new_allocation, update_modified=False)
create_earned_leave_ledger_entry(allocation, earned_leaves, today)
create_additional_leave_ledger_entry(allocation, earned_leaves, today)
def create_earned_leave_ledger_entry(allocation, earned_leaves, date):
''' Create leave ledger entry based on the earned leave frequency '''
allocation.new_leaves_allocated = earned_leaves
def create_additional_leave_ledger_entry(allocation, leaves, date):
''' Create leave ledger entry for leave types '''
allocation.new_leaves_allocated = leaves
allocation.from_date = date
allocation.unused_leaves = 0
allocation.create_leave_ledger_entry()
@ -389,6 +389,7 @@ def get_sal_slip_total_benefit_given(employee, payroll_period, component=False):
def get_holidays_for_employee(employee, start_date, end_date):
holiday_list = get_holiday_list_for_employee(employee)
holidays = frappe.db.sql_list('''select holiday_date from `tabHoliday`
where
parent=%(holiday_list)s

View File

@ -606,6 +606,7 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite
item.image,
bom.project,
item.stock_uom,
item.item_group,
item.allow_alternative_item,
item_default.default_warehouse,
item_default.expense_account as expense_account,

View File

@ -615,6 +615,9 @@ def get_items_for_material_requests(doc, ignore_existing_ordered_qty=None):
doc['mr_items'] = []
po_items = doc.get('po_items') if doc.get('po_items') else doc.get('items')
if not po_items:
frappe.throw(_("Items are required to pull the raw materials which is associated with it."))
company = doc.get('company')
warehouse = doc.get('for_warehouse')

View File

@ -4,20 +4,16 @@ frappe.ui.form.on("Project", {
setup(frm) {
frm.make_methods = {
'Timesheet': () => {
let doctype = 'Timesheet';
frappe.model.with_doctype(doctype, () => {
let new_doc = frappe.model.get_new_doc(doctype);
// add a new row and set the project
let time_log = frappe.model.get_new_doc('Timesheet Detail');
time_log.project = frm.doc.name;
time_log.parent = new_doc.name;
time_log.parentfield = 'time_logs';
time_log.parenttype = 'Timesheet';
new_doc.time_logs = [time_log];
frappe.ui.form.make_quick_entry(doctype, null, null, new_doc);
});
open_form(frm, "Timesheet", "Timesheet Detail", "time_logs");
},
'Purchase Order': () => {
open_form(frm, "Purchase Order", "Purchase Order Item", "items");
},
'Purchase Receipt': () => {
open_form(frm, "Purchase Receipt", "Purchase Receipt Item", "items");
},
'Purchase Invoice': () => {
open_form(frm, "Purchase Invoice", "Purchase Invoice Item", "items");
},
};
},
@ -123,3 +119,20 @@ frappe.ui.form.on("Project", {
},
});
function open_form(frm, doctype, child_doctype, parentfield) {
frappe.model.with_doctype(doctype, () => {
let new_doc = frappe.model.get_new_doc(doctype);
// add a new row and set the project
let new_child_doc = frappe.model.get_new_doc(child_doctype);
new_child_doc.project = frm.doc.name;
new_child_doc.parent = new_doc.name;
new_child_doc.parentfield = parentfield;
new_child_doc.parenttype = doctype;
new_doc[parentfield] = [new_child_doc];
frappe.ui.form.make_quick_entry(doctype, null, null, new_doc);
});
}

View File

@ -188,7 +188,8 @@ class Timesheet(Document):
}, as_dict=True)
# check internal overlap
for time_log in self.time_logs:
if not (time_log.from_time or time_log.to_time): continue
if not (time_log.from_time and time_log.to_time
and args.from_time and args.to_time): continue
if (fieldname != 'workstation' or args.get(fieldname) == time_log.get(fieldname)) and \
args.idx != time_log.idx and ((args.from_time > time_log.from_time and args.from_time < time_log.to_time) or

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

View File

@ -24,7 +24,7 @@ import NotFound from './pages/NotFound.vue';
function get_route_map() {
const read_only_routes = {
'marketplace/home': Home,
'marketplace/search/:keyword': Search,
'marketplace/search/:category/:keyword': Search,
'marketplace/category/:category': Category,
'marketplace/item/:item': Item,
'marketplace/seller/:seller': Seller,

View File

@ -3,6 +3,12 @@
class="marketplace-page"
:data-page-name="page_name"
>
<search-input
:placeholder="search_placeholder"
:on_search="set_search_route"
v-model="search_value"
/>
<h5>{{ page_title }}</h5>
<item-cards-container
@ -26,7 +32,13 @@ export default {
item_id_fieldname: 'name',
// Constants
empty_state_message: __(`No items in this category yet.`)
empty_state_message: __(`No items in this category yet.`),
search_value: '',
// Constants
search_placeholder: __('Search for anything ...'),
};
},
computed: {
@ -35,6 +47,7 @@ export default {
}
},
created() {
this.search_value = '';
this.get_items();
},
methods: {
@ -51,7 +64,11 @@ export default {
go_to_item_details_page(hub_item_name) {
frappe.set_route(`marketplace/item/${hub_item_name}`);
}
},
set_search_route() {
frappe.set_route('marketplace', 'search', this.category, this.search_value);
},
}
}
</script>

View File

@ -98,7 +98,7 @@ export default {
},
set_search_route() {
frappe.set_route('marketplace', 'search', this.search_value);
frappe.set_route('marketplace', 'search', 'All', this.search_value);
},
}
}

View File

@ -29,8 +29,10 @@ export default {
return {
page_name: frappe.get_route()[1],
items: [],
search_value: frappe.get_route()[2],
category: frappe.get_route()[2],
search_value: frappe.get_route()[3],
item_id_fieldname: 'name',
filters: {},
// Constants
search_placeholder: __('Search for anything ...'),
@ -40,7 +42,7 @@ export default {
computed: {
page_title() {
return this.items.length
? __(`Results for "${this.search_value}"`)
? __(`Results for "${this.search_value}" ${this.category !== 'All'? `in category ${this.category}` : ''}`)
: __('No Items found.');
}
},
@ -49,14 +51,20 @@ export default {
},
methods: {
get_items() {
hub.call('get_items', { keyword: this.search_value })
if (this.category !== 'All') {
this.filters['hub_category'] = this.category;
}
hub.call('get_items', {
keyword: this.search_value,
filters: this.filters
})
.then((items) => {
this.items = items;
})
},
set_route_and_get_items() {
frappe.set_route('marketplace', 'search', this.search_value);
frappe.set_route('marketplace', 'search', this.category, this.search_value);
this.get_items();
},

View File

@ -55,14 +55,25 @@ frappe.query_reports["GSTR-1"] = {
report.page.add_inner_button(__("Download as JSON"), function () {
var filters = report.get_values();
const args = {
cmd: 'erpnext.regional.report.gstr_1.gstr_1.get_json',
frappe.call({
method: 'erpnext.regional.report.gstr_1.gstr_1.get_json',
args: {
data: report.data,
report_name: report.report_name,
filters: filters
},
callback: function(r) {
if (r.message) {
const args = {
cmd: 'erpnext.regional.report.gstr_1.gstr_1.download_json_file',
data: r.message.data,
report_name: r.message.report_name,
report_type: r.message.report_type
};
open_url_post(frappe.request.url, args);
}
}
});
});
}
}

View File

@ -532,16 +532,9 @@ class Gstr1Report(object):
self.columns = self.invoice_columns + self.tax_columns + self.other_columns
@frappe.whitelist()
def get_json():
data = frappe._dict(frappe.local.form_dict)
del data["cmd"]
if "csrf_token" in data:
del data["csrf_token"]
filters = json.loads(data["filters"])
report_data = json.loads(data["data"])
report_name = data["report_name"]
def get_json(filters, report_name, data):
filters = json.loads(filters)
report_data = json.loads(data)
gstin = get_company_gstin_number(filters["company"])
fp = "%02d%s" % (getdate(filters["to_date"]).month, getdate(filters["to_date"]).year)
@ -575,7 +568,11 @@ def get_json():
out = get_export_json(res)
gst_json["exp"] = out
download_json_file(report_name, filters["type_of_business"], gst_json)
return {
'report_name': report_name,
'report_type': filters['type_of_business'],
'data': gst_json
}
def get_b2b_json(res, gstin):
inv_type, out = {"Registered Regular": "R", "Deemed Export": "DE", "URD": "URD", "SEZ": "SEZ"}, []
@ -722,11 +719,15 @@ def get_company_gstin_number(company):
if gstin:
return gstin[0]["gstin"]
else:
frappe.throw(_("Please set valid GSTIN No. in Company Address"))
frappe.throw(_("Please set valid GSTIN No. in Company Address for company {0}".format(
frappe.bold(company)
)))
def download_json_file(filename, report_type, data):
@frappe.whitelist()
def download_json_file():
''' download json content in a file '''
frappe.response['filename'] = frappe.scrub("{0} {1}".format(filename, report_type)) + '.json'
frappe.response['filecontent'] = json.dumps(data)
data = frappe._dict(frappe.local.form_dict)
frappe.response['filename'] = frappe.scrub("{0} {1}".format(data['report_name'], data['report_type'])) + '.json'
frappe.response['filecontent'] = data['data']
frappe.response['content_type'] = 'application/json'
frappe.response['type'] = 'download'

View File

@ -112,7 +112,6 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
let allow_delivery = false;
if (doc.docstatus==1) {
this.frm.add_custom_button(__('Pick List'), () => this.create_pick_list(), __('Create'));
if(this.frm.has_perm("submit")) {
if(doc.status === 'On Hold') {
@ -148,6 +147,8 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
}
}
this.frm.add_custom_button(__('Pick List'), () => this.create_pick_list(), __('Create'));
// delivery note
if(flt(doc.per_delivered, 6) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1 && allow_delivery) {
this.frm.add_custom_button(__('Delivery Note'), () => this.make_delivery_note_based_on_delivery_date(), __('Create'));

View File

@ -3,18 +3,18 @@
"app": "ERPNext",
"creation": "2019-11-15 14:44:10.065014",
"docstatus": 0,
"doctype": "Setup Wizard Slide",
"doctype": "Onboarding Slide",
"domains": [],
"help_links": [
{
"label": "Customers",
"label": "Learn More",
"video_id": "zsrrVDk6VBs"
}
],
"idx": 0,
"image_src": "/assets/erpnext/images/illustrations/customer.png",
"image_src": "/assets/erpnext/images/illustrations/customers-onboard.png",
"max_count": 3,
"modified": "2019-11-26 18:26:15.888794",
"modified": "2019-12-03 22:54:28.959549",
"modified_by": "Administrator",
"name": "Add A Few Customers",
"owner": "Administrator",
@ -44,6 +44,5 @@
],
"slide_order": 40,
"slide_title": "Add A Few Customers",
"slide_type": "Create",
"submit_method": ""
"slide_type": "Create"
}

View File

@ -283,7 +283,7 @@ class EmailDigest(Document):
card.value = card.value *-1
card.value = self.fmt_money(card.value,False if key in ("bank_balance", "credit_balance") else True)
cache.setex(cache_key, card, 24 * 60 * 60)
cache.set_value(cache_key, card, expires_in_sec=24 * 60 * 60)
context.cards.append(card)

View File

@ -0,0 +1,23 @@
{
"add_more_button": 0,
"app": "ERPNext",
"creation": "2019-12-04 19:21:39.995776",
"docstatus": 0,
"doctype": "Onboarding Slide",
"domains": [],
"help_links": [],
"idx": 0,
"image_src": "/assets/erpnext/images/illustrations/desk-onboard.png",
"is_completed": 0,
"max_count": 3,
"modified": "2019-12-04 19:21:39.995776",
"modified_by": "Administrator",
"name": "Welcome back to ERPNext!",
"owner": "Administrator",
"slide_desc": "<p>Let's continue where you left from!</p>",
"slide_fields": [],
"slide_module": "Setup",
"slide_order": 0,
"slide_title": "Welcome back to ERPNext!",
"slide_type": "Continue"
}

View File

@ -3,20 +3,20 @@
"app": "ERPNext",
"creation": "2019-11-26 17:01:26.671859",
"docstatus": 0,
"doctype": "Setup Wizard Slide",
"doctype": "Onboarding Slide",
"domains": [],
"help_links": [],
"idx": 0,
"image_src": "/assets/erpnext/images/illustrations/onboard.png",
"image_src": "/assets/erpnext/images/illustrations/desk-onboard.png",
"max_count": 0,
"modified": "2019-11-26 17:17:29.813299",
"modified": "2019-12-03 22:49:12.871260",
"modified_by": "Administrator",
"name": "Welcome to ERPNext!",
"owner": "Administrator",
"slide_desc": "Setting up an ERP can be overwhelming. But don't worry, we have got your back!<br>\nLet's setup your company.\nThis wizard will help you onboard to ERPNext in a short time!",
"slide_desc": "Setting up an ERP can be overwhelming. But don't worry, we have got your back!\nLet's setup your company.\nThis wizard will help you onboard to ERPNext in a short time!",
"slide_fields": [],
"slide_module": "Setup",
"slide_order": 10,
"slide_order": 1,
"slide_title": "Welcome to ERPNext!",
"slide_type": "Information"
}

View File

@ -106,7 +106,8 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=No
# expire in 6 hours
response.raise_for_status()
value = response.json()["rates"][to_currency]
cache.setex(key, value, 6 * 60 * 60)
cache.set_value(key, value, expires_in_sec=6 * 60 * 60)
return flt(value)
except:
frappe.log_error(title="Get Exchange Rate")

View File

@ -65,7 +65,7 @@ def update_packing_list_item(doc, packing_item_code, qty, main_item_row, descrip
bin = get_bin_qty(packing_item_code, pi.warehouse)
pi.actual_qty = flt(bin.get("actual_qty"))
pi.projected_qty = flt(bin.get("projected_qty"))
if old_packed_items_map:
if old_packed_items_map and old_packed_items_map.get((packing_item_code, main_item_row.item_code)):
pi.batch_no = old_packed_items_map.get((packing_item_code, main_item_row.item_code))[0].batch_no
pi.serial_no = old_packed_items_map.get((packing_item_code, main_item_row.item_code))[0].serial_no
pi.warehouse = old_packed_items_map.get((packing_item_code, main_item_row.item_code))[0].warehouse

View File

@ -249,6 +249,8 @@ frappe.ui.form.on('Stock Entry', {
}, __("Get items from"));
}
frm.events.show_bom_custom_button(frm);
if (frm.doc.company) {
frm.trigger("toggle_display_account_head");
}
@ -262,6 +264,11 @@ frappe.ui.form.on('Stock Entry', {
frm.trigger("setup_quality_inspection");
},
stock_entry_type: function(frm){
frm.remove_custom_button('Bill of Materials', "Get items from");
frm.events.show_bom_custom_button(frm);
},
purpose: function(frm) {
frm.trigger('validate_purpose_consumption');
frm.fields_dict.items.grid.refresh();
@ -398,6 +405,85 @@ frappe.ui.form.on('Stock Entry', {
}
},
show_bom_custom_button: function(frm){
if (frm.doc.docstatus === 0 &&
['Material Issue', 'Material Receipt', 'Material Transfer', 'Send to Subcontractor'].includes(frm.doc.purpose)) {
frm.add_custom_button(__('Bill of Materials'), function() {
frm.events.get_items_from_bom(frm);
}, __("Get items from"));
}
},
get_items_from_bom: function(frm) {
let filters = function(){
return {filters: { docstatus:1 }};
}
let fields = [
{"fieldname":"bom", "fieldtype":"Link", "label":__("BOM"),
options:"BOM", reqd: 1, get_query: filters()},
{"fieldname":"source_warehouse", "fieldtype":"Link", "label":__("Source Warehouse"),
options:"Warehouse"},
{"fieldname":"target_warehouse", "fieldtype":"Link", "label":__("Target Warehouse"),
options:"Warehouse"},
{"fieldname":"qty", "fieldtype":"Float", "label":__("Quantity"),
reqd: 1, "default": 1},
{"fieldname":"fetch_exploded", "fieldtype":"Check",
"label":__("Fetch exploded BOM (including sub-assemblies)"), "default":1},
{"fieldname":"fetch", "label":__("Get Items from BOM"), "fieldtype":"Button"}
]
// Exclude field 'Target Warehouse' in case of Material Issue
if (frm.doc.purpose == 'Material Issue'){
fields.splice(2,1);
}
// Exclude field 'Source Warehouse' in case of Material Receipt
else if(frm.doc.purpose == 'Material Receipt'){
fields.splice(1,1);
}
let d = new frappe.ui.Dialog({
title: __("Get Items from BOM"),
fields: fields
});
d.get_input("fetch").on("click", function() {
let values = d.get_values();
if(!values) return;
values["company"] = frm.doc.company;
if(!frm.doc.company) frappe.throw(__("Company field is required"));
frappe.call({
method: "erpnext.manufacturing.doctype.bom.bom.get_bom_items",
args: values,
callback: function(r) {
if (!r.message) {
frappe.throw(__("BOM does not contain any stock item"));
} else {
erpnext.utils.remove_empty_first_row(frm, "items");
$.each(r.message, function(i, item) {
let d = frappe.model.add_child(cur_frm.doc, "Stock Entry Detail", "items");
d.item_code = item.item_code;
d.item_name = item.item_name;
d.item_group = item.item_group;
d.s_warehouse = values.source_warehouse;
d.t_warehouse = values.target_warehouse;
d.uom = item.stock_uom;
d.stock_uom = item.stock_uom;
d.conversion_factor = item.conversion_factor ? item.conversion_factor : 1;
d.qty = item.qty;
d.expense_account = item.expense_account;
d.project = item.project;
frm.events.set_basic_rate(frm, d.doctype, d.name);
});
}
d.hide();
refresh_field("items");
}
});
});
d.show();
},
calculate_basic_amount: function(frm, item) {
item.basic_amount = flt(flt(item.transfer_qty) * flt(item.basic_rate),
precision("basic_amount", item));

View File

@ -3,13 +3,13 @@
"app": "ERPNext",
"creation": "2019-11-15 14:41:12.007359",
"docstatus": 0,
"doctype": "Setup Wizard Slide",
"doctype": "Onboarding Slide",
"domains": [],
"help_links": [],
"idx": 0,
"image_src": "/assets/erpnext/images/illustrations/product.png",
"image_src": "/assets/erpnext/images/illustrations/products-onboard.png",
"max_count": 3,
"modified": "2019-11-26 18:26:35.305755",
"modified": "2019-12-03 22:54:07.558632",
"modified_by": "Administrator",
"name": "Add A Few Products You Buy Or Sell",
"owner": "Administrator",
@ -26,15 +26,9 @@
},
{
"align": "",
"fieldtype": "Column Break",
"reqd": 1
},
{
"align": "",
"fieldname": "uom",
"fieldtype": "Link",
"label": "UOM",
"options": "UOM",
"fieldname": "item_price",
"fieldtype": "Currency",
"label": "Item Price",
"reqd": 1
},
{
@ -44,14 +38,14 @@
},
{
"align": "",
"fieldname": "item_price",
"fieldtype": "Currency",
"label": "Item Price",
"fieldname": "uom",
"fieldtype": "Link",
"label": "UOM",
"options": "UOM",
"reqd": 1
}
],
"slide_order": 30,
"slide_title": "Add A Few Products You Buy Or Sell",
"slide_type": "Create",
"submit_method": ""
"slide_type": "Create"
}