merge frappe/develop

This commit is contained in:
Ranjith 2018-05-16 23:24:34 +05:30
commit 31eeff00f7
195 changed files with 4048 additions and 1420 deletions

View File

@ -6,22 +6,22 @@ from __future__ import unicode_literals
import frappe
import unittest
class TestAccountingPeriod(unittest.TestCase):
def test_overlap(self):
ap1 = create_accounting_period({"start_date":"2018-04-01", "end_date":"2018-06-30", "company":"Wind Power LLC"})
ap1.save()
ap2 = create_accounting_period({"start_date":"2018-06-30", "end_date":"2018-07-10", "company":"Wind Power LLC"})
self.assertRaises(frappe.OverlapError, accounting_period_2.save())
def tearDown(self):
pass
def create_accounting_period(**args):
accounting_period = frappe.new_doc("Accounting Period")
accounting_period.start_date = args.start_date or frappe.utils.datetime.date(2018, 4, 1)
accounting_period.end_date = args.end_date or frappe.utils.datetime.date(2018, 6, 30)
accounting_period.company = args.company
accounting_period.period_name = "_Test_Period_Name_1"
return accounting_period
# class TestAccountingPeriod(unittest.TestCase):
# def test_overlap(self):
# ap1 = create_accounting_period({"start_date":"2018-04-01", "end_date":"2018-06-30", "company":"Wind Power LLC"})
# ap1.save()
# ap2 = create_accounting_period({"start_date":"2018-06-30", "end_date":"2018-07-10", "company":"Wind Power LLC"})
# self.assertRaises(frappe.OverlapError, accounting_period_2.save())
#
# def tearDown(self):
# pass
#
#
# def create_accounting_period(**args):
# accounting_period = frappe.new_doc("Accounting Period")
# accounting_period.start_date = args.start_date or frappe.utils.datetime.date(2018, 4, 1)
# accounting_period.end_date = args.end_date or frappe.utils.datetime.date(2018, 6, 30)
# accounting_period.company = args.company
# accounting_period.period_name = "_Test_Period_Name_1"
#
# return accounting_period

View File

@ -181,28 +181,41 @@ def get_amount(args, budget):
amount = 0
if args.get('doctype') == 'Material Request' and budget.for_material_request:
amount = (get_requested_amount(args.item_code)
+ get_ordered_amount(args.item_code) + get_actual_expense(args))
amount = (get_requested_amount(args)
+ get_ordered_amount(args) + get_actual_expense(args))
elif args.get('doctype') == 'Purchase Order' and budget.for_purchase_order:
amount = get_ordered_amount(args.item_code) + get_actual_expense(args)
amount = get_ordered_amount(args) + get_actual_expense(args)
return amount
def get_requested_amount(item_code):
def get_requested_amount(args):
item_code = args.get('item_code')
condition = get_project_condiion(args)
data = frappe.db.sql(""" select ifnull((sum(stock_qty - ordered_qty) * rate), 0) as amount
from `tabMaterial Request Item` where item_code = %s and docstatus = 1
and stock_qty > ordered_qty """, item_code, as_list=1)
and stock_qty > ordered_qty and {0}""".format(condition), item_code, as_list=1)
return data[0][0] if data else 0
def get_ordered_amount(item_code):
def get_ordered_amount(args):
item_code = args.get('item_code')
condition = get_project_condiion(args)
data = frappe.db.sql(""" select ifnull(sum(amount - billed_amt), 0) as amount
from `tabPurchase Order Item` where item_code = %s and docstatus = 1
and amount > billed_amt""", item_code, as_list=1)
and amount > billed_amt and {0}""".format(condition), item_code, as_list=1)
return data[0][0] if data else 0
def get_project_condiion(args):
condition = "1=1"
if args.get('project'):
condition = "project = '%s'" %(args.get('project'))
return condition
def get_actual_expense(args):
condition1 = " and gle.posting_date <= %(month_end_date)s" \
if args.get("month_end_date") else ""

View File

@ -73,7 +73,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -150,7 +150,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -1020,7 +1020,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -42,7 +42,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -17,7 +17,8 @@ frappe.ui.form.on("Journal Entry", {
"from_date": frm.doc.posting_date,
"to_date": frm.doc.posting_date,
"company": frm.doc.company,
group_by_voucher: 0
"finance_book": frm.doc.finance_book,
"group_by_voucher": 0
};
frappe.set_route("query-report", "General Ledger");
}, "fa fa-table");

View File

@ -109,7 +109,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -109,7 +109,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -68,7 +68,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -66,7 +66,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -43,7 +43,6 @@ class PaymentEntry(AccountsController):
def validate(self):
self.setup_party_account_field()
self.set_tax_withholding()
self.set_missing_values()
self.validate_payment_type()
self.validate_party_details()
@ -511,20 +510,6 @@ class PaymentEntry(AccountsController):
def on_recurring(self, reference_doc, auto_repeat_doc):
self.reference_no = reference_doc.name
self.reference_date = nowdate()
def set_tax_withholding(self):
if self.party_type != 'Supplier':
return
self.supplier = self.party
tax_withholding_details = get_patry_tax_withholding_details(self)
for tax_details in tax_withholding_details:
if self.deductions:
if tax_details['tax']['account_head'] not in [deduction.account for deduction in self.deductions]:
self.append('deductions', self.calculate_deductions(tax_details))
else:
self.append('deductions', self.calculate_deductions(tax_details))
def calculate_deductions(self, tax_details):
return {

View File

@ -93,7 +93,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -220,7 +220,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -391,7 +391,7 @@
"icon": "fa fa-resize-horizontal",
"idx": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 1,
"istable": 0,

View File

@ -162,7 +162,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -318,7 +318,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -45,7 +45,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -45,7 +45,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -115,7 +115,6 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
}
this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted==="Yes");
var me = this;
if (doc.docstatus == 1 && !doc.inter_company_invoice_reference) {
frappe.model.with_doc("Supplier", me.frm.doc.supplier, function() {
var supplier = frappe.model.get_doc("Supplier", me.frm.doc.supplier);

View File

@ -4231,7 +4231,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2018-04-19 15:48:29.457594",
"modified": "2018-05-16 15:48:29.457594",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice",

View File

@ -176,7 +176,8 @@ class PurchaseInvoice(BuyingController):
if self.update_stock:
for d in self.get('items'):
if not d.warehouse:
frappe.throw(_("Warehouse required at Row No {0}").format(d.idx))
frappe.throw(_("Warehouse required at Row No {0}, please set default warehouse for the item {1} for the company {2}").
format(d.idx, d.item_code, self.company))
super(PurchaseInvoice, self).validate_warehouse()
@ -352,6 +353,7 @@ class PurchaseInvoice(BuyingController):
self.make_supplier_gl_entry(gl_entries)
self.make_item_gl_entries(gl_entries)
self.get_asset_gl_entry(gl_entries)
self.make_tax_gl_entries(gl_entries)
gl_entries = merge_similar_entries(gl_entries)
@ -434,50 +436,6 @@ class PurchaseInvoice(BuyingController):
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
"credit": flt(item.rm_supp_cost)
}, warehouse_account[self.supplier_warehouse]["account_currency"]))
elif item.is_fixed_asset:
asset_accounts = self.get_company_default(["asset_received_but_not_billed",
"expenses_included_in_asset_valuation", "capital_work_in_progress_account"])
asset_amount = flt(item.net_amount) + flt(item.item_tax_amount/self.conversion_rate)
base_asset_amount = flt(item.base_net_amount + item.item_tax_amount)
if not self.update_stock:
asset_rbnb_currency = get_account_currency(asset_accounts[0])
gl_entries.append(self.get_gl_dict({
"account": asset_accounts[0],
"against": self.supplier,
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
"debit": base_asset_amount,
"debit_in_account_currency": (base_asset_amount
if asset_rbnb_currency == self.company_currency else asset_amount)
}))
else:
cwip_account = get_asset_category_account(item.asset,
'capital_work_in_progress_account') or asset_accounts[2]
cwip_account_currency = get_account_currency(cwip_account)
gl_entries.append(self.get_gl_dict({
"account": cwip_account,
"against": self.supplier,
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
"debit": base_asset_amount,
"debit_in_account_currency": (base_asset_amount
if cwip_account_currency == self.company_currency else asset_amount)
}))
if item.item_tax_amount:
asset_eiiav_currency = get_account_currency(asset_accounts[0])
gl_entries.append(self.get_gl_dict({
"account": asset_accounts[1],
"against": self.supplier,
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
"cost_center": item.cost_center,
"credit": item.item_tax_amount,
"credit_in_account_currency": (item.item_tax_amount
if asset_eiiav_currency == self.company_currency else
item.item_tax_amount / self.conversion_rate)
}))
else:
gl_entries.append(
self.get_gl_dict({
@ -513,6 +471,67 @@ class PurchaseInvoice(BuyingController):
self.negative_expense_to_be_booked += flt(item.item_tax_amount, \
item.precision("item_tax_amount"))
def get_asset_gl_entry(self, gl_entries):
for item in self.get("items"):
if item.is_fixed_asset:
asset_accounts = self.get_company_default(["asset_received_but_not_billed",
"expenses_included_in_asset_valuation", "capital_work_in_progress_account"])
asset_amount = flt(item.net_amount) + flt(item.item_tax_amount/self.conversion_rate)
base_asset_amount = flt(item.base_net_amount + item.item_tax_amount)
if not self.update_stock:
asset_rbnb_currency = get_account_currency(asset_accounts[0])
gl_entries.append(self.get_gl_dict({
"account": asset_accounts[0],
"against": self.supplier,
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
"debit": base_asset_amount,
"debit_in_account_currency": (base_asset_amount
if asset_rbnb_currency == self.company_currency else asset_amount)
}))
if item.item_tax_amount:
asset_eiiav_currency = get_account_currency(asset_accounts[0])
gl_entries.append(self.get_gl_dict({
"account": asset_accounts[1],
"against": self.supplier,
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
"cost_center": item.cost_center,
"credit": item.item_tax_amount,
"credit_in_account_currency": (item.item_tax_amount
if asset_eiiav_currency == self.company_currency else
item.item_tax_amount / self.conversion_rate)
}))
else:
cwip_account = get_asset_category_account(item.asset,
'capital_work_in_progress_account') or asset_accounts[2]
cwip_account_currency = get_account_currency(cwip_account)
gl_entries.append(self.get_gl_dict({
"account": cwip_account,
"against": self.supplier,
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
"debit": base_asset_amount,
"debit_in_account_currency": (base_asset_amount
if cwip_account_currency == self.company_currency else asset_amount)
}))
if item.item_tax_amount and not cint(erpnext.is_perpetual_inventory_enabled(self.company)):
asset_eiiav_currency = get_account_currency(asset_accounts[0])
gl_entries.append(self.get_gl_dict({
"account": asset_accounts[1],
"against": self.supplier,
"remarks": self.get("remarks") or _("Accounting Entry for Asset"),
"cost_center": item.cost_center,
"credit": item.item_tax_amount,
"credit_in_account_currency": (item.item_tax_amount
if asset_eiiav_currency == self.company_currency else
item.item_tax_amount / self.conversion_rate)
}))
return gl_entries
def make_tax_gl_entries(self, gl_entries):
# tax table gl entries
valuation_tax = {}
@ -751,10 +770,6 @@ class PurchaseInvoice(BuyingController):
self.db_set('release_date', None)
def set_tax_withholding(self):
"""
1. Get TDS Configurations against Supplier
"""
tax_withholding_details = get_patry_tax_withholding_details(self)
for tax_details in tax_withholding_details:
if flt(self.get("rounded_total") or self.grand_total) >= flt(tax_details['threshold']):

View File

@ -215,7 +215,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -2027,6 +2027,39 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "is_fixed_asset",
"fieldname": "asset_location",
"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": "Asset Location",
"length": 0,
"no_copy": 0,
"options": "Location",
"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_on_submit": 0,
@ -2258,7 +2291,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2018-04-23 14:07:33.576495",
"modified": "2018-05-16 17:50:21.957780",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",

View File

@ -217,7 +217,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -71,7 +71,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -39,7 +39,7 @@ def get_pos_data():
update_multi_mode_option(doc, pos_profile)
default_print_format = pos_profile.get('print_format') or "Point of Sale"
print_template = frappe.db.get_value('Print Format', default_print_format, 'html')
items_list = get_items_list(pos_profile)
items_list = get_items_list(pos_profile, doc.company)
customers = get_customers_list(pos_profile)
return {
@ -151,25 +151,26 @@ def update_tax_table(doc):
doc.append('taxes', tax)
def get_items_list(pos_profile):
cond = "1=1"
item_groups = []
def get_items_list(pos_profile, company):
cond = ""
args_list = [company]
if pos_profile.get('item_groups'):
# Get items based on the item groups defined in the POS profile
for d in pos_profile.get('item_groups'):
item_groups.extend([d.name for d in get_child_nodes('Item Group', d.item_group)])
cond = "item_group in (%s)" % (', '.join(['%s'] * len(item_groups)))
args_list.extend([d.name for d in get_child_nodes('Item Group', d.item_group)])
cond = "and i.item_group in (%s)" % (', '.join(['%s'] * len(args_list)))
return frappe.db.sql("""
select
name, item_code, item_name, description, item_group, expense_account, has_batch_no,
has_serial_no, expense_account, selling_cost_center, stock_uom, image,
default_warehouse, is_stock_item, brand
i.name, i.item_code, i.item_name, i.description, i.item_group, i.has_batch_no,
i.has_serial_no, i.is_stock_item, i.brand, i.stock_uom, i.image,
id.expense_account, id.selling_cost_center, id.default_warehouse
from
tabItem
`tabItem` i, `tabItem Default` id
where
disabled = 0 and has_variants = 0 and is_sales_item = 1 and {cond}
""".format(cond=cond), tuple(item_groups), as_dict=1)
id.parent = i.name and i.disabled = 0 and i.has_variants = 0 and i.is_sales_item = 1
and id.company = %s {cond}
""".format(cond=cond), tuple(args_list), as_dict=1)
def get_item_groups(pos_profile):
@ -531,9 +532,12 @@ def validate_item(doc):
item_doc.item_code = item.get('item_code')
item_doc.item_name = item.get('item_name')
item_doc.description = item.get('description')
item_doc.default_warehouse = item.get('warehouse')
item_doc.stock_uom = item.get('stock_uom')
item_doc.item_group = item.get('item_group')
item_doc.append('item_defaults', {
"company": doc.get("company"),
"default_warehouse": item.get('warehouse')
})
item_doc.save(ignore_permissions=True)
frappe.db.commit()

View File

@ -1028,7 +1028,7 @@ def update_linked_invoice(doctype, name, inter_company_invoice_reference):
def unlink_inter_company_invoice(doctype, name, inter_company_invoice_reference):
ref_doc = "Purchase Invoice" if doctype == "Sales Invoice" else "Sales Invoice"
if inter_company_invoice_reference:
frappe.db.set_value(doctype, name,\
frappe.db.set_value(doctype, name,\
"inter_company_invoice_reference", "")
frappe.db.set_value(ref_doc, inter_company_invoice_reference,\
"inter_company_invoice_reference", "")

View File

@ -215,7 +215,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -134,7 +134,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -216,7 +216,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -89,7 +89,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -42,7 +42,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -13,68 +13,6 @@
"editable_grid": 1,
"engine": "InnoDB",
"fields": [
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "is_default",
"fieldtype": "Check",
"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": "Is Default",
"length": 0,
"no_copy": 0,
"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_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "enabled",
"fieldtype": "Check",
"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": "Enabled",
"length": 0,
"no_copy": 0,
"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_on_submit": 0,
@ -198,37 +136,6 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "book_on_advance",
"fieldtype": "Check",
"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": "Book on Advance",
"length": 0,
"no_copy": 0,
"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_on_submit": 0,
@ -333,7 +240,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-05-11 14:25:07.474461",
"modified": "2018-05-16 13:57:52.489773",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Tax Withholding Category",

View File

@ -487,7 +487,7 @@ def get_patry_tax_withholding_details(ref_doc):
if tax.valid_till and date_diff(tax.valid_till, ref_doc.posting_date) > 0:
tax_mapper.update({
"rate": tax.applicable_percentage
"rate": tax.applicable_percent
})
prepare_tax_withholding_details(tax_mapper, tax_withholding_details)

View File

@ -15,6 +15,10 @@ from erpnext.accounts.report.cash_flow.cash_flow import (get_cash_flow_accounts,
def execute(filters=None):
columns, data, message, chart = [], [], [], []
if not filters.get('company'):
return columns, data, message, chart
fiscal_year = get_fiscal_year_data(filters.get('from_fiscal_year'), filters.get('to_fiscal_year'))
companies_column, companies = get_companies(filters)
columns = get_columns(companies_column)

View File

@ -84,9 +84,7 @@ frappe.query_reports["General Ledger"] = {
var party_type = frappe.query_report_filters_by_name.party_type.get_value();
var parties = frappe.query_report_filters_by_name.party.get_value();
if(!party_type) {
frappe.throw(__("Please select Party Type first"));
}
if(!party_type) return;
const values = parties.split(/\s*,\s*/).filter(d => d);
const txt = parties.match(/[^,\s*]*$/)[0] || '';

View File

@ -681,23 +681,29 @@ def get_companies():
def get_children(doctype, parent, company, is_root=False):
from erpnext.accounts.report.financial_statements import sort_accounts
parent_fieldname = 'parent_' + doctype.lower().replace(' ', '_')
fields = [
'name as value',
'is_group as expandable'
]
filters = [['docstatus', '<', 2]]
fieldname = frappe.db.escape(doctype.lower().replace(' ','_'))
doctype = frappe.db.escape(doctype)
# root
if is_root:
fields += ['root_type', 'report_type', 'account_currency'] if doctype == 'Account' else []
filters.append([parent_fieldname, '=', ''])
filters.append(['company', '=', company])
fields = ", root_type, report_type, account_currency" if doctype=="Account" else ""
acc = frappe.db.sql(""" select
name as value, is_group as expandable {fields}
from `tab{doctype}`
where ifnull(`parent_{fieldname}`,'') = ''
and `company` = %s and docstatus<2
order by name""".format(fields=fields, fieldname = fieldname, doctype=doctype),
company, as_dict=1)
else:
fields += ['account_currency'] if doctype == 'Account' else []
fields += [parent_fieldname + ' as parent']
acc = frappe.get_list(doctype, fields=fields, filters=filters)
# other
fields = ", account_currency" if doctype=="Account" else ""
acc = frappe.db.sql("""select
name as value, is_group as expandable, parent_{fieldname} as parent {fields}
from `tab{doctype}`
where ifnull(`parent_{fieldname}`,'') = %s
and docstatus<2
order by name""".format(fields=fields, fieldname=fieldname, doctype=doctype),
parent, as_dict=1)
if doctype == 'Account':
sort_accounts(acc, is_root, key="value")

View File

@ -169,10 +169,11 @@ def get_children(doctype, parent, is_root=False):
if is_root:
parent = ''
land_units = frappe.get_list(doctype,
fields = ['name as value', 'is_group as expandable'],
filters= [['parent_land_unit', '=', parent]],
order_by='name')
land_units = frappe.db.sql("""select name as value,
is_group as expandable
from `tabLand Unit`
where ifnull(`parent_land_unit`,'') = %s
order by name""", (parent), as_dict=1)
# return nodes
return land_units

View File

@ -157,6 +157,13 @@ frappe.ui.form.on('Asset', {
}
},
available_for_use_date: function(frm) {
$.each(frm.doc.finance_books || [], function(i, d) {
if(!d.depreciation_start_date) d.depreciation_start_date = frm.doc.available_for_use_date;
});
refresh_field("finance_books");
},
is_existing_asset: function(frm) {
// frm.toggle_reqd("next_depreciation_date", (!frm.doc.is_existing_asset && frm.doc.calculate_depreciation));
},

View File

@ -42,6 +42,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -57,7 +58,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Asset Name",
"length": 0,
@ -72,6 +73,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -103,6 +105,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -134,6 +137,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -149,7 +153,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 1,
"in_list_view": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Asset Category",
"length": 0,
@ -165,6 +169,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -196,6 +201,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -228,6 +234,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -260,6 +267,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -292,6 +300,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -322,6 +331,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -351,6 +361,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -382,6 +393,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -397,7 +409,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Location",
"length": 0,
@ -413,6 +425,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -444,6 +457,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -475,6 +489,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -505,6 +520,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -535,6 +551,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -566,6 +583,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -595,6 +613,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -626,6 +645,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -656,6 +676,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -685,6 +706,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -715,6 +737,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -745,6 +768,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -777,6 +801,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -808,6 +833,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -839,6 +865,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -870,6 +897,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -899,6 +927,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -932,6 +961,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -963,6 +993,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -993,6 +1024,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1022,6 +1054,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1052,6 +1085,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1083,6 +1117,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1114,6 +1149,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1145,6 +1181,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1175,6 +1212,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1205,6 +1243,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1235,6 +1274,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1265,6 +1305,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1294,6 +1335,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1324,6 +1366,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1354,6 +1397,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1384,6 +1428,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1414,6 +1459,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1445,6 +1491,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1475,6 +1522,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1507,6 +1555,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1538,6 +1587,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1567,6 +1617,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1598,6 +1649,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1628,6 +1680,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1659,6 +1712,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -1689,6 +1743,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@ -1703,7 +1758,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-05-11 10:41:45.972686",
"modified": "2018-05-16 08:45:31.659647",
"modified_by": "Administrator",
"module": "Assets",
"name": "Asset",
@ -1712,7 +1767,6 @@
"permissions": [
{
"amend": 1,
"apply_user_permissions": 0,
"cancel": 1,
"create": 1,
"delete": 1,
@ -1732,7 +1786,6 @@
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 1,
"create": 1,
"delete": 1,
@ -1757,6 +1810,7 @@
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "asset_name",
"track_changes": 0,
"track_seen": 0
}

View File

@ -28,6 +28,7 @@ class Asset(AccountsController):
self.validate_expected_value_after_useful_life()
def on_submit(self):
self.validate_in_use_date()
self.set_status()
self.update_stock_movement()
@ -48,6 +49,10 @@ class Asset(AccountsController):
elif item.is_stock_item:
frappe.throw(_("Item {0} must be a non-stock item").format(self.item_code))
def validate_in_use_date(self):
if not self.available_for_use_date:
frappe.throw(_("Available for use date is required"))
def set_missing_values(self):
if not self.asset_category:
self.asset_category = frappe.db.get_value("Item", self.item_code, "asset_category")
@ -157,6 +162,9 @@ class Asset(AccountsController):
frappe.throw(_("Row {0}: Expected Value After Useful Life must be less than Gross Purchase Amount")
.format(row.idx))
if not row.depreciation_start_date:
frappe.throw(_("Row {0}: Depreciation Start Date is required").format(row.idx))
if not self.is_existing_asset:
self.opening_accumulated_depreciation = 0
self.number_of_depreciations_booked = 0

View File

@ -14,16 +14,13 @@ class AssetMovement(Document):
self.validate_warehouses()
def validate_asset(self):
status, company, serial_no = frappe.db.get_value("Asset", self.asset, ["status", "company", "serial_no"])
status, company = frappe.db.get_value("Asset", self.asset, ["status", "company"])
if self.purpose == 'Transfer' and status in ("Draft", "Scrapped", "Sold"):
frappe.throw(_("{0} asset cannot be transferred").format(status))
if company != self.company:
frappe.throw(_("Asset {0} does not belong to company {1}").format(self.asset, self.company))
if serial_no and not self.serial_no:
self.serial_no = serial_no
if self.serial_no and len(get_serial_nos(self.serial_no)) != self.quantity:
frappe.throw(_("Number of serial nos and quantity must be the same"))
@ -58,7 +55,5 @@ class AssetMovement(Document):
frappe.db.set_value("Asset", self.asset, "location", location)
if self.serial_no:
serial_nos = get_serial_nos(self.serial_no)
frappe.db.sql(""" update `tabSerial No` set location = %s where name in (%s)"""
%('%s', ','.join(['%s'] * len(serial_nos))), (location, tuple(serial_nos)))
for d in get_serial_nos(self.serial_no):
frappe.db.set_value('Serial No', d, 'location', location)

View File

@ -14,6 +14,7 @@ from frappe.desk.notifications import clear_doctype_notifications
from erpnext.buying.utils import validate_for_items, check_for_closed_status
from erpnext.stock.utils import get_bin
from six import string_types
from erpnext.stock.doctype.item.item import get_item_defaults
form_grid_templates = {
"items": "templates/form_grid/item_grid.html"
@ -374,9 +375,9 @@ def make_purchase_invoice(source_name, target_doc=None):
target.base_amount = target.amount * flt(source_parent.conversion_rate)
target.qty = target.amount / flt(obj.rate) if (flt(obj.rate) and flt(obj.billed_amt)) else flt(obj.qty)
item = frappe.db.get_value("Item", target.item_code, ["item_group", "buying_cost_center"], as_dict=1)
item = get_item_defaults(target.item_code, source_parent.company)
target.cost_center = frappe.db.get_value("Project", obj.project, "cost_center") \
or item.buying_cost_center \
or item.get("buying_cost_center") \
or frappe.db.get_value("Item Group", item.item_group, "default_cost_center")
doc = get_mapped_doc("Purchase Order", source_name, {

View File

@ -715,7 +715,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -1322,7 +1322,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-05-11 15:15:19.912308",
"modified": "2018-05-16 15:15:19.912308",
"modified_by": "Administrator",
"module": "Buying",
"name": "Supplier",

View File

@ -142,7 +142,7 @@ def get_data():
]
},
{
"label": _("Expense Claim"),
"label": _("Travel and Expense Claim"),
"items": [
{
"type": "doctype",
@ -156,6 +156,10 @@ def get_data():
"type": "doctype",
"name": "Expense Claim Type",
},
{
"type": "doctype",
"name": "Travel Request",
},
]
},
{

View File

@ -639,10 +639,10 @@ class AccountsController(TransactionBase):
frappe.throw(_("Row #{0}: Asset {1} must be submitted").format(d.idx, d.asset))
elif self.doctype == "Purchase Invoice":
if asset.status != "Submitted":
frappe.throw(_("Row #{0}: Asset {1} is already {2}")
.format(d.idx, d.asset, asset.status))
elif getdate(asset.purchase_date) != getdate(self.posting_date):
# if asset.status != "Submitted":
# frappe.throw(_("Row #{0}: Asset {1} is already {2}")
# .format(d.idx, d.asset, asset.status))
if getdate(asset.purchase_date) != getdate(self.posting_date):
frappe.throw(_("Row #{0}: Posting Date must be same as purchase date {1} of asset {2}").format(d.idx, asset.purchase_date, d.asset))
elif asset.is_existing_asset:
frappe.throw(_("Row #{0}: Purchase Invoice cannot be made against an existing asset {1}").format(d.idx, d.asset))

View File

@ -216,8 +216,9 @@ class BuyingController(StockController):
raw_materials_cost = 0
items = list(set([d.item_code for d in bom_items]))
item_wh = frappe._dict(frappe.db.sql("""select item_code, default_warehouse
from `tabItem` where name in ({0})""".format(", ".join(["%s"] * len(items))), items))
item_wh = frappe._dict(frappe.db.sql("""select i.item_code, id.default_warehouse
from `tabItem` i, `tabItem Default` id where id.company=%s and i.name in ({0})"""
.format(", ".join(["%s"] * len(items))), [self.company] + items))
for bom_item in bom_items:
if self.doctype == "Purchase Order":
@ -473,6 +474,7 @@ class BuyingController(StockController):
'item_code': data.item_code,
'item_group': data.item_group,
'posting_date': data.schedule_date,
'project': data.project,
'doctype': self.doctype
}, self.company)

View File

@ -340,10 +340,21 @@ class SellingController(StockController):
def check_active_sales_items(obj):
for d in obj.get("items"):
if d.item_code:
item = frappe.db.sql("""select docstatus,
income_account from tabItem where name = %s""",
d.item_code, as_dict=True)[0]
item = frappe.db.sql("""select i.docstatus, id.income_account
from `tabItem` i, `tabItem Default` id
where i.name=%s and id.parent=i.name and id.company=%s""",
(d.item_code, obj.company), as_dict=True)
if getattr(d, "income_account", None) and not item.income_account:
frappe.db.set_value("Item", d.item_code, "income_account",
d.income_account)
if getattr(d, "income_account", None):
doc = frappe.get_doc("Item", d.item_code)
if item and not item[0].income_account:
for default in doc.item_defaults:
if default.company == obj.company:
default.income_account = d.income_account
break
elif not item:
doc.append("item_defaults", {
"company": obj.company,
"income_account": d.income_account
})
doc.save()

View File

@ -33,6 +33,10 @@ class StockController(AccountsController):
items, warehouses = self.get_items_and_warehouses()
update_gl_entries_after(self.posting_date, self.posting_time, warehouses, items,
warehouse_account)
elif self.doctype in ['Purchase Receipt', 'Purchase Invoice']:
gl_entries = []
gl_entries = self.get_asset_gl_entry(gl_entries)
make_gl_entries(gl_entries, from_repost=from_repost)
def get_gl_entries(self, warehouse_account=None, default_expense_account=None,
default_cost_center=None):

View File

@ -407,7 +407,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -1,7 +1,9 @@
[
{
"default_supplier": "Asiatic Solutions",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "For Upper Bearing",
"image": "/assets/erpnext_demo/images/disc.png",
"item_code": "Disc Collars",
@ -10,7 +12,9 @@
},
{
"default_supplier": "Nan Duskin",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "CAST IRON, MCMASTER PART NO. 3710T13",
"image": "/assets/erpnext_demo/images/bearing.jpg",
"item_code": "Bearing Block",
@ -19,7 +23,9 @@
},
{
"default_supplier": null,
"default_warehouse": "Finished Goods",
"item_defaults": [{
"default_warehouse": "Finished Goods"
}],
"description": "Wind Mill C Series for Commercial Use 18ft",
"image": "/assets/erpnext_demo/images/wind-turbine-2.png",
"item_code": "Wind MIll C Series",
@ -28,7 +34,9 @@
},
{
"default_supplier": null,
"default_warehouse": "Finished Goods",
"item_defaults": [{
"default_warehouse": "Finished Goods"
}],
"description": "Wind Mill A Series for Home Use 9ft",
"image": "/assets/erpnext_demo/images/wind-turbine.png",
"item_code": "Wind Mill A Series",
@ -37,7 +45,9 @@
},
{
"default_supplier": null,
"default_warehouse": "Finished Goods",
"item_defaults": [{
"default_warehouse": "Finished Goods"
}],
"description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->",
"image": "/assets/erpnext_demo/images/wind-turbine-1.jpg",
"item_code": "Wind Turbine",
@ -51,7 +61,9 @@
},
{
"default_supplier": "HomeBase",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "1.5 in. Diameter x 36 in. Mild Steel Tubing",
"image": null,
"item_code": "Bearing Pipe",
@ -60,7 +72,9 @@
},
{
"default_supplier": "New World Realty",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet",
"image": null,
"item_code": "Wing Sheet",
@ -69,7 +83,9 @@
},
{
"default_supplier": "Eagle Hardware",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate",
"image": null,
"item_code": "Upper Bearing Plate",
@ -78,7 +94,9 @@
},
{
"default_supplier": "Asiatic Solutions",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "Bearing Assembly",
"image": null,
"item_code": "Bearing Assembly",
@ -87,7 +105,9 @@
},
{
"default_supplier": "HomeBase",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "3/4 in. x 2 ft. x 4 ft. Pine Plywood",
"image": null,
"item_code": "Base Plate",
@ -97,7 +117,9 @@
},
{
"default_supplier": "Scott Ties",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "N/A",
"image": null,
"item_code": "Stand",
@ -106,7 +128,9 @@
},
{
"default_supplier": "Eagle Hardware",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar",
"image": null,
"item_code": "Bearing Collar",
@ -115,7 +139,9 @@
},
{
"default_supplier": "Eagle Hardware",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "1/4 in. x 6 in. x 6 in. Mild Steel Plate",
"image": null,
"item_code": "Base Bearing Plate",
@ -124,7 +150,9 @@
},
{
"default_supplier": "HomeBase",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing",
"image": null,
"item_code": "External Disc",
@ -133,7 +161,9 @@
},
{
"default_supplier": "Eagle Hardware",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "1.25 in. Diameter x 6 ft. Mild Steel Tubing",
"image": null,
"item_code": "Shaft",
@ -142,7 +172,9 @@
},
{
"default_supplier": "Ks Merchandise",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "1/2 in. x 2 ft. x 4 ft. Pine Plywood",
"image": null,
"item_code": "Blade Rib",
@ -151,7 +183,9 @@
},
{
"default_supplier": "HomeBase",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "For Bearing Collar",
"image": null,
"item_code": "Internal Disc",
@ -160,7 +194,9 @@
},
{
"default_supplier": null,
"default_warehouse": "Finished Goods",
"item_defaults": [{
"default_warehouse": "Finished Goods"
}],
"description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->\n<p>Size: Small</p>",
"image": "/assets/erpnext_demo/images/wind-turbine-1.jpg",
"item_code": "Wind Turbine-S",
@ -177,7 +213,9 @@
},
{
"default_supplier": null,
"default_warehouse": "Finished Goods",
"item_defaults": [{
"default_warehouse": "Finished Goods"
}],
"description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->\n<p>Size: Medium</p>",
"image": "/assets/erpnext_demo/images/wind-turbine-1.jpg",
"item_code": "Wind Turbine-M",
@ -194,7 +232,9 @@
},
{
"default_supplier": null,
"default_warehouse": "Finished Goods",
"item_defaults": [{
"default_warehouse": "Finished Goods"
}],
"description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->\n<p>Size: Large</p>",
"image": "/assets/erpnext_demo/images/wind-turbine-1.jpg",
"item_code": "Wind Turbine-L",
@ -218,7 +258,9 @@
},
{
"default_supplier": "HomeBase",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "3/4 in. x 2 ft. x 4 ft. Pine Plywood",
"image": null,
"item_code": "Base Plate Un Painted",
@ -284,7 +326,9 @@
"has_batch_no": 1,
"create_new_batch": 1,
"valuation_rate": 200,
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores"
}],
"description": "Corrugated Box",
"item_code": "Corrugated Box",
"item_name": "Corrugated Box",

View File

@ -1,63 +1,90 @@
[
{
"default_supplier": "Asiatic Solutions",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores",
"company": "Whitmore College"
}],
"item_code": "Books",
"item_group": "Raw Material",
"item_name": "Books"
},
{
"default_supplier": "HomeBase",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores",
"company": "Whitmore College"
}],
"item_code": "Pencil",
"item_group": "Raw Material",
"item_name": "Pencil"
},
{
"default_supplier": "New World Realty",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores",
"company": "Whitmore College"
}],
"item_code": "Tables",
"item_group": "Raw Material",
"item_name": "Tables"
},
{
"default_supplier": "Eagle Hardware",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores",
"company": "Whitmore College"
}],
"item_code": "Chair",
"item_group": "Raw Material",
"item_name": "Chair"
},
{
"default_supplier": "Asiatic Solutions",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores",
"company": "Whitmore College"
}],
"item_code": "Black Board",
"item_group": "Sub Assemblies",
"item_name": "Black Board"
},
{
"default_supplier": "HomeBase",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores",
"company": "Whitmore College"
}],
"item_code": "Chalk",
"item_group": "Raw Material",
"item_name": "Chalk"
},
{
"default_supplier": "HomeBase",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores",
"company": "Whitmore College"
}],
"item_code": "Notepad",
"item_group": "Raw Material",
"item_name": "Notepad"
},
{
"default_supplier": "Ks Merchandise",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores",
"company": "Whitmore College"
}],
"item_code": "Uniform",
"item_group": "Raw Material",
"item_name": "Uniform"
},
{
"is_stock_item": 0,
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores",
"company": "Whitmore College"
}],
"description": "Computer",
"item_code": "Computer",
"item_name": "Computer",
@ -65,7 +92,10 @@
},
{
"is_stock_item": 0,
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores",
"company": "Whitmore College"
}],
"description": "Mobile",
"item_code": "Mobile",
"item_name": "Mobile",
@ -73,7 +103,10 @@
},
{
"is_stock_item": 0,
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores",
"company": "Whitmore College"
}],
"description": "ERP",
"item_code": "ERP",
"item_name": "ERP",
@ -81,15 +114,20 @@
},
{
"is_stock_item": 0,
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores",
"company": "Whitmore College"
}],
"description": "Autocad",
"item_code": "Autocad",
"item_name": "Autocad",
"item_group": "All Item Groups"
},
{
"default_warehouse": "Stores",
"default_warehouse": "Stores",
"item_defaults": [{
"default_warehouse": "Stores",
"company": "Whitmore College"
}],
"item_code": "Service",
"item_group": "Services",
"item_name": "Service",

View File

@ -36,7 +36,8 @@ def setup_item():
item = frappe.new_doc('Item')
item.update(i)
item.min_order_qty = random.randint(10, 30)
item.default_warehouse = frappe.get_all('Warehouse', filters={'warehouse_name': item.default_warehouse}, limit=1)[0].name
item.item_defaults[0].default_warehouse = frappe.get_all('Warehouse',
filters={'warehouse_name': item.item_defaults[0].default_warehouse}, limit=1)[0].name
item.insert()
def make_student_applicants():

View File

@ -4,6 +4,7 @@ import random, json
import frappe
from frappe.utils import nowdate, add_days
from erpnext.demo.setup.setup_data import import_json
from erpnext.demo.domains import data
from six import iteritems
@ -65,10 +66,11 @@ def setup_item():
for i in items:
item = frappe.new_doc('Item')
item.update(i)
if item.default_warehouse:
warehouse = frappe.get_all('Warehouse', filters={'warehouse_name': item.default_warehouse}, limit=1)
if item.item_defaults[0].default_warehouse:
item.item_defaults[0].company = data.get("Manufacturing").get('company_name')
warehouse = frappe.get_all('Warehouse', filters={'warehouse_name': item.item_defaults[0].default_warehouse}, limit=1)
if warehouse:
item.default_warehouse = warehouse[0].name
item.item_defaults[0].default_warehouse = warehouse[0].name
item.insert()
def setup_product_bundle():

View File

@ -202,7 +202,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -108,7 +108,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -73,7 +73,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -44,7 +44,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -6,36 +6,36 @@ from __future__ import unicode_literals
import frappe
import unittest
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 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)
#

View File

@ -1,4 +1,4 @@
[
{"doctype":"Department", "department_name":"_Test Department"},
{"doctype":"Department", "department_name":"_Test Department 1"}
{"doctype":"Department", "department_name":"_Test Department", "company": "_Test Company"},
{"doctype":"Department", "department_name":"_Test Department 1", "company": "_Test Company"}
]

View File

@ -77,7 +77,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -318,26 +318,26 @@ def get_employee_emails(employee_list):
@frappe.whitelist()
def get_children(doctype, parent=None, company=None, is_root=False, is_tree=False):
filters = [['company', '=', company]]
fields = ['name as value', 'employee_name as title']
condition = ''
if is_root:
parent = ''
parent = ""
if parent and company and parent!=company:
filters.append(['reports_to', '=', parent])
condition = ' and reports_to = "{0}"'.format(frappe.db.escape(parent))
else:
filters.append(['reports_to', '=', ''])
condition = ' and ifnull(reports_to, "")=""'
employees = frappe.get_list(doctype, fields=fields,
filters=filters, order_by='name')
employee = frappe.db.sql("""
select
name as value, employee_name as title,
exists(select name from `tabEmployee` where reports_to=emp.name) as expandable
from
`tabEmployee` emp
where company='{company}' {condition} order by name"""
.format(company=company, condition=condition), as_dict=1)
for employee in employees:
is_expandable = frappe.get_all(doctype, filters=[
['reports_to', '=', employee.get('value')]
])
employee.expandable = 1 if is_expandable else 0
return employees
# return employee
return employee
def on_doctype_update():

View File

@ -3,7 +3,7 @@
"company": "_Test Company",
"date_of_birth": "1980-01-01",
"date_of_joining": "2010-01-01",
"department": "_Test Department",
"department": "_Test Department - _TC",
"doctype": "Employee",
"employee_name": "_Test Employee",
"gender": "Female",
@ -15,7 +15,7 @@
"company": "_Test Company",
"date_of_birth": "1980-01-01",
"date_of_joining": "2010-01-01",
"department": "_Test Department 1",
"department": "_Test Department 1 - _TC",
"doctype": "Employee",
"employee_name": "_Test Employee 1",
"gender": "Male",
@ -27,7 +27,7 @@
"company": "_Test Company",
"date_of_birth": "1980-01-01",
"date_of_joining": "2010-01-01",
"department": "_Test Department 1",
"department": "_Test Department 1 - _TC",
"doctype": "Employee",
"employee_name": "_Test Employee 2",
"gender": "Male",

View File

@ -84,15 +84,17 @@ frappe.ui.form.on('Employee Advance', {
},
employee: function (frm) {
return frappe.call({
method: "erpnext.hr.doctype.employee_advance.employee_advance.get_due_advance_amount",
args: {
"employee": frm.doc.employee,
"posting_date": frm.doc.posting_date
},
callback: function(r) {
frm.set_value("due_advance_amount",r.message);
}
});
if (frm.doc.employee) {
return frappe.call({
method: "erpnext.hr.doctype.employee_advance.employee_advance.get_due_advance_amount",
args: {
"employee": frm.doc.employee,
"posting_date": frm.doc.posting_date
},
callback: function(r) {
frm.set_value("due_advance_amount",r.message);
}
});
}
}
});

View File

@ -235,7 +235,7 @@
"hide_toolbar": 1,
"idx": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 1,
"istable": 0,

View File

@ -174,7 +174,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -172,7 +172,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -148,7 +148,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -19,38 +19,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "employee_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Employee Name",
"length": 0,
"no_copy": 0,
"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_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "employee",
"fieldname": "job_applicant",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
@ -59,18 +28,18 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Employee",
"label": "Job Applicant",
"length": 0,
"no_copy": 0,
"options": "Employee",
"options": "Job Applicant",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
@ -114,19 +83,19 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "job_applicant",
"fieldtype": "Link",
"fieldname": "employee_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Job Applicant",
"label": "Employee Name",
"length": 0,
"no_copy": 0,
"options": "Job Applicant",
"options": "job_applicant.applicant_name",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -140,6 +109,38 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "employee",
"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": "Employee",
"length": 0,
"no_copy": 0,
"options": "Employee",
"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_on_submit": 0,
@ -530,7 +531,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-05-10 06:34:21.103617",
"modified": "2018-05-16 05:01:09.897011",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee Onboarding",
@ -557,7 +558,7 @@
"write": 1
}
],
"quick_entry": 1,
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,

View File

@ -5,50 +5,50 @@ from __future__ import unicode_literals
import frappe
import unittest
from erpnext.hr.doctype.employee_tax_exemption_declaration.test_employee_tax_exemption_declaration import create_exemption_category, create_payroll_period
class TestEmployeeTaxExemptionProofSubmission(unittest.TestCase):
def setup(self):
make_employee("employee@proofsubmission.com")
create_payroll_period()
create_exemption_category()
frappe.db.sql("""delete from `tabEmployee Tax Exemption Proof Submission`""")
def test_exemption_amount_lesser_than_category_max(self):
declaration = frappe.get_doc({
"doctype": "Employee Tax Exemption Proof Submission",
"employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
"payroll_period": "Test Payroll Period",
"tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
type_of_proof = "Test Proof",
exemption_category = "_Test Category",
amount = 150000)]
})
self.assertRaises(frappe.ValidationError, declaration.save)
declaration = frappe.get_doc({
"doctype": "Employee Tax Exemption Proof Submission",
"payroll_period": "Test Payroll Period",
"employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
"tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
type_of_proof = "Test Proof",
exemption_category = "_Test Category",
amount = 100000)]
})
self.assertTrue(declaration.save)
self.assertTrue(declaration.submit)
def test_duplicate_category_in_proof_submission(self):
declaration = frappe.get_doc({
"doctype": "Employee Tax Exemption Proof Submission",
"employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
"payroll_period": "Test Payroll Period",
"tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
exemption_category = "_Test Category",
type_of_proof = "Test Proof",
amount = 100000),
dict(exemption_sub_category = "_Test Sub Category",
exemption_category = "_Test Category",
amount = 50000),
]
})
self.assertRaises(frappe.ValidationError, declaration.save)
# from erpnext.hr.doctype.employee_tax_exemption_declaration.test_employee_tax_exemption_declaration import create_exemption_category, create_payroll_period
#
# class TestEmployeeTaxExemptionProofSubmission(unittest.TestCase):
# def setup(self):
# make_employee("employee@proofsubmission.com")
# create_payroll_period()
# create_exemption_category()
# frappe.db.sql("""delete from `tabEmployee Tax Exemption Proof Submission`""")
#
# def test_exemption_amount_lesser_than_category_max(self):
# declaration = frappe.get_doc({
# "doctype": "Employee Tax Exemption Proof Submission",
# "employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
# "payroll_period": "Test Payroll Period",
# "tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
# type_of_proof = "Test Proof",
# exemption_category = "_Test Category",
# amount = 150000)]
# })
# self.assertRaises(frappe.ValidationError, declaration.save)
# declaration = frappe.get_doc({
# "doctype": "Employee Tax Exemption Proof Submission",
# "payroll_period": "Test Payroll Period",
# "employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
# "tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
# type_of_proof = "Test Proof",
# exemption_category = "_Test Category",
# amount = 100000)]
# })
# self.assertTrue(declaration.save)
# self.assertTrue(declaration.submit)
#
# def test_duplicate_category_in_proof_submission(self):
# declaration = frappe.get_doc({
# "doctype": "Employee Tax Exemption Proof Submission",
# "employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
# "payroll_period": "Test Payroll Period",
# "tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
# exemption_category = "_Test Category",
# type_of_proof = "Test Proof",
# amount = 100000),
# dict(exemption_sub_category = "_Test Sub Category",
# exemption_category = "_Test Category",
# amount = 50000),
# ]
# })
# self.assertRaises(frappe.ValidationError, declaration.save)

View File

@ -48,7 +48,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -68,7 +68,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -101,7 +101,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -68,7 +68,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -0,0 +1,8 @@
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on('Identification Document Type', {
refresh: function(frm) {
}
});

View File

@ -0,0 +1,93 @@
{
"allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"autoname": "field:identification_document_type",
"beta": 0,
"creation": "2018-05-15 07:13:28.620570",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"editable_grid": 1,
"engine": "InnoDB",
"fields": [
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "identification_document_type",
"fieldtype": "Data",
"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": "Identification Document Type",
"length": 0,
"no_copy": 0,
"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
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-05-16 04:34:00.448680",
"modified_by": "Administrator",
"module": "HR",
"name": "Identification Document Type",
"name_case": "",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
}
],
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 0,
"track_seen": 0
}

View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class IdentificationDocumentType(Document):
pass

View File

@ -0,0 +1,23 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Identification Document Type", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially([
// insert a new Identification Document Type
() => frappe.tests.make('Identification Document Type', [
// values to be set
{key: 'value'}
]),
() => {
assert.equal(cur_frm.doc.key, 'value');
},
() => done()
]);
});

View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import frappe
import unittest
class TestIdentificationDocumentType(unittest.TestCase):
pass

View File

@ -42,7 +42,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -249,7 +249,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -50,8 +50,11 @@ frappe.ui.form.on("Leave Application", {
date: frm.doc.posting_date
},
callback: function(r) {
if (!r.exc && r.message) {
leave_details = r.message;
if (!r.exc && r.message['leave_allocation']) {
leave_details = r.message['leave_allocation'];
}
if (!r.exc && r.message['leave_approver']) {
frm.set_value('leave_approver', r.message['leave_approver']);
}
}
});
@ -74,6 +77,13 @@ frappe.ui.form.on("Leave Application", {
if(frm.doc.__islocal && !in_list(frappe.user_roles, "Employee")) {
frm.set_intro(__("Fill the form and save it"));
}
if (!frm.doc.employee && frappe.defaults.get_user_permissions()) {
const perm = frappe.defaults.get_user_permissions();
if (perm && perm['Employee']) {
frm.set_value('employee', perm['Employee']["docs"][0])
}
}
},
employee: function(frm) {

View File

@ -374,7 +374,12 @@ def get_leave_details(employee, date):
"pending_leaves": leaves_pending,
"remaining_leaves": remaining_leaves}
return leave_allocation
ret = {
'leave_allocation': leave_allocation,
'leave_approver': get_leave_approver(employee)
}
return ret
@frappe.whitelist()
def get_leave_balance_on(employee, leave_type, date, allocation_records=None,
@ -603,3 +608,10 @@ def get_approved_leaves_for_period(employee, leave_type, from_date, to_date):
return leave_days
def get_leave_approver(employee, department=None):
if not department:
department = frappe.db.get_value('Employee', employee, 'department')
if department:
return frappe.db.get_value('Department Approver', {'parent': department,
'parentfield': 'leave_approver', 'idx': 1}, 'approver')

View File

@ -71,7 +71,7 @@ class TestLeaveApplication(unittest.TestCase):
add_role("test1@example.com", "Leave Approver")
clear_user_permissions_for_doctype("Employee")
frappe.db.set_value("Department", "_Test Department",
frappe.db.set_value("Department", "_Test Department - _TC",
"leave_block_list", "_Test Leave Block List")
make_allocation_record()
@ -214,7 +214,7 @@ class TestLeaveApplication(unittest.TestCase):
frappe.db.set_value("Leave Block List", "_Test Leave Block List",
"applies_to_all_departments", 1)
frappe.db.set_value("Employee", "_T-Employee-00002", "department",
"_Test Department")
"_Test Department - _TC")
frappe.set_user("test1@example.com")
application.insert()
@ -387,24 +387,24 @@ class TestLeaveApplication(unittest.TestCase):
self.assertRaises(frappe.ValidationError, leave_application.insert)
def test_earned_leave(self):
leave_period = get_leave_period()
employee = get_employee()
leave_type = frappe.get_doc(dict(
leave_type_name = 'Test Earned Leave Type',
doctype = 'Leave Type',
is_earned_leave = 1,
earned_leave_frequency = 'Monthly',
rounding = 0.5
)).insert()
allocate_leaves(employee, leave_period, leave_type.name, 0, eligible_leaves = 12)
# this method will be called by scheduler
allocate_earned_leaves(leave_type.name, leave_period, as_on = half_of_leave_period)
self.assertEqual(get_leave_balance(employee, leave_period, leave_type.name), 6)
# def test_earned_leave(self):
# leave_period = get_leave_period()
# employee = get_employee()
#
# leave_type = frappe.get_doc(dict(
# leave_type_name = 'Test Earned Leave Type',
# doctype = 'Leave Type',
# is_earned_leave = 1,
# earned_leave_frequency = 'Monthly',
# rounding = 0.5
# )).insert()
#
# allocate_leaves(employee, leave_period, leave_type.name, 0, eligible_leaves = 12)
#
# # this method will be called by scheduler
# allocate_earned_leaves(leave_type.name, leave_period, as_on = half_of_leave_period)
#
# self.assertEqual(get_leave_balance(employee, leave_period, leave_type.name), 6)
def make_allocation_record(employee=None, leave_type=None):

View File

@ -207,7 +207,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -14,20 +14,20 @@ class TestLeaveBlockList(unittest.TestCase):
def test_get_applicable_block_dates(self):
frappe.set_user("test@example.com")
frappe.db.set_value("Department", "_Test Department", "leave_block_list",
frappe.db.set_value("Department", "_Test Department - _TC", "leave_block_list",
"_Test Leave Block List")
self.assertTrue(getdate("2013-01-02") in
[d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03")])
def test_get_applicable_block_dates_for_allowed_user(self):
frappe.set_user("test1@example.com")
frappe.db.set_value("Department", "_Test Department 1", "leave_block_list",
frappe.db.set_value("Department", "_Test Department 1 - _TC", "leave_block_list",
"_Test Leave Block List")
self.assertEqual([], [d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03")])
def test_get_applicable_block_dates_all_lists(self):
frappe.set_user("test1@example.com")
frappe.db.set_value("Department", "_Test Department 1", "leave_block_list",
frappe.db.set_value("Department", "_Test Department 1 - _TC", "leave_block_list",
"_Test Leave Block List")
self.assertTrue(getdate("2013-01-02") in
[d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03", all_lists=True)])

View File

@ -42,7 +42,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -67,7 +67,7 @@
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,

View File

@ -6,37 +6,37 @@ from __future__ import unicode_literals
import frappe
import unittest
class TestLeaveEncashment(unittest.TestCase):
def test_leave_balance_value_and_amount(self):
employee = get_employee()
leave_period = get_leave_period()
today = get_today()
leave_type = frappe.get_doc(dict(
leave_type_name = 'Test Leave Type',
doctype = 'Leave Type',
allow_encashment = 1,
encashment_threshold_days = 3,
earning_component = 'Leave Encashment'
)).insert()
allocate_leave(employee, leave_period, leave_type.name, 5)
leave_encashment = frappe.get_doc(dict(
doctype = 'Leave Encashment',
employee = employee,
leave_period = leave_period,
leave_type = leave_type.name,
payroll_date = today
)).insert()
self.assertEqual(leave_encashment.leave_balance, 5)
self.assertEqual(leave_encashment.encashable_days, 2)
# TODO; validate value
salary_structure = get_current_structure(employee, today)
self.assertEqual(leave_encashment.encashment_value,
2 * frappe.db.get_value('Salary Structure', salary_structure, 'leave_encashment_amount_per_day'))
# class TestLeaveEncashment(unittest.TestCase):
# def test_leave_balance_value_and_amount(self):
# employee = get_employee()
# leave_period = get_leave_period()
# today = get_today()
#
# leave_type = frappe.get_doc(dict(
# leave_type_name = 'Test Leave Type',
# doctype = 'Leave Type',
# allow_encashment = 1,
# encashment_threshold_days = 3,
# earning_component = 'Leave Encashment'
# )).insert()
#
# allocate_leave(employee, leave_period, leave_type.name, 5)
#
# leave_encashment = frappe.get_doc(dict(
# doctype = 'Leave Encashment',
# employee = employee,
# leave_period = leave_period,
# leave_type = leave_type.name,
# payroll_date = today
# )).insert()
#
# self.assertEqual(leave_encashment.leave_balance, 5)
# self.assertEqual(leave_encashment.encashable_days, 2)
#
# # TODO; validate value
# salary_structure = get_current_structure(employee, today)
# self.assertEqual(leave_encashment.encashment_value,
# 2 * frappe.db.get_value('Salary Structure', salary_structure, 'leave_encashment_amount_per_day'))

View File

@ -6,26 +6,26 @@ from __future__ import unicode_literals
import frappe
import unittest
class TestLeavePeriod(unittest.TestCase):
def test_leave_grant(self):
employee = get_employee()
leave_policy = get_leave_policy()
leave_period = get_leave_period()
frappe.db.set_value('Employee', employee, 'leave_policy', leave_policy)
leave_period.employee = employee
clear_leave_allocation(employee)
leave_period.grant_leaves()
for d in leave_policy:
self.assertEqual(get_leave_balance(employee, d.leave_type), d.annual_allocation)
return leave_period
def test_duplicate_grant(self):
leave_period = self.test_leave_grant()
self.assertRaises(DuplicateLeaveGrant, leave_period.grant_leaves)
# class TestLeavePeriod(unittest.TestCase):
# def test_leave_grant(self):
# employee = get_employee()
# leave_policy = get_leave_policy()
# leave_period = get_leave_period()
#
# frappe.db.set_value('Employee', employee, 'leave_policy', leave_policy)
#
# leave_period.employee = employee
#
# clear_leave_allocation(employee)
#
# leave_period.grant_leaves()
#
# for d in leave_policy:
# self.assertEqual(get_leave_balance(employee, d.leave_type), d.annual_allocation)
#
# return leave_period
#
# def test_duplicate_grant(self):
# leave_period = self.test_leave_grant()
# self.assertRaises(DuplicateLeaveGrant, leave_period.grant_leaves)
#

View File

@ -42,7 +42,7 @@
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,

View File

@ -0,0 +1,8 @@
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on('Purpose of Travel', {
refresh: function(frm) {
}
});

View File

@ -0,0 +1,93 @@
{
"allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"autoname": "field:purpose_of_travel",
"beta": 0,
"creation": "2018-05-15 07:00:30.933908",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"editable_grid": 1,
"engine": "InnoDB",
"fields": [
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "purpose_of_travel",
"fieldtype": "Data",
"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": "Purpose of Travel",
"length": 0,
"no_copy": 0,
"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
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-05-15 07:05:26.219209",
"modified_by": "Administrator",
"module": "HR",
"name": "Purpose of Travel",
"name_case": "",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
}
],
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 0,
"track_seen": 0
}

View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class PurposeofTravel(Document):
pass

View File

@ -0,0 +1,23 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Purpose of Travel", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially([
// insert a new Purpose of Travel
() => frappe.tests.make('Purpose of Travel', [
// values to be set
{key: 'value'}
]),
() => {
assert.equal(cur_frm.doc.key, 'value');
},
() => done()
]);
});

View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import frappe
import unittest
class TestPurposeofTravel(unittest.TestCase):
pass

Some files were not shown because too many files have changed in this diff Show More