Browse Source

Merge branch 'develop' into stock-ageing-negative-stock

develop
Marica 3 years ago
committed by GitHub
parent
commit
0eb38a4b13
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 27
      .github/ISSUE_TEMPLATE/bug_report.yaml
  2. 4
      erpnext/__init__.py
  3. 29
      erpnext/accounts/doctype/account/tests/test_account.js
  4. 69
      erpnext/accounts/doctype/account/tests/test_account_with_number.js
  5. 46
      erpnext/accounts/doctype/account/tests/test_make_tax_account.js
  6. 35
      erpnext/accounts/doctype/accounts_settings/test_accounts_settings.js
  7. 39
      erpnext/accounts/doctype/journal_entry/test_journal_entry.js
  8. 2
      erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py
  9. 55
      erpnext/accounts/doctype/payment_entry/tests/test_payment_against_invoice.js
  10. 60
      erpnext/accounts/doctype/payment_entry/tests/test_payment_against_purchase_invoice.js
  11. 28
      erpnext/accounts/doctype/payment_entry/tests/test_payment_entry.js
  12. 67
      erpnext/accounts/doctype/payment_entry/tests/test_payment_entry_write_off.js
  13. 28
      erpnext/accounts/doctype/pricing_rule/tests/test_pricing_rule.js
  14. 58
      erpnext/accounts/doctype/pricing_rule/tests/test_pricing_rule_with_different_currency.js
  15. 56
      erpnext/accounts/doctype/pricing_rule/tests/test_pricing_rule_with_same_currency.js
  16. 74
      erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.js
  17. 28
      erpnext/accounts/doctype/purchase_taxes_and_charges_template/test_purchase_taxes_and_charges_template.js
  18. 8
      erpnext/accounts/doctype/sales_invoice/sales_invoice.py
  19. 73
      erpnext/accounts/doctype/sales_invoice/test_sales_invoice.js
  20. 42
      erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice.js
  21. 35
      erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_margin.js
  22. 56
      erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_payment.js
  23. 51
      erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_payment_request.js
  24. 44
      erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_serialize_item.js
  25. 28
      erpnext/accounts/doctype/sales_taxes_and_charges_template/test_sales_taxes_and_charges_template.js
  26. 36
      erpnext/accounts/doctype/shipping_rule/test_shipping_rule.js
  27. 36
      erpnext/accounts/doctype/shipping_rule/tests/test_shipping_rule_for_buying.js
  28. 32
      erpnext/accounts/doctype/subscription/test_subscription.js
  29. 2
      erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py
  30. 116
      erpnext/agriculture/doctype/crop/test_crop.js
  31. 34
      erpnext/agriculture/doctype/crop_cycle/test_crop_cycle.js
  32. 38
      erpnext/agriculture/doctype/disease/test_disease.js
  33. 31
      erpnext/agriculture/doctype/fertilizer/test_fertilizer.js
  34. 26
      erpnext/agriculture/doctype/soil_texture/test_soil_texture.js
  35. 25
      erpnext/agriculture/doctype/water_analysis/test_water_analysis.js
  36. 80
      erpnext/buying/doctype/purchase_order/tests/test_purchase_order.js
  37. 61
      erpnext/buying/doctype/purchase_order/tests/test_purchase_order_get_items.js
  38. 74
      erpnext/buying/doctype/purchase_order/tests/test_purchase_order_receipt.js
  39. 47
      erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_discount_on_grand_total.js
  40. 44
      erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_item_wise_discount.js
  41. 39
      erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_multi_uom.js
  42. 43
      erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_shipping_rule.js
  43. 44
      erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_taxes_and_charges.js
  44. 76
      erpnext/buying/doctype/request_for_quotation/tests/test_request_for_quotation.js
  45. 128
      erpnext/buying/doctype/request_for_quotation/tests/test_request_for_quotation_for_status.js
  46. 77
      erpnext/buying/doctype/supplier/test_supplier.js
  47. 74
      erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation.js
  48. 34
      erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_item_wise_discount.js
  49. 37
      erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_taxes_and_charges.js
  50. 17
      erpnext/crm/doctype/lead/lead.py
  51. 11
      erpnext/crm/doctype/lead/test_lead.py
  52. 43
      erpnext/crm/doctype/lead/tests/test_lead_individual.js
  53. 55
      erpnext/crm/doctype/lead/tests/test_lead_organization.js
  54. 56
      erpnext/crm/doctype/opportunity/test_opportunity.js
  55. 24
      erpnext/education/doctype/academic_term/test_academic_term.js
  56. 16
      erpnext/education/doctype/assessment_criteria/test_assessment_criteria.js
  57. 15
      erpnext/education/doctype/assessment_criteria_group/test_assessment_criteria_group.js
  58. 65
      erpnext/education/doctype/assessment_group/test_assessment_group.js
  59. 54
      erpnext/education/doctype/assessment_plan/test_assessment_plan.js
  60. 73
      erpnext/education/doctype/assessment_result/test_assessment_result.js
  61. 29
      erpnext/education/doctype/assessment_result_tool/test_assessment_result_tool.js
  62. 36
      erpnext/education/doctype/course/test_course.js
  63. 31
      erpnext/education/doctype/education_settings/test_education_settings.js
  64. 31
      erpnext/education/doctype/fees/test_fees.js
  65. 102
      erpnext/education/doctype/grading_scale/test_grading_scale.js
  66. 34
      erpnext/education/doctype/guardian/test_guardian.js
  67. 20
      erpnext/education/doctype/instructor/test_instructor.js
  68. 34
      erpnext/education/doctype/program/test_program.js
  69. 22
      erpnext/education/doctype/room/test_room.js
  70. 40
      erpnext/education/doctype/student_admission/test_student_admission.js
  71. 95
      erpnext/education/doctype/student_applicant/tests/test_student_applicant.js
  72. 87
      erpnext/education/doctype/student_applicant/tests/test_student_applicant_dummy_data.js
  73. 110
      erpnext/education/doctype/student_applicant/tests/test_student_applicant_options.js
  74. 31
      erpnext/education/doctype/student_attendance/test_student_attendance.js
  75. 85
      erpnext/education/doctype/student_attendance_tool/test_student_attendance_tool.js
  76. 19
      erpnext/education/doctype/student_batch_name/test_student_batch_name.js
  77. 19
      erpnext/education/doctype/student_category/test_student_category.js
  78. 56
      erpnext/education/doctype/student_group/test_student_group.js
  79. 84
      erpnext/education/doctype/student_group_creation_tool/test_student_group_creation_tool.js
  80. 69
      erpnext/education/doctype/student_leave_application/test_student_leave_application.js
  81. 35
      erpnext/education/doctype/student_log/test_student_log.js
  82. 78
      erpnext/erpnext_integrations/workspace/erpnext_integrations_settings/erpnext_integrations_settings.json
  83. 2
      erpnext/hooks.py
  84. 17
      erpnext/hr/doctype/appointment_letter/appointment_letter.py
  85. 57
      erpnext/hr/doctype/appraisal/test_appraisal.js
  86. 29
      erpnext/hr/doctype/appraisal_template/test_appraisal_template.js
  87. 39
      erpnext/hr/doctype/attendance/test_attendance.js
  88. 40
      erpnext/hr/doctype/employee/test_employee.js
  89. 61
      erpnext/hr/doctype/employee_attendance_tool/test_employee_attendance_tool.js
  90. 22
      erpnext/hr/doctype/employment_type/test_employment_type.js
  91. 2
      erpnext/hr/doctype/expense_claim/expense_claim.js
  92. 44
      erpnext/hr/doctype/expense_claim/test_expense_claim.js
  93. 24
      erpnext/hr/doctype/expense_claim/test_expense_claim.py
  94. 1
      erpnext/hr/doctype/expense_claim/test_records.json
  95. 29
      erpnext/hr/doctype/expense_claim_type/test_expense_claim_type.js
  96. 42
      erpnext/hr/doctype/holiday_list/test_holiday_list.js
  97. 28
      erpnext/hr/doctype/job_applicant/test_job_applicant.js
  98. 51
      erpnext/hr/doctype/job_offer/test_job_offer.js
  99. 26
      erpnext/hr/doctype/job_opening/test_job_opening.js
  100. 41
      erpnext/hr/doctype/leave_allocation/test_leave_allocation.js

27
.github/ISSUE_TEMPLATE/bug_report.yaml

@ -24,20 +24,6 @@ body:
validations:
required: true
- type: dropdown
id: version
attributes:
label: Version
description: Affected versions.
multiple: true
options:
- v12
- v13
- v14
- develop
validations:
required: true
- type: dropdown
id: module
attributes:
@ -86,7 +72,7 @@ body:
- manual install
- FrappeCloud
validations:
required: true
required: false
- type: textarea
id: logs
@ -95,12 +81,7 @@ body:
description: Please copy and paste any relevant log output. This will be automatically formatted.
render: shell
- type: checkboxes
id: terms
- type: markdown
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/frappe/erpnext/blob/develop/CODE_OF_CONDUCT.md)
options:
- label: I agree to follow this project's Code of Conduct
required: true
value: |
By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/frappe/erpnext/blob/develop/CODE_OF_CONDUCT.md)

4
erpnext/__init__.py

@ -55,9 +55,9 @@ def set_perpetual_inventory(enable=1, company=None):
company.enable_perpetual_inventory = enable
company.save()
def encode_company_abbr(name, company):
def encode_company_abbr(name, company=None, abbr=None):
'''Returns name encoded with company abbreviation'''
company_abbr = frappe.get_cached_value('Company', company, "abbr")
company_abbr = abbr or frappe.get_cached_value('Company', company, "abbr")
parts = name.rsplit(" - ", 1)
if parts[-1].lower() != company_abbr.lower():

29
erpnext/accounts/doctype/account/tests/test_account.js

@ -1,29 +0,0 @@
QUnit.module('accounts');
QUnit.test("test account", function(assert) {
assert.expect(4);
let done = assert.async();
frappe.run_serially([
() => frappe.set_route('Tree', 'Account'),
() => frappe.timeout(3),
() => frappe.click_button('Expand All'),
() => frappe.timeout(1),
() => frappe.click_link('Debtors'),
() => frappe.click_button('Edit'),
() => frappe.timeout(1),
() => {
assert.ok(cur_frm.doc.root_type=='Asset');
assert.ok(cur_frm.doc.report_type=='Balance Sheet');
assert.ok(cur_frm.doc.account_type=='Receivable');
},
() => frappe.click_button('Ledger'),
() => frappe.timeout(1),
() => {
// check if general ledger report shown
assert.deepEqual(frappe.get_route(), ['query-report', 'General Ledger']);
window.history.back();
return frappe.timeout(1);
},
() => done()
]);
});

69
erpnext/accounts/doctype/account/tests/test_account_with_number.js

@ -1,69 +0,0 @@
QUnit.module('accounts');
QUnit.test("test account with number", function(assert) {
assert.expect(7);
let done = assert.async();
frappe.run_serially([
() => frappe.set_route('Tree', 'Account'),
() => frappe.click_link('Income'),
() => frappe.click_button('Add Child'),
() => frappe.timeout(.5),
() => {
cur_dialog.fields_dict.account_name.$input.val("Test Income");
cur_dialog.fields_dict.account_number.$input.val("4010");
},
() => frappe.click_button('Create New'),
() => frappe.timeout(1),
() => {
assert.ok($('a:contains("4010 - Test Income"):visible').length!=0, "Account created with number");
},
() => frappe.click_link('4010 - Test Income'),
() => frappe.click_button('Edit'),
() => frappe.timeout(.5),
() => frappe.click_button('Update Account Number'),
() => frappe.timeout(.5),
() => {
cur_dialog.fields_dict.account_number.$input.val("4020");
},
() => frappe.timeout(1),
() => cur_dialog.primary_action(),
() => frappe.timeout(1),
() => cur_frm.refresh_fields(),
() => frappe.timeout(.5),
() => {
var abbr = frappe.get_abbr(frappe.defaults.get_default("Company"));
var new_account = "4020 - Test Income - " + abbr;
assert.ok(cur_frm.doc.name==new_account, "Account renamed");
assert.ok(cur_frm.doc.account_name=="Test Income", "account name remained same");
assert.ok(cur_frm.doc.account_number=="4020", "Account number updated to 4020");
},
() => frappe.timeout(1),
() => frappe.click_button('Menu'),
() => frappe.click_link('Rename'),
() => frappe.timeout(.5),
() => {
cur_dialog.fields_dict.new_name.$input.val("4030 - Test Income");
},
() => frappe.timeout(.5),
() => frappe.click_button("Rename"),
() => frappe.timeout(2),
() => {
assert.ok(cur_frm.doc.account_name=="Test Income", "account name remained same");
assert.ok(cur_frm.doc.account_number=="4030", "Account number updated to 4030");
},
() => frappe.timeout(.5),
() => frappe.click_button('Chart of Accounts'),
() => frappe.timeout(.5),
() => frappe.click_button('Menu'),
() => frappe.click_link('Refresh'),
() => frappe.click_button('Expand All'),
() => frappe.click_link('4030 - Test Income'),
() => frappe.click_button('Delete'),
() => frappe.click_button('Yes'),
() => frappe.timeout(.5),
() => {
assert.ok($('a:contains("4030 - Test Account"):visible').length==0, "Account deleted");
},
() => done()
]);
});

46
erpnext/accounts/doctype/account/tests/test_make_tax_account.js

@ -1,46 +0,0 @@
QUnit.module('accounts');
QUnit.test("test account", assert => {
assert.expect(3);
let done = assert.async();
frappe.run_serially([
() => frappe.set_route('Tree', 'Account'),
() => frappe.click_button('Expand All'),
() => frappe.click_link('Duties and Taxes - '+ frappe.get_abbr(frappe.defaults.get_default("Company"))),
() => {
if($('a:contains("CGST"):visible').length == 0){
return frappe.map_tax.make('CGST', 9);
}
},
() => {
if($('a:contains("SGST"):visible').length == 0){
return frappe.map_tax.make('SGST', 9);
}
},
() => {
if($('a:contains("IGST"):visible').length == 0){
return frappe.map_tax.make('IGST', 18);
}
},
() => {
assert.ok($('a:contains("CGST"):visible').length!=0, "CGST Checked");
assert.ok($('a:contains("SGST"):visible').length!=0, "SGST Checked");
assert.ok($('a:contains("IGST"):visible').length!=0, "IGST Checked");
},
() => done()
]);
});
frappe.map_tax = {
make:function(text,rate){
return frappe.run_serially([
() => frappe.click_button('Add Child'),
() => frappe.timeout(0.2),
() => cur_dialog.set_value('account_name',text),
() => cur_dialog.set_value('account_type','Tax'),
() => cur_dialog.set_value('tax_rate',rate),
() => cur_dialog.set_value('account_currency','INR'),
() => frappe.click_button('Create New'),
]);
}
};

35
erpnext/accounts/doctype/accounts_settings/test_accounts_settings.js

@ -1,35 +0,0 @@
QUnit.module('accounts');
QUnit.test("test: Accounts Settings doesn't allow negatives", function (assert) {
let done = assert.async();
assert.expect(2);
frappe.run_serially([
() => frappe.set_route('Form', 'Accounts Settings', 'Accounts Settings'),
() => frappe.timeout(2),
() => unchecked_if_checked(cur_frm, 'Allow Stale Exchange Rates', frappe.click_check),
() => cur_frm.set_value('stale_days', 0),
() => frappe.click_button('Save'),
() => frappe.timeout(2),
() => {
assert.ok(cur_dialog);
},
() => frappe.click_button('Close'),
() => cur_frm.set_value('stale_days', -1),
() => frappe.click_button('Save'),
() => frappe.timeout(2),
() => {
assert.ok(cur_dialog);
},
() => frappe.click_button('Close'),
() => done()
]);
});
const unchecked_if_checked = function(frm, field_name, fn){
if (frm.doc.allow_stale) {
return fn(field_name);
}
};

39
erpnext/accounts/doctype/journal_entry/test_journal_entry.js

@ -1,39 +0,0 @@
QUnit.module('Journal Entry');
QUnit.test("test journal entry", function(assert) {
assert.expect(2);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Journal Entry', [
{posting_date:frappe.datetime.add_days(frappe.datetime.nowdate(), 0)},
{accounts: [
[
{'account':'Debtors - '+frappe.get_abbr(frappe.defaults.get_default('Company'))},
{'party_type':'Customer'},
{'party':'Test Customer 1'},
{'credit_in_account_currency':1000},
{'is_advance':'Yes'},
],
[
{'account':'HDFC - '+frappe.get_abbr(frappe.defaults.get_default('Company'))},
{'debit_in_account_currency':1000},
]
]},
{cheque_no:1234},
{cheque_date: frappe.datetime.add_days(frappe.datetime.nowdate(), -1)},
{user_remark: 'Test'},
]);
},
() => cur_frm.save(),
() => {
// get_item_details
assert.ok(cur_frm.doc.total_debit==1000, "total debit correct");
assert.ok(cur_frm.doc.total_credit==1000, "total credit correct");
},
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

2
erpnext/accounts/doctype/opening_invoice_creation_tool/test_opening_invoice_creation_tool.py

@ -148,7 +148,7 @@ def make_company():
company.company_name = "_Test Opening Invoice Company"
company.abbr = "_TOIC"
company.default_currency = "INR"
company.country = "India"
company.country = "Pakistan"
company.insert()
return company

55
erpnext/accounts/doctype/payment_entry/tests/test_payment_against_invoice.js

@ -1,55 +0,0 @@
QUnit.module('Payment Entry');
QUnit.test("test payment entry", function(assert) {
assert.expect(6);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Sales Invoice', [
{customer: 'Test Customer 1'},
{items: [
[
{'item_code': 'Test Product 1'},
{'qty': 1},
{'rate': 101},
]
]}
]);
},
() => cur_frm.save(),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(1),
() => frappe.tests.click_button('Close'),
() => frappe.timeout(1),
() => frappe.click_button('Make'),
() => frappe.timeout(1),
() => frappe.click_link('Payment'),
() => frappe.timeout(2),
() => {
assert.equal(frappe.get_route()[1], 'Payment Entry',
'made payment entry');
assert.equal(cur_frm.doc.party, 'Test Customer 1',
'customer set in payment entry');
assert.equal(cur_frm.doc.paid_amount, 101,
'paid amount set in payment entry');
assert.equal(cur_frm.doc.references[0].allocated_amount, 101,
'amount allocated against sales invoice');
},
() => frappe.timeout(1),
() => cur_frm.set_value('paid_amount', 100),
() => frappe.timeout(1),
() => {
frappe.model.set_value("Payment Entry Reference", cur_frm.doc.references[0].name,
"allocated_amount", 101);
},
() => frappe.timeout(1),
() => frappe.click_button('Write Off Difference Amount'),
() => frappe.timeout(1),
() => {
assert.equal(cur_frm.doc.difference_amount, 0, 'difference amount is zero');
assert.equal(cur_frm.doc.deductions[0].amount, 1, 'Write off amount = 1');
},
() => done()
]);
});

60
erpnext/accounts/doctype/payment_entry/tests/test_payment_against_purchase_invoice.js

@ -1,60 +0,0 @@
QUnit.module('Payment Entry');
QUnit.test("test payment entry", function(assert) {
assert.expect(7 );
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Purchase Invoice', [
{supplier: 'Test Supplier'},
{bill_no: 'in1234'},
{items: [
[
{'qty': 2},
{'item_code': 'Test Product 1'},
{'rate':1000},
]
]},
{update_stock:1},
{supplier_address: 'Test1-Billing'},
{contact_person: 'Contact 3-Test Supplier'},
{tc_name: 'Test Term 1'},
{terms: 'This is just a Test'}
]);
},
() => cur_frm.save(),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(1),
() => frappe.click_button('Make'),
() => frappe.timeout(2),
() => frappe.click_link('Payment'),
() => frappe.timeout(3),
() => cur_frm.set_value('mode_of_payment','Cash'),
() => frappe.timeout(3),
() => {
assert.equal(frappe.get_route()[1], 'Payment Entry',
'made payment entry');
assert.equal(cur_frm.doc.party, 'Test Supplier',
'supplier set in payment entry');
assert.equal(cur_frm.doc.paid_amount, 2000,
'paid amount set in payment entry');
assert.equal(cur_frm.doc.references[0].allocated_amount, 2000,
'amount allocated against purchase invoice');
assert.equal(cur_frm.doc.references[0].bill_no, 'in1234',
'invoice number allocated against purchase invoice');
assert.equal(cur_frm.get_field('total_allocated_amount').value, 2000,
'correct amount allocated in Write Off');
assert.equal(cur_frm.get_field('unallocated_amount').value, 0,
'correct amount unallocated in Write Off');
},
() => cur_frm.save(),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(3),
() => done()
]);
});

28
erpnext/accounts/doctype/payment_entry/tests/test_payment_entry.js

@ -1,28 +0,0 @@
QUnit.module('Accounts');
QUnit.test("test payment entry", function(assert) {
assert.expect(1);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Payment Entry', [
{payment_type:'Receive'},
{mode_of_payment:'Cash'},
{party_type:'Customer'},
{party:'Test Customer 3'},
{paid_amount:675},
{reference_no:123},
{reference_date: frappe.datetime.add_days(frappe.datetime.nowdate(), 0)},
]);
},
() => cur_frm.save(),
() => {
// get_item_details
assert.ok(cur_frm.doc.total_allocated_amount==675, "Allocated AmountCorrect");
},
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

67
erpnext/accounts/doctype/payment_entry/tests/test_payment_entry_write_off.js

@ -1,67 +0,0 @@
QUnit.module('Payment Entry');
QUnit.test("test payment entry", function(assert) {
assert.expect(8);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Sales Invoice', [
{customer: 'Test Customer 1'},
{company: 'For Testing'},
{currency: 'INR'},
{selling_price_list: '_Test Price List'},
{items: [
[
{'qty': 1},
{'item_code': 'Test Product 1'},
]
]}
]);
},
() => frappe.timeout(1),
() => cur_frm.save(),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(1.5),
() => frappe.click_button('Close'),
() => frappe.timeout(0.5),
() => frappe.click_button('Make'),
() => frappe.timeout(1),
() => frappe.click_link('Payment'),
() => frappe.timeout(2),
() => cur_frm.set_value("paid_to", "_Test Cash - FT"),
() => frappe.timeout(0.5),
() => {
assert.equal(frappe.get_route()[1], 'Payment Entry', 'made payment entry');
assert.equal(cur_frm.doc.party, 'Test Customer 1', 'customer set in payment entry');
assert.equal(cur_frm.doc.paid_from, 'Debtors - FT', 'customer account set in payment entry');
assert.equal(cur_frm.doc.paid_amount, 100, 'paid amount set in payment entry');
assert.equal(cur_frm.doc.references[0].allocated_amount, 100,
'amount allocated against sales invoice');
},
() => cur_frm.set_value('paid_amount', 95),
() => frappe.timeout(1),
() => {
frappe.model.set_value("Payment Entry Reference",
cur_frm.doc.references[0].name, "allocated_amount", 100);
},
() => frappe.timeout(.5),
() => {
assert.equal(cur_frm.doc.difference_amount, 5, 'difference amount is 5');
},
() => {
frappe.db.set_value("Company", "For Testing", "write_off_account", "_Test Write Off - FT");
frappe.timeout(1);
frappe.db.set_value("Company", "For Testing",
"exchange_gain_loss_account", "_Test Exchange Gain/Loss - FT");
},
() => frappe.timeout(1),
() => frappe.click_button('Write Off Difference Amount'),
() => frappe.timeout(2),
() => {
assert.equal(cur_frm.doc.difference_amount, 0, 'difference amount is zero');
assert.equal(cur_frm.doc.deductions[0].amount, 5, 'Write off amount = 5');
},
() => done()
]);
});

28
erpnext/accounts/doctype/pricing_rule/tests/test_pricing_rule.js

@ -1,28 +0,0 @@
QUnit.module('Pricing Rule');
QUnit.test("test pricing rule", function(assert) {
assert.expect(2);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make("Pricing Rule", [
{title: 'Test Pricing Rule'},
{item_code:'Test Product 2'},
{selling:1},
{applicable_for:'Customer'},
{customer:'Test Customer 3'},
{currency: frappe.defaults.get_default("currency")}
{min_qty:1},
{max_qty:20},
{valid_upto: frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)},
{discount_percentage:10},
{for_price_list:'Standard Selling'}
]);
},
() => {
assert.ok(cur_frm.doc.item_code=='Test Product 2');
assert.ok(cur_frm.doc.customer=='Test Customer 3');
},
() => done()
]);
});

58
erpnext/accounts/doctype/pricing_rule/tests/test_pricing_rule_with_different_currency.js

@ -1,58 +0,0 @@
QUnit.module('Pricing Rule');
QUnit.test("test pricing rule with different currency", function(assert) {
assert.expect(3);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make("Pricing Rule", [
{title: 'Test Pricing Rule 2'},
{apply_on: 'Item Code'},
{item_code:'Test Product 4'},
{selling:1},
{priority: 1},
{min_qty:1},
{max_qty:20},
{valid_upto: frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)},
{margin_type: 'Amount'},
{margin_rate_or_amount: 20},
{rate_or_discount: 'Rate'},
{rate:200},
{currency:'USD'}
]);
},
() => cur_frm.save(),
() => frappe.timeout(0.3),
() => {
assert.ok(cur_frm.doc.item_code=='Test Product 4');
},
() => {
return frappe.tests.make('Sales Order', [
{customer: 'Test Customer 1'},
{currency: 'INR'},
{items: [
[
{'delivery_date': frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)},
{'qty': 5},
{'item_code': "Test Product 4"}
]
]}
]);
},
() => cur_frm.save(),
() => frappe.timeout(0.3),
() => {
// get_item_details
assert.ok(cur_frm.doc.items[0].pricing_rule=='Test Pricing Rule 2', "Pricing rule correct");
// margin not applied because different currency in pricing rule
assert.ok(cur_frm.doc.items[0].margin_type==null, "Margin correct");
},
() => frappe.timeout(0.3),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

56
erpnext/accounts/doctype/pricing_rule/tests/test_pricing_rule_with_same_currency.js

@ -1,56 +0,0 @@
QUnit.module('Pricing Rule');
QUnit.test("test pricing rule with same currency", function(assert) {
assert.expect(4);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make("Pricing Rule", [
{title: 'Test Pricing Rule 1'},
{apply_on: 'Item Code'},
{item_code:'Test Product 4'},
{selling:1},
{min_qty:1},
{max_qty:20},
{valid_upto: frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)},
{rate_or_discount: 'Rate'},
{rate:200},
{currency:'USD'}
]);
},
() => cur_frm.save(),
() => frappe.timeout(0.3),
() => {
assert.ok(cur_frm.doc.item_code=='Test Product 4');
},
() => {
return frappe.tests.make('Sales Order', [
{customer: 'Test Customer 1'},
{currency: 'USD'},
{items: [
[
{'delivery_date': frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)},
{'qty': 5},
{'item_code': "Test Product 4"}
]
]}
]);
},
() => cur_frm.save(),
() => frappe.timeout(0.3),
() => {
// get_item_details
assert.ok(cur_frm.doc.items[0].pricing_rule=='Test Pricing Rule 1', "Pricing rule correct");
assert.ok(cur_frm.doc.items[0].price_list_rate==200, "Item rate correct");
// get_total
assert.ok(cur_frm.doc.total== 1000, "Total correct");
},
() => frappe.timeout(0.3),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

74
erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.js

@ -1,74 +0,0 @@
QUnit.module('Purchase Invoice');
QUnit.test("test purchase invoice", function(assert) {
assert.expect(9);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Purchase Invoice', [
{supplier: 'Test Supplier'},
{bill_no: 'in123'},
{items: [
[
{'qty': 5},
{'item_code': 'Test Product 1'},
{'rate':100},
]
]},
{update_stock:1},
{supplier_address: 'Test1-Billing'},
{contact_person: 'Contact 3-Test Supplier'},
{taxes_and_charges: 'TEST In State GST - FT'},
{tc_name: 'Test Term 1'},
{terms: 'This is Test'},
{payment_terms_template: '_Test Payment Term Template UI'}
]);
},
() => cur_frm.save(),
() => {
// get_item_details
assert.ok(cur_frm.doc.items[0].item_name=='Test Product 1', "Item name correct");
// get tax details
assert.ok(cur_frm.doc.taxes_and_charges=='TEST In State GST - FT', "Tax details correct");
// get tax account head details
assert.ok(cur_frm.doc.taxes[0].account_head=='CGST - '+frappe.get_abbr(frappe.defaults.get_default('Company')), " Account Head abbr correct");
// grand_total Calculated
assert.ok(cur_frm.doc.grand_total==590, "Grad Total correct");
assert.ok(cur_frm.doc.payment_terms_template, "Payment Terms Template is correct");
assert.ok(cur_frm.doc.payment_schedule.length > 0, "Payment Term Schedule is not empty");
},
() => {
let date = cur_frm.doc.due_date;
frappe.tests.set_control('due_date', frappe.datetime.add_days(date, 1));
frappe.timeout(0.5);
assert.ok(cur_dialog && cur_dialog.is_visible, 'Message is displayed to user');
},
() => frappe.timeout(1),
() => frappe.tests.click_button('Close'),
() => frappe.timeout(0.5),
() => frappe.tests.set_form_values(cur_frm, [{'payment_terms_schedule': ''}]),
() => {
let date = cur_frm.doc.due_date;
frappe.tests.set_control('due_date', frappe.datetime.add_days(date, 1));
frappe.timeout(0.5);
assert.ok(cur_dialog && cur_dialog.is_visible, 'Message is displayed to user');
},
() => frappe.timeout(1),
() => frappe.tests.click_button('Close'),
() => frappe.timeout(0.5),
() => frappe.tests.set_form_values(cur_frm, [{'payment_schedule': []}]),
() => {
let date = cur_frm.doc.due_date;
frappe.tests.set_control('due_date', frappe.datetime.add_days(date, 1));
frappe.timeout(0.5);
assert.ok(!cur_dialog, 'Message is not shown');
},
() => cur_frm.save(),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(1),
() => done()
]);
});

28
erpnext/accounts/doctype/purchase_taxes_and_charges_template/test_purchase_taxes_and_charges_template.js

@ -1,28 +0,0 @@
QUnit.module('Sales Taxes and Charges Template');
QUnit.test("test sales taxes and charges template", function(assert) {
assert.expect(2);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Purchase Taxes and Charges Template', [
{title: "TEST In State GST"},
{taxes:[
[
{charge_type:"On Net Total"},
{account_head:"CGST - "+frappe.get_abbr(frappe.defaults.get_default("Company")) }
],
[
{charge_type:"On Net Total"},
{account_head:"SGST - "+frappe.get_abbr(frappe.defaults.get_default("Company")) }
]
]}
]);
},
() => {
assert.ok(cur_frm.doc.title=='TEST In State GST');
assert.ok(cur_frm.doc.name=='TEST In State GST - FT');
},
() => done()
]);
});

8
erpnext/accounts/doctype/sales_invoice/sales_invoice.py

@ -1049,6 +1049,8 @@ class SalesInvoice(SellingController):
frappe.flags.is_reverse_depr_entry = False
asset.flags.ignore_validate_update_after_submit = True
schedule.journal_entry = None
depreciation_amount = self.get_depreciation_amount_in_je(reverse_journal_entry)
asset.finance_books[0].value_after_depreciation += depreciation_amount
asset.save()
def get_posting_date_of_sales_invoice(self):
@ -1071,6 +1073,12 @@ class SalesInvoice(SellingController):
return False
def get_depreciation_amount_in_je(self, journal_entry):
if journal_entry.accounts[0].debit_in_account_currency:
return journal_entry.accounts[0].debit_in_account_currency
else:
return journal_entry.accounts[0].credit_in_account_currency
@property
def enable_discount_accounting(self):
if not hasattr(self, "_enable_discount_accounting"):

73
erpnext/accounts/doctype/sales_invoice/test_sales_invoice.js

@ -1,73 +0,0 @@
QUnit.module('Sales Invoice');
QUnit.test("test sales Invoice", function(assert) {
assert.expect(9);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Sales Invoice', [
{customer: 'Test Customer 1'},
{items: [
[
{'qty': 5},
{'item_code': 'Test Product 1'},
]
]},
{update_stock:1},
{customer_address: 'Test1-Billing'},
{shipping_address_name: 'Test1-Shipping'},
{contact_person: 'Contact 1-Test Customer 1'},
{taxes_and_charges: 'TEST In State GST - FT'},
{tc_name: 'Test Term 1'},
{terms: 'This is Test'},
{payment_terms_template: '_Test Payment Term Template UI'}
]);
},
() => cur_frm.save(),
() => {
// get_item_details
assert.ok(cur_frm.doc.items[0].item_name=='Test Product 1', "Item name correct");
// get tax details
assert.ok(cur_frm.doc.taxes_and_charges=='TEST In State GST - FT', "Tax details correct");
// get tax account head details
assert.ok(cur_frm.doc.taxes[0].account_head=='CGST - '+frappe.get_abbr(frappe.defaults.get_default('Company')), " Account Head abbr correct");
// grand_total Calculated
assert.ok(cur_frm.doc.grand_total==590, "Grand Total correct");
assert.ok(cur_frm.doc.payment_terms_template, "Payment Terms Template is correct");
assert.ok(cur_frm.doc.payment_schedule.length > 0, "Payment Term Schedule is not empty");
},
() => {
let date = cur_frm.doc.due_date;
frappe.tests.set_control('due_date', frappe.datetime.add_days(date, 1));
frappe.timeout(0.5);
assert.ok(cur_dialog && cur_dialog.is_visible, 'Message is displayed to user');
},
() => frappe.timeout(1),
() => frappe.tests.click_button('Close'),
() => frappe.timeout(0.5),
() => frappe.tests.set_form_values(cur_frm, [{'payment_terms_schedule': ''}]),
() => {
let date = cur_frm.doc.due_date;
frappe.tests.set_control('due_date', frappe.datetime.add_days(date, 1));
frappe.timeout(0.5);
assert.ok(cur_dialog && cur_dialog.is_visible, 'Message is displayed to user');
},
() => frappe.timeout(1),
() => frappe.tests.click_button('Close'),
() => frappe.timeout(0.5),
() => frappe.tests.set_form_values(cur_frm, [{'payment_schedule': []}]),
() => {
let date = cur_frm.doc.due_date;
frappe.tests.set_control('due_date', frappe.datetime.add_days(date, 1));
frappe.timeout(0.5);
assert.ok(!cur_dialog, 'Message is not shown');
},
() => cur_frm.save(),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

42
erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice.js

@ -1,42 +0,0 @@
QUnit.module('Sales Invoice');
QUnit.test("test sales Invoice", function(assert) {
assert.expect(4);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Sales Invoice', [
{customer: 'Test Customer 1'},
{items: [
[
{'qty': 5},
{'item_code': 'Test Product 1'},
]
]},
{update_stock:1},
{customer_address: 'Test1-Billing'},
{shipping_address_name: 'Test1-Shipping'},
{contact_person: 'Contact 1-Test Customer 1'},
{taxes_and_charges: 'TEST In State GST - FT'},
{tc_name: 'Test Term 1'},
{terms: 'This is Test'}
]);
},
() => cur_frm.save(),
() => {
// get_item_details
assert.ok(cur_frm.doc.items[0].item_name=='Test Product 1', "Item name correct");
// get tax details
assert.ok(cur_frm.doc.taxes_and_charges=='TEST In State GST - FT', "Tax details correct");
// get tax account head details
assert.ok(cur_frm.doc.taxes[0].account_head=='CGST - '+frappe.get_abbr(frappe.defaults.get_default('Company')), " Account Head abbr correct");
// grand_total Calculated
assert.ok(cur_frm.doc.grand_total==590, "Grad Total correct");
},
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

35
erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_margin.js

@ -1,35 +0,0 @@
QUnit.module('Accounts');
QUnit.test("test sales invoice with margin", function(assert) {
assert.expect(3);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Sales Invoice', [
{customer: 'Test Customer 1'},
{selling_price_list: 'Test-Selling-USD'},
{currency: 'USD'},
{items: [
[
{'item_code': 'Test Product 4'},
{'delivery_date': frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1)},
{'qty': 1},
{'margin_type': 'Percentage'},
{'margin_rate_or_amount': 20}
]
]}
]);
},
() => cur_frm.save(),
() => {
assert.ok(cur_frm.doc.items[0].rate_with_margin == 240, "Margin rate correct");
assert.ok(cur_frm.doc.items[0].base_rate_with_margin == cur_frm.doc.conversion_rate * 240, "Base margin rate correct");
assert.ok(cur_frm.doc.total == 240, "Amount correct");
},
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

56
erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_payment.js

@ -1,56 +0,0 @@
QUnit.module('Sales Invoice');
QUnit.test("test sales Invoice with payment", function(assert) {
assert.expect(4);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Sales Invoice', [
{customer: 'Test Customer 1'},
{items: [
[
{'qty': 5},
{'item_code': 'Test Product 1'},
]
]},
{update_stock:1},
{customer_address: 'Test1-Billing'},
{shipping_address_name: 'Test1-Shipping'},
{contact_person: 'Contact 1-Test Customer 1'},
{taxes_and_charges: 'TEST In State GST - FT'},
{tc_name: 'Test Term 1'},
{terms: 'This is Test'},
{payment_terms_template: '_Test Payment Term Template UI'}
]);
},
() => cur_frm.save(),
() => {
// get_item_details
assert.ok(cur_frm.doc.items[0].item_name=='Test Product 1', "Item name correct");
// get tax details
assert.ok(cur_frm.doc.taxes_and_charges=='TEST In State GST - FT', "Tax details correct");
// grand_total Calculated
assert.ok(cur_frm.doc.grand_total==590, "Grad Total correct");
},
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(2),
() => frappe.tests.click_button('Close'),
() => frappe.tests.click_button('Make'),
() => frappe.tests.click_link('Payment'),
() => frappe.timeout(0.2),
() => { cur_frm.set_value('mode_of_payment','Cash');},
() => { cur_frm.set_value('paid_to','Cash - '+frappe.get_abbr(frappe.defaults.get_default('Company')));},
() => {cur_frm.set_value('reference_no','TEST1234');},
() => {cur_frm.set_value('reference_date',frappe.datetime.add_days(frappe.datetime.nowdate(), 0));},
() => cur_frm.save(),
() => {
// get payment details
assert.ok(cur_frm.doc.paid_amount==590, "Paid Amount Correct");
},
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => done()
]);
});

51
erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_payment_request.js

@ -1,51 +0,0 @@
QUnit.module('Sales Invoice');
QUnit.test("test sales Invoice with payment request", function(assert) {
assert.expect(4);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Sales Invoice', [
{customer: 'Test Customer 1'},
{items: [
[
{'qty': 5},
{'item_code': 'Test Product 1'},
]
]},
{update_stock:1},
{customer_address: 'Test1-Billing'},
{shipping_address_name: 'Test1-Shipping'},
{contact_person: 'Contact 1-Test Customer 1'},
{taxes_and_charges: 'TEST In State GST - FT'},
{tc_name: 'Test Term 1'},
{terms: 'This is Test'}
]);
},
() => cur_frm.save(),
() => {
// get_item_details
assert.ok(cur_frm.doc.items[0].item_name=='Test Product 1', "Item name correct");
// get tax details
assert.ok(cur_frm.doc.taxes_and_charges=='TEST In State GST - FT', "Tax details correct");
// grand_total Calculated
assert.ok(cur_frm.doc.grand_total==590, "Grad Total correct");
},
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(2),
() => frappe.tests.click_button('Close'),
() => frappe.tests.click_button('Make'),
() => frappe.tests.click_link('Payment Request'),
() => frappe.timeout(0.2),
() => { cur_frm.set_value('print_format','GST Tax Invoice');},
() => { cur_frm.set_value('email_to','test@gmail.com');},
() => cur_frm.save(),
() => {
// get payment details
assert.ok(cur_frm.doc.grand_total==590, "grand total Correct");
},
() => done()
]);
});

44
erpnext/accounts/doctype/sales_invoice/tests/test_sales_invoice_with_serialize_item.js

@ -1,44 +0,0 @@
QUnit.module('Sales Invoice');
QUnit.test("test sales Invoice with serialize item", function(assert) {
assert.expect(5);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Sales Invoice', [
{customer: 'Test Customer 1'},
{items: [
[
{'qty': 2},
{'item_code': 'Test Product 4'},
]
]},
{update_stock:1},
{customer_address: 'Test1-Billing'},
{shipping_address_name: 'Test1-Shipping'},
{contact_person: 'Contact 1-Test Customer 1'},
{taxes_and_charges: 'TEST In State GST - FT'},
{tc_name: 'Test Term 1'},
{terms: 'This is Test'}
]);
},
() => cur_frm.save(),
() => {
// get_item_details
assert.ok(cur_frm.doc.items[0].item_name=='Test Product 4', "Item name correct");
// get tax details
assert.ok(cur_frm.doc.taxes_and_charges=='TEST In State GST - FT', "Tax details correct");
// get tax account head details
assert.ok(cur_frm.doc.taxes[0].account_head=='CGST - '+frappe.get_abbr(frappe.defaults.get_default('Company')), " Account Head abbr correct");
// get batch number
assert.ok(cur_frm.doc.items[0].batch_no=='TEST-BATCH-001', " Batch Details correct");
// grand_total Calculated
assert.ok(cur_frm.doc.grand_total==218, "Grad Total correct");
},
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

28
erpnext/accounts/doctype/sales_taxes_and_charges_template/test_sales_taxes_and_charges_template.js

@ -1,28 +0,0 @@
QUnit.module('Sales Taxes and Charges Template');
QUnit.test("test sales taxes and charges template", function(assert) {
assert.expect(2);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Sales Taxes and Charges Template', [
{title: "TEST In State GST"},
{taxes:[
[
{charge_type:"On Net Total"},
{account_head:"CGST - "+frappe.get_abbr(frappe.defaults.get_default("Company")) }
],
[
{charge_type:"On Net Total"},
{account_head:"SGST - "+frappe.get_abbr(frappe.defaults.get_default("Company")) }
]
]}
]);
},
() => {
assert.ok(cur_frm.doc.title=='TEST In State GST');
assert.ok(cur_frm.doc.name=='TEST In State GST - FT');
},
() => done()
]);
});

36
erpnext/accounts/doctype/shipping_rule/test_shipping_rule.js

@ -1,36 +0,0 @@
QUnit.module('Shipping Rule');
QUnit.test("test Shipping Rule", function(assert) {
assert.expect(1);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make("Shipping Rule", [
{label: "Next Day Shipping"},
{shipping_rule_type: "Selling"},
{calculate_based_on: 'Net Total'},
{conditions:[
[
{from_value:1},
{to_value:200},
{shipping_amount:100}
],
[
{from_value:201},
{to_value:2000},
{shipping_amount:50}
],
]},
{countries:[
[
{country:'India'}
]
]},
{account:'Accounts Payable - '+frappe.get_abbr(frappe.defaults.get_default("Company"))},
{cost_center:'Main - '+frappe.get_abbr(frappe.defaults.get_default("Company"))}
]);
},
() => {assert.ok(cur_frm.doc.name=='Next Day Shipping');},
() => done()
]);
});

36
erpnext/accounts/doctype/shipping_rule/tests/test_shipping_rule_for_buying.js

@ -1,36 +0,0 @@
QUnit.module('Shipping Rule');
QUnit.test("test Shipping Rule", function(assert) {
assert.expect(1);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make("Shipping Rule", [
{label: "Two Day Shipping"},
{shipping_rule_type: "Buying"},
{fixed_shipping_amount: 0},
{conditions:[
[
{from_value:1},
{to_value:200},
{shipping_amount:100}
],
[
{from_value:201},
{to_value:3000},
{shipping_amount:200}
],
]},
{countries:[
[
{country:'India'}
]
]},
{account:'Accounts Payable - '+frappe.get_abbr(frappe.defaults.get_default("Company"))},
{cost_center:'Main - '+frappe.get_abbr(frappe.defaults.get_default("Company"))}
]);
},
() => {assert.ok(cur_frm.doc.name=='Two Day Shipping');},
() => done()
]);
});

32
erpnext/accounts/doctype/subscription/test_subscription.js

@ -1,32 +0,0 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Subscription", function (assert) {
assert.expect(4);
let done = assert.async();
frappe.run_serially([
// insert a new Subscription
() => {
return frappe.tests.make("Subscription", [
{reference_doctype: 'Sales Invoice'},
{reference_document: 'SINV-00004'},
{start_date: frappe.datetime.month_start()},
{end_date: frappe.datetime.month_end()},
{frequency: 'Weekly'}
]);
},
() => cur_frm.savesubmit(),
() => frappe.timeout(1),
() => frappe.click_button('Yes'),
() => frappe.timeout(2),
() => {
assert.ok(cur_frm.doc.frequency.includes("Weekly"), "Set frequency Weekly");
assert.ok(cur_frm.doc.reference_doctype.includes("Sales Invoice"), "Set base doctype Sales Invoice");
assert.equal(cur_frm.doc.docstatus, 1, "Submitted subscription");
assert.equal(cur_frm.doc.next_schedule_date,
frappe.datetime.add_days(frappe.datetime.get_today(), 7), "Set schedule date");
},
() => done()
]);
});

2
erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py

@ -370,7 +370,7 @@ def get_account_heads(root_type, companies, filters):
accounts = get_accounts(root_type, filters)
if not accounts:
return None, None
return None, None, None
accounts = update_parent_account_names(accounts)

116
erpnext/agriculture/doctype/crop/test_crop.js

@ -1,116 +0,0 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Crop", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(2);
frappe.run_serially([
// insert a new Item
() => frappe.tests.make('Item', [
// values to be set
{item_code: 'Basil Seeds'},
{item_name: 'Basil Seeds'},
{item_group: 'Seed'}
]),
// insert a new Item
() => frappe.tests.make('Item', [
// values to be set
{item_code: 'Twigs'},
{item_name: 'Twigs'},
{item_group: 'By-product'}
]),
// insert a new Item
() => frappe.tests.make('Item', [
// values to be set
{item_code: 'Basil Leaves'},
{item_name: 'Basil Leaves'},
{item_group: 'Produce'}
]),
// insert a new Crop
() => frappe.tests.make('Crop', [
// values to be set
{title: 'Basil from seed'},
{crop_name: 'Basil'},
{scientific_name: 'Ocimum basilicum'},
{materials_required: [
[
{item_code: 'Basil Seeds'},
{qty: '25'},
{uom: 'Nos'},
{rate: '1'}
],
[
{item_code: 'Urea'},
{qty: '5'},
{uom: 'Kg'},
{rate: '10'}
]
]},
{byproducts: [
[
{item_code: 'Twigs'},
{qty: '25'},
{uom: 'Nos'},
{rate: '1'}
]
]},
{produce: [
[
{item_code: 'Basil Leaves'},
{qty: '100'},
{uom: 'Nos'},
{rate: '1'}
]
]},
{agriculture_task: [
[
{task_name: "Plough the field"},
{start_day: 1},
{end_day: 1},
{holiday_management: "Ignore holidays"}
],
[
{task_name: "Plant the seeds"},
{start_day: 2},
{end_day: 3},
{holiday_management: "Ignore holidays"}
],
[
{task_name: "Water the field"},
{start_day: 4},
{end_day: 4},
{holiday_management: "Ignore holidays"}
],
[
{task_name: "First harvest"},
{start_day: 8},
{end_day: 8},
{holiday_management: "Ignore holidays"}
],
[
{task_name: "Add the fertilizer"},
{start_day: 10},
{end_day: 12},
{holiday_management: "Ignore holidays"}
],
[
{task_name: "Final cut"},
{start_day: 15},
{end_day: 15},
{holiday_management: "Ignore holidays"}
]
]}
]),
// agriculture task list
() => {
assert.equal(cur_frm.doc.name, 'Basil from seed');
assert.equal(cur_frm.doc.period, 15);
},
() => done()
]);
});

34
erpnext/agriculture/doctype/crop_cycle/test_crop_cycle.js

@ -1,34 +0,0 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Crop Cycle", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially([
// insert a new Crop Cycle
() => frappe.tests.make('Crop Cycle', [
// values to be set
{title: 'Basil from seed 2017'},
{detected_disease: [
[
{start_date: '2017-11-21'},
{disease: 'Aphids'}
]
]},
{linked_land_unit: [
[
{land_unit: 'Basil Farm'}
]
]},
{crop: 'Basil from seed'},
{start_date: '2017-11-11'},
{cycle_type: 'Less than a year'}
]),
() => assert.equal(cur_frm.doc.name, 'Basil from seed 2017'),
() => done()
]);
});

38
erpnext/agriculture/doctype/disease/test_disease.js

@ -1,38 +0,0 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Disease", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially([
// insert a new Disease
() => frappe.tests.make('Disease', [
// values to be set
{common_name: 'Aphids'},
{scientific_name: 'Aphidoidea'},
{treatment_task: [
[
{task_name: "Survey and find the aphid locations"},
{start_day: 1},
{end_day: 2},
{holiday_management: "Ignore holidays"}
],
[
{task_name: "Apply Pesticides"},
{start_day: 3},
{end_day: 3},
{holiday_management: "Ignore holidays"}
]
]}
]),
() => {
assert.equal(cur_frm.doc.treatment_period, 3);
},
() => done()
]);
});

31
erpnext/agriculture/doctype/fertilizer/test_fertilizer.js

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

26
erpnext/agriculture/doctype/soil_texture/test_soil_texture.js

@ -1,26 +0,0 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Soil Texture", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(2);
frappe.run_serially([
// insert a new Soil Texture
() => frappe.tests.make('Soil Texture', [
// values to be set
{location: '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[72.882185,19.076395]}}]}'},
{collection_datetime: '2017-11-08'},
{clay_composition: 20},
{sand_composition: 30}
]),
() => {
assert.equal(cur_frm.doc.silt_composition, 50);
assert.equal(cur_frm.doc.soil_type, 'Silt Loam');
},
() => done()
]);
});

25
erpnext/agriculture/doctype/water_analysis/test_water_analysis.js

@ -1,25 +0,0 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Water Analysis", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially([
// insert a new Water Analysis
() => frappe.tests.make('Water Analysis', [
// values to be set
{location: '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[72.882185,19.076395]}}]}'},
{collection_datetime: '2017-11-08 18:43:57'},
{laboratory_testing_datetime: '2017-11-10 18:43:57'}
]),
() => {
assert.equal(cur_frm.doc.result_datetime, '2017-11-10 18:43:57');
},
() => done()
]);
});

80
erpnext/buying/doctype/purchase_order/tests/test_purchase_order.js

@ -1,80 +0,0 @@
QUnit.module('Buying');
QUnit.test("test: purchase order", function(assert) {
assert.expect(16);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Purchase Order', [
{supplier: 'Test Supplier'},
{is_subcontracted: 'No'},
{currency: 'INR'},
{items: [
[
{"item_code": 'Test Product 4'},
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(), 2)},
{"expected_delivery_date": frappe.datetime.add_days(frappe.datetime.now_date(), 5)},
{"qty": 5},
{"uom": 'Unit'},
{"rate": 100},
{"warehouse": 'Stores - '+frappe.get_abbr(frappe.defaults.get_default("Company"))}
],
[
{"item_code": 'Test Product 1'},
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(), 1)},
{"expected_delivery_date": frappe.datetime.add_days(frappe.datetime.now_date(), 5)},
{"qty": 2},
{"uom": 'Unit'},
{"rate": 100},
{"warehouse": 'Stores - '+frappe.get_abbr(frappe.defaults.get_default("Company"))}
]
]},
{tc_name: 'Test Term 1'},
{terms: 'This is a term.'}
]);
},
() => {
// Get supplier details
assert.ok(cur_frm.doc.supplier_name == 'Test Supplier', "Supplier name correct");
assert.ok(cur_frm.doc.schedule_date == frappe.datetime.add_days(frappe.datetime.now_date(), 1), "Schedule Date correct");
assert.ok(cur_frm.doc.contact_email == 'test@supplier.com', "Contact email correct");
// Get item details
assert.ok(cur_frm.doc.items[0].item_name == 'Test Product 4', "Item name correct");
assert.ok(cur_frm.doc.items[0].description == 'Test Product 4', "Description correct");
assert.ok(cur_frm.doc.items[0].qty == 5, "Quantity correct");
assert.ok(cur_frm.doc.items[0].schedule_date == frappe.datetime.add_days(frappe.datetime.now_date(), 2), "Schedule Date correct");
assert.ok(cur_frm.doc.items[1].item_name == 'Test Product 1', "Item name correct");
assert.ok(cur_frm.doc.items[1].description == 'Test Product 1', "Description correct");
assert.ok(cur_frm.doc.items[1].qty == 2, "Quantity correct");
assert.ok(cur_frm.doc.items[1].schedule_date == cur_frm.doc.schedule_date, "Schedule Date correct");
// Calculate total
assert.ok(cur_frm.doc.total == 700, "Total correct");
// Get terms
assert.ok(cur_frm.doc.terms == 'This is a term.', "Terms correct");
},
() => cur_frm.print_doc(),
() => frappe.timeout(2),
() => {
assert.ok($('.btn-print-print').is(':visible'), "Print Format Available");
assert.ok($('div > div:nth-child(5) > div > div > table > tbody > tr > td:nth-child(4) > div').text().includes('Test Product 4'), "Print Preview Works");
},
() => cur_frm.print_doc(),
() => frappe.timeout(1),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(1),
() => {
assert.ok(cur_frm.doc.status == 'To Receive and Bill', "Submitted successfully");
},
() => done()
]);
});

61
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_get_items.js

@ -1,61 +0,0 @@
QUnit.module('Buying');
QUnit.test("test: purchase order with get items", function(assert) {
assert.expect(4);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Purchase Order', [
{supplier: 'Test Supplier'},
{is_subcontracted: 'No'},
{buying_price_list: 'Test-Buying-USD'},
{currency: 'USD'},
{items: [
[
{"item_code": 'Test Product 4'},
{"qty": 5},
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(), 1)},
{"expected_delivery_date": frappe.datetime.add_days(frappe.datetime.now_date(), 5)},
{"warehouse": 'Stores - '+frappe.get_abbr(frappe.defaults.get_default("Company"))}
]
]}
]);
},
() => {
assert.ok(cur_frm.doc.supplier_name == 'Test Supplier', "Supplier name correct");
},
() => frappe.timeout(0.3),
() => frappe.click_button('Get items from'),
() => frappe.timeout(0.3),
() => frappe.click_link('Product Bundle'),
() => frappe.timeout(0.5),
() => cur_dialog.set_value('product_bundle', 'Computer'),
() => frappe.click_button('Get Items'),
() => frappe.timeout(1),
// Check if items are fetched from Product Bundle
() => {
assert.ok(cur_frm.doc.items[1].item_name == 'CPU', "Product bundle item 1 correct");
assert.ok(cur_frm.doc.items[2].item_name == 'Screen', "Product bundle item 2 correct");
assert.ok(cur_frm.doc.items[3].item_name == 'Keyboard', "Product bundle item 3 correct");
},
() => cur_frm.doc.items[1].warehouse = 'Stores - '+frappe.get_abbr(frappe.defaults.get_default("Company")),
() => cur_frm.doc.items[2].warehouse = 'Stores - '+frappe.get_abbr(frappe.defaults.get_default("Company")),
() => cur_frm.doc.items[3].warehouse = 'Stores - '+frappe.get_abbr(frappe.defaults.get_default("Company")),
() => cur_frm.save(),
() => frappe.timeout(1),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

74
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_receipt.js

@ -1,74 +0,0 @@
QUnit.module('Buying');
QUnit.test("test: purchase order receipt", function(assert) {
assert.expect(5);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Purchase Order', [
{supplier: 'Test Supplier'},
{is_subcontracted: 'No'},
{buying_price_list: 'Test-Buying-USD'},
{currency: 'USD'},
{items: [
[
{"item_code": 'Test Product 1'},
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(), 1)},
{"expected_delivery_date": frappe.datetime.add_days(frappe.datetime.now_date(), 5)},
{"qty": 5},
{"uom": 'Unit'},
{"rate": 100},
{"warehouse": 'Stores - '+frappe.get_abbr(frappe.defaults.get_default("Company"))}
]
]},
]);
},
() => {
// Check supplier and item details
assert.ok(cur_frm.doc.supplier_name == 'Test Supplier', "Supplier name correct");
assert.ok(cur_frm.doc.items[0].item_name == 'Test Product 1', "Item name correct");
assert.ok(cur_frm.doc.items[0].description == 'Test Product 1', "Description correct");
assert.ok(cur_frm.doc.items[0].qty == 5, "Quantity correct");
},
() => frappe.timeout(1),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(1.5),
() => frappe.click_button('Close'),
() => frappe.timeout(0.3),
// Make Purchase Receipt
() => frappe.click_button('Make'),
() => frappe.timeout(0.3),
() => frappe.click_link('Receipt'),
() => frappe.timeout(2),
() => cur_frm.save(),
// Save and submit Purchase Receipt
() => frappe.timeout(1),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(1),
// View Purchase order in Stock Ledger
() => frappe.click_button('View'),
() => frappe.timeout(0.3),
() => frappe.click_link('Stock Ledger'),
() => frappe.timeout(2),
() => {
assert.ok($('div.slick-cell.l2.r2 > a').text().includes('Test Product 1')
&& $('div.slick-cell.l9.r9 > div').text().includes(5), "Stock ledger entry correct");
},
() => done()
]);
});

47
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_discount_on_grand_total.js

@ -1,47 +0,0 @@
QUnit.module('Buying');
QUnit.test("test: purchase order with discount on grand total", function(assert) {
assert.expect(4);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Purchase Order', [
{supplier: 'Test Supplier'},
{is_subcontracted: 'No'},
{buying_price_list: 'Test-Buying-EUR'},
{currency: 'EUR'},
{items: [
[
{"item_code": 'Test Product 4'},
{"qty": 5},
{"uom": 'Unit'},
{"rate": 500 },
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(), 1)},
{"expected_delivery_date": frappe.datetime.add_days(frappe.datetime.now_date(), 5)},
{"warehouse": 'Stores - '+frappe.get_abbr(frappe.defaults.get_default("Company"))}
]
]},
{apply_discount_on: 'Grand Total'},
{additional_discount_percentage: 10}
]);
},
() => frappe.timeout(1),
() => {
assert.ok(cur_frm.doc.supplier_name == 'Test Supplier', "Supplier name correct");
assert.ok(cur_frm.doc.items[0].rate == 500, "Rate correct");
// Calculate total
assert.ok(cur_frm.doc.total == 2500, "Total correct");
// Calculate grand total after discount
assert.ok(cur_frm.doc.grand_total == 2250, "Grand total correct");
},
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

44
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_item_wise_discount.js

@ -1,44 +0,0 @@
QUnit.module('Buying');
QUnit.test("test: purchase order with item wise discount", function(assert) {
assert.expect(4);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Purchase Order', [
{supplier: 'Test Supplier'},
{is_subcontracted: 'No'},
{buying_price_list: 'Test-Buying-EUR'},
{currency: 'EUR'},
{items: [
[
{"item_code": 'Test Product 4'},
{"qty": 5},
{"uom": 'Unit'},
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(), 1)},
{"expected_delivery_date": frappe.datetime.add_days(frappe.datetime.now_date(), 5)},
{"warehouse": 'Stores - '+frappe.get_abbr(frappe.defaults.get_default("Company"))},
{"discount_percentage": 20}
]
]}
]);
},
() => frappe.timeout(1),
() => {
assert.ok(cur_frm.doc.supplier_name == 'Test Supplier', "Supplier name correct");
assert.ok(cur_frm.doc.items[0].discount_percentage == 20, "Discount correct");
// Calculate totals after discount
assert.ok(cur_frm.doc.total == 2000, "Total correct");
assert.ok(cur_frm.doc.grand_total == 2000, "Grand total correct");
},
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

39
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_multi_uom.js

@ -1,39 +0,0 @@
QUnit.module('Buying');
QUnit.test("test: purchase order with multi UOM", function(assert) {
assert.expect(3);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Purchase Order', [
{supplier: 'Test Supplier'},
{is_subcontracted: 'No'},
{items: [
[
{"item_code": 'Test Product 4'},
{"qty": 5},
{"uom": 'Unit'},
{"rate": 100},
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(), 1)},
{"expected_delivery_date": frappe.datetime.add_days(frappe.datetime.now_date(), 5)},
{"warehouse": 'Stores - '+frappe.get_abbr(frappe.defaults.get_default("Company"))}
]
]}
]);
},
() => {
assert.ok(cur_frm.doc.supplier_name == 'Test Supplier', "Supplier name correct");
assert.ok(cur_frm.doc.items[0].item_name == 'Test Product 4', "Item name correct");
assert.ok(cur_frm.doc.items[0].uom == 'Unit', "Multi UOM correct");
},
() => frappe.timeout(1),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

43
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_shipping_rule.js

@ -1,43 +0,0 @@
QUnit.module('Buying');
QUnit.test("test: purchase order with shipping rule", function(assert) {
assert.expect(3);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Purchase Order', [
{supplier: 'Test Supplier'},
{is_subcontracted: 'No'},
{buying_price_list: 'Test-Buying-USD'},
{currency: 'USD'},
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(), 1)},
{items: [
[
{"item_code": 'Test Product 4'},
{"qty": 5},
{"uom": 'Unit'},
{"rate": 500 },
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(), 1)},
{"expected_delivery_date": frappe.datetime.add_days(frappe.datetime.now_date(), 5)},
{"warehouse": 'Stores - '+frappe.get_abbr(frappe.defaults.get_default("Company"))}
]
]},
{shipping_rule:'Two Day Shipping'}
]);
},
() => {
// Check grand total
assert.ok(cur_frm.doc.total_taxes_and_charges == 200, "Taxes and charges correct");
assert.ok(cur_frm.doc.grand_total == 2700, "Grand total correct");
},
() => frappe.timeout(0.3),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

44
erpnext/buying/doctype/purchase_order/tests/test_purchase_order_with_taxes_and_charges.js

@ -1,44 +0,0 @@
QUnit.module('Buying');
QUnit.test("test: purchase order with taxes and charges", function(assert) {
assert.expect(3);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Purchase Order', [
{supplier: 'Test Supplier'},
{is_subcontracted: 'No'},
{buying_price_list: 'Test-Buying-USD'},
{currency: 'USD'},
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(), 1)},
{items: [
[
{"item_code": 'Test Product 4'},
{"qty": 5},
{"uom": 'Unit'},
{"rate": 500 },
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(), 1)},
{"expected_delivery_date": frappe.datetime.add_days(frappe.datetime.now_date(), 5)},
{"warehouse": 'Stores - '+frappe.get_abbr(frappe.defaults.get_default("Company"))}
]
]},
{taxes_and_charges: 'TEST In State GST - FT'}
]);
},
() => {
// Check taxes and calculate grand total
assert.ok(cur_frm.doc.taxes[1].account_head=='SGST - '+frappe.get_abbr(frappe.defaults.get_default('Company')), "Account Head abbr correct");
assert.ok(cur_frm.doc.total_taxes_and_charges == 225, "Taxes and charges correct");
assert.ok(cur_frm.doc.grand_total == 2725, "Grand total correct");
},
() => frappe.timeout(0.3),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

76
erpnext/buying/doctype/request_for_quotation/tests/test_request_for_quotation.js

@ -1,76 +0,0 @@
QUnit.module('Buying');
QUnit.test("test: request_for_quotation", function(assert) {
assert.expect(14);
let done = assert.async();
let date;
frappe.run_serially([
() => {
date = frappe.datetime.add_days(frappe.datetime.now_date(), 10);
return frappe.tests.make('Request for Quotation', [
{transaction_date: date},
{suppliers: [
[
{"supplier": 'Test Supplier'},
{"email_id": 'test@supplier.com'}
]
]},
{items: [
[
{"item_code": 'Test Product 4'},
{"qty": 5},
{"schedule_date": frappe.datetime.add_days(frappe.datetime.now_date(),20)},
{"warehouse": 'All Warehouses - '+frappe.get_abbr(frappe.defaults.get_default("Company"))}
]
]},
{message_for_supplier: 'Please supply the specified items at the best possible rates'},
{tc_name: 'Test Term 1'}
]);
},
() => frappe.timeout(3),
() => {
assert.ok(cur_frm.doc.transaction_date == date, "Date correct");
assert.ok(cur_frm.doc.company == cur_frm.doc.company, "Company correct");
assert.ok(cur_frm.doc.suppliers[0].supplier_name == 'Test Supplier', "Supplier name correct");
assert.ok(cur_frm.doc.suppliers[0].contact == 'Contact 3-Test Supplier', "Contact correct");
assert.ok(cur_frm.doc.suppliers[0].email_id == 'test@supplier.com', "Email id correct");
assert.ok(cur_frm.doc.items[0].item_name == 'Test Product 4', "Item Name correct");
assert.ok(cur_frm.doc.items[0].warehouse == 'All Warehouses - '+frappe.get_abbr(frappe.defaults.get_default("Company")), "Warehouse correct");
assert.ok(cur_frm.doc.message_for_supplier == 'Please supply the specified items at the best possible rates', "Reply correct");
assert.ok(cur_frm.doc.tc_name == 'Test Term 1', "Term name correct");
},
() => frappe.timeout(3),
() => cur_frm.print_doc(),
() => frappe.timeout(1),
() => {
assert.ok($('.btn-print-print').is(':visible'), "Print Format Available");
assert.ok($('.section-break+ .section-break .column-break:nth-child(1) .value').text().includes("Test Product 4"), "Print Preview Works");
},
() => cur_frm.print_doc(),
() => frappe.timeout(1),
() => frappe.click_button('Get items from'),
() => frappe.timeout(0.3),
() => frappe.click_link('Material Request'),
() => frappe.timeout(1),
() => frappe.click_button('Get Items'),
() => frappe.timeout(1),
() => {
assert.ok(cur_frm.doc.items[1].item_name == 'Test Product 1', "Getting items from material requests work");
},
() => cur_frm.save(),
() => frappe.timeout(1),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(1),
() => {
assert.ok(cur_frm.doc.docstatus == 1, "Quotation request submitted");
},
() => frappe.click_button('Send Supplier Emails'),
() => frappe.timeout(6),
() => {
assert.ok($('div.modal.fade.in > div.modal-dialog > div > div.modal-body.ui-front > div.msgprint').text().includes("Email sent to supplier Test Supplier"), "Send emails working");
},
() => frappe.click_button('Close'),
() => done()
]);
});

128
erpnext/buying/doctype/request_for_quotation/tests/test_request_for_quotation_for_status.js

@ -1,128 +0,0 @@
QUnit.module('buying');
QUnit.test("Test: Request for Quotation", function (assert) {
assert.expect(5);
let done = assert.async();
let rfq_name = "";
frappe.run_serially([
// Go to RFQ list
() => frappe.set_route("List", "Request for Quotation"),
// Create a new RFQ
() => frappe.new_doc("Request for Quotation"),
() => frappe.timeout(1),
() => cur_frm.set_value("transaction_date", "04-04-2017"),
() => cur_frm.set_value("company", "For Testing"),
// Add Suppliers
() => {
cur_frm.fields_dict.suppliers.grid.grid_rows[0].toggle_view();
},
() => frappe.timeout(1),
() => {
cur_frm.fields_dict.suppliers.grid.grid_rows[0].doc.supplier = "_Test Supplier";
frappe.click_check('Send Email');
cur_frm.cur_grid.frm.script_manager.trigger('supplier');
},
() => frappe.timeout(1),
() => {
cur_frm.cur_grid.toggle_view();
},
() => frappe.timeout(1),
() => frappe.click_button('Add Row',0),
() => frappe.timeout(1),
() => {
cur_frm.fields_dict.suppliers.grid.grid_rows[1].toggle_view();
},
() => frappe.timeout(1),
() => {
cur_frm.fields_dict.suppliers.grid.grid_rows[1].doc.supplier = "_Test Supplier 1";
frappe.click_check('Send Email');
cur_frm.cur_grid.frm.script_manager.trigger('supplier');
},
() => frappe.timeout(1),
() => {
cur_frm.cur_grid.toggle_view();
},
() => frappe.timeout(1),
// Add Item
() => {
cur_frm.fields_dict.items.grid.grid_rows[0].toggle_view();
},
() => frappe.timeout(1),
() => {
cur_frm.fields_dict.items.grid.grid_rows[0].doc.item_code = "_Test Item";
frappe.set_control('item_code',"_Test Item");
frappe.set_control('qty',5);
frappe.set_control('schedule_date', "05-05-2017");
cur_frm.cur_grid.frm.script_manager.trigger('supplier');
},
() => frappe.timeout(2),
() => {
cur_frm.cur_grid.toggle_view();
},
() => frappe.timeout(2),
() => {
cur_frm.fields_dict.items.grid.grid_rows[0].doc.warehouse = "_Test Warehouse - FT";
},
() => frappe.click_button('Save'),
() => frappe.timeout(1),
() => frappe.click_button('Submit'),
() => frappe.timeout(1),
() => frappe.click_button('Yes'),
() => frappe.timeout(1),
() => frappe.click_button('Menu'),
() => frappe.timeout(1),
() => frappe.click_link('Reload'),
() => frappe.timeout(1),
() => {
assert.equal(cur_frm.doc.docstatus, 1);
rfq_name = cur_frm.doc.name;
assert.ok(cur_frm.fields_dict.suppliers.grid.grid_rows[0].doc.quote_status == "Pending");
assert.ok(cur_frm.fields_dict.suppliers.grid.grid_rows[1].doc.quote_status == "Pending");
},
() => {
cur_frm.fields_dict.suppliers.grid.grid_rows[0].toggle_view();
},
() => frappe.timeout(1),
() => frappe.timeout(1),
() => {
cur_frm.cur_grid.toggle_view();
},
() => frappe.click_button('Update'),
() => frappe.timeout(1),
() => frappe.click_button('Supplier Quotation'),
() => frappe.timeout(1),
() => frappe.click_link('Make'),
() => frappe.timeout(1),
() => {
frappe.set_control('supplier',"_Test Supplier 1");
},
() => frappe.timeout(1),
() => frappe.click_button('Make Supplier Quotation'),
() => frappe.timeout(1),
() => cur_frm.set_value("company", "For Testing"),
() => cur_frm.fields_dict.items.grid.grid_rows[0].doc.rate = 4.99,
() => frappe.timeout(1),
() => frappe.click_button('Save'),
() => frappe.timeout(1),
() => frappe.click_button('Submit'),
() => frappe.timeout(1),
() => frappe.click_button('Yes'),
() => frappe.timeout(1),
() => frappe.set_route("List", "Request for Quotation"),
() => frappe.timeout(2),
() => frappe.set_route("List", "Request for Quotation"),
() => frappe.timeout(2),
() => frappe.click_link(rfq_name),
() => frappe.timeout(1),
() => frappe.click_button('Menu'),
() => frappe.timeout(1),
() => frappe.click_link('Reload'),
() => frappe.timeout(1),
() => {
assert.ok(cur_frm.fields_dict.suppliers.grid.grid_rows[1].doc.quote_status == "Received");
},
() => done()
]);
});

77
erpnext/buying/doctype/supplier/test_supplier.js

@ -1,77 +0,0 @@
QUnit.module('Buying');
QUnit.test("test: supplier", function(assert) {
assert.expect(6);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Supplier', [
{supplier_name: 'Test Supplier'},
{supplier_group: 'Hardware'},
{country: 'India'},
{default_currency: 'INR'},
{accounts: [
[
{'company': "For Testing"},
{'account': "Creditors - FT"}
]]
}
]);
},
() => frappe.timeout(1),
() => frappe.click_button('New Address'),
() => {
return frappe.tests.set_form_values(cur_frm, [
{address_title:"Test3"},
{address_type: "Billing"},
{address_line1: "Billing Street 3"},
{city: "Billing City 3"},
]);
},
() => cur_frm.save(),
() => frappe.timeout(2),
() => frappe.click_button('New Address'),
() => {
return frappe.tests.set_form_values(cur_frm, [
{address_title:"Test3"},
{address_type: "Shipping"},
{address_line1: "Shipping Street 3"},
{city: "Shipping City 3"},
]);
},
() => cur_frm.save(),
() => frappe.timeout(2),
() => frappe.click_button('New Address'),
() => {
return frappe.tests.set_form_values(cur_frm, [
{address_title:"Test3"},
{address_type: "Warehouse"},
{address_line1: "Warehouse Street 3"},
{city: "Warehouse City 3"},
]);
},
() => cur_frm.save(),
() => frappe.timeout(2),
() => frappe.click_button('New Contact'),
() => {
return frappe.tests.set_form_values(cur_frm, [
{first_name: "Contact 3"},
{email_id: "test@supplier.com"}
]);
},
() => cur_frm.save(),
() => frappe.timeout(1),
() => frappe.set_route('Form', 'Supplier', 'Test Supplier'),
() => frappe.timeout(0.3),
() => {
assert.ok(cur_frm.doc.supplier_name == 'Test Supplier', "Name correct");
assert.ok(cur_frm.doc.supplier_group == 'Hardware', "Type correct");
assert.ok(cur_frm.doc.default_currency == 'INR', "Currency correct");
assert.ok(cur_frm.doc.accounts[0].account == 'Creditors - '+frappe.get_abbr('For Testing'), " Account Head abbr correct");
assert.ok($('.address-box:nth-child(3) p').text().includes('Shipping City 3'), "Address correct");
assert.ok($('.col-sm-6+ .col-sm-6 .h6').text().includes('Contact 3'), "Contact correct");
},
() => done()
]);
});

74
erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation.js

@ -1,74 +0,0 @@
QUnit.module('Buying');
QUnit.test("test: supplier quotation", function(assert) {
assert.expect(11);
let done = assert.async();
let date;
frappe.run_serially([
() => {
date = frappe.datetime.add_days(frappe.datetime.now_date(), 10);
return frappe.tests.make('Supplier Quotation', [
{supplier: 'Test Supplier'},
{transaction_date: date},
{currency: 'INR'},
{items: [
[
{"item_code": 'Test Product 4'},
{"qty": 5},
{"uom": 'Unit'},
{"rate": 200},
{"warehouse": 'All Warehouses - '+frappe.get_abbr(frappe.defaults.get_default("Company"))}
]
]},
{apply_discount_on: 'Grand Total'},
{additional_discount_percentage: 10},
{tc_name: 'Test Term 1'},
{terms: 'This is a term'}
]);
},
() => frappe.timeout(3),
() => {
// Get Supplier details
assert.ok(cur_frm.doc.supplier == 'Test Supplier', "Supplier correct");
assert.ok(cur_frm.doc.company == cur_frm.doc.company, "Company correct");
// Get Contact details
assert.ok(cur_frm.doc.contact_person == 'Contact 3-Test Supplier', "Conatct correct");
assert.ok(cur_frm.doc.contact_email == 'test@supplier.com', "Email correct");
// Get uom
assert.ok(cur_frm.doc.items[0].uom == 'Unit', "Multi uom correct");
assert.ok(cur_frm.doc.total == 1000, "Total correct");
// Calculate total after discount
assert.ok(cur_frm.doc.grand_total == 900, "Grand total correct");
// Get terms
assert.ok(cur_frm.doc.tc_name == 'Test Term 1', "Terms correct");
},
() => cur_frm.print_doc(),
() => frappe.timeout(2),
() => {
assert.ok($('.btn-print-print').is(':visible'), "Print Format Available");
assert.ok($("table > tbody > tr > td:nth-child(3) > div").text().includes("Test Product 4"), "Print Preview Works As Expected");
},
() => cur_frm.print_doc(),
() => frappe.timeout(1),
() => frappe.click_button('Get items from'),
() => frappe.timeout(0.3),
() => frappe.click_link('Material Request'),
() => frappe.timeout(0.3),
() => frappe.click_button('Get Items'),
() => frappe.timeout(1),
() => {
// Get item from Material Requests
assert.ok(cur_frm.doc.items[1].item_name == 'Test Product 1', "Getting items from material requests work");
},
() => cur_frm.save(),
() => frappe.timeout(1),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

34
erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_item_wise_discount.js

@ -1,34 +0,0 @@
QUnit.module('Buying');
QUnit.test("test: supplier quotation with item wise discount", function(assert){
assert.expect(2);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Supplier Quotation', [
{supplier: 'Test Supplier'},
{company: 'For Testing'},
{items: [
[
{"item_code": 'Test Product 4'},
{"qty": 5},
{"uom": 'Unit'},
{"warehouse": 'All Warehouses - FT'},
{'discount_percentage': 10},
]
]}
]);
},
() => {
assert.ok(cur_frm.doc.total == 900, "Total correct");
assert.ok(cur_frm.doc.grand_total == 900, "Grand total correct");
},
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

37
erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation_for_taxes_and_charges.js

@ -1,37 +0,0 @@
QUnit.module('Buying');
QUnit.test("test: supplier quotation with taxes and charges", function(assert) {
assert.expect(3);
let done = assert.async();
let supplier_quotation_name;
frappe.run_serially([
() => {
return frappe.tests.make('Supplier Quotation', [
{supplier: 'Test Supplier'},
{items: [
[
{"item_code": 'Test Product 4'},
{"qty": 5},
{"rate": 100},
{"warehouse": 'Stores - '+frappe.get_abbr(frappe.defaults.get_default('Company'))},
]
]},
{taxes_and_charges:'TEST In State GST - FT'},
]);
},
() => {supplier_quotation_name = cur_frm.doc.name;},
() => {
assert.ok(cur_frm.doc.taxes[0].account_head=='CGST - '+frappe.get_abbr(frappe.defaults.get_default('Company')), " Account Head abbr correct");
assert.ok(cur_frm.doc.total_taxes_and_charges == 45, "Taxes and charges correct");
assert.ok(cur_frm.doc.grand_total == 545, "Grand total correct");
},
() => cur_frm.save(),
() => frappe.timeout(0.3),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.3),
() => done()
]);
});

17
erpnext/crm/doctype/lead/lead.py

@ -8,7 +8,6 @@ from frappe.contacts.address_and_contact import load_address_and_contact
from frappe.email.inbox import link_communication_to_document
from frappe.model.mapper import get_mapped_doc
from frappe.utils import (
cint,
comma_and,
cstr,
get_link_to_form,
@ -39,11 +38,7 @@ class Lead(SellingController):
self.check_email_id_is_unique()
self.validate_email_id()
self.validate_contact_date()
self._prev = frappe._dict({
"contact_date": frappe.db.get_value("Lead", self.name, "contact_date") if (not cint(self.is_new())) else None,
"ends_on": frappe.db.get_value("Lead", self.name, "ends_on") if (not cint(self.is_new())) else None,
"contact_by": frappe.db.get_value("Lead", self.name, "contact_by") if (not cint(self.is_new())) else None,
})
self.set_prev()
def set_full_name(self):
if self.first_name:
@ -75,6 +70,16 @@ class Lead(SellingController):
self.add_calendar_event()
self.update_prospects()
def set_prev(self):
if self.is_new():
self._prev = frappe._dict({
"contact_date": None,
"ends_on": None,
"contact_by": None
})
else:
self._prev = frappe.db.get_value("Lead", self.name, ["contact_date", "ends_on", "contact_by"], as_dict=1)
def before_insert(self):
self.contact_doc = self.create_contact()

11
erpnext/crm/doctype/lead/test_lead.py

@ -23,6 +23,17 @@ class TestLead(unittest.TestCase):
customer.customer_group = "_Test Customer Group"
customer.insert()
#check whether lead contact is carried forward to the customer.
contact = frappe.db.get_value('Dynamic Link', {
"parenttype": "Contact",
"link_doctype": "Lead",
"link_name": customer.lead_name,
}, "parent")
if contact:
contact_doc = frappe.get_doc("Contact", contact)
self.assertEqual(contact_doc.has_link(customer.doctype, customer.name), True)
def test_make_customer_from_organization(self):
from erpnext.crm.doctype.lead.lead import make_customer

43
erpnext/crm/doctype/lead/tests/test_lead_individual.js

@ -1,43 +0,0 @@
QUnit.module("sales");
QUnit.test("test: lead", function (assert) {
assert.expect(4);
let done = assert.async();
let lead_name = frappe.utils.get_random(10);
frappe.run_serially([
// test lead creation
() => frappe.set_route("List", "Lead"),
() => frappe.new_doc("Lead"),
() => frappe.timeout(1),
() => cur_frm.set_value("lead_name", lead_name),
() => cur_frm.save(),
() => frappe.timeout(1),
() => {
assert.ok(cur_frm.doc.lead_name.includes(lead_name),
'name correctly set');
frappe.lead_name = cur_frm.doc.name;
},
// create address and contact
() => frappe.click_link('Address & Contact'),
() => frappe.click_button('New Address'),
() => frappe.timeout(1),
() => frappe.set_control('address_line1', 'Gateway'),
() => frappe.set_control('city', 'Mumbai'),
() => cur_frm.save(),
() => frappe.timeout(3),
() => assert.equal(frappe.get_route()[1], 'Lead',
'back to lead form'),
() => frappe.click_link('Address & Contact'),
() => assert.ok($('.address-box').text().includes('Mumbai'),
'city is seen in address box'),
// make opportunity
() => frappe.click_button('Make'),
() => frappe.click_link('Opportunity'),
() => frappe.timeout(2),
() => assert.equal(cur_frm.doc.lead, frappe.lead_name,
'lead name correctly mapped'),
() => done()
]);
});

55
erpnext/crm/doctype/lead/tests/test_lead_organization.js

@ -1,55 +0,0 @@
QUnit.module("sales");
QUnit.test("test: lead", function (assert) {
assert.expect(5);
let done = assert.async();
let lead_name = frappe.utils.get_random(10);
frappe.run_serially([
// test lead creation
() => frappe.set_route("List", "Lead"),
() => frappe.new_doc("Lead"),
() => frappe.timeout(1),
() => cur_frm.set_value("company_name", lead_name),
() => cur_frm.save(),
() => frappe.timeout(1),
() => {
assert.ok(cur_frm.doc.lead_name.includes(lead_name),
'name correctly set');
frappe.lead_name = cur_frm.doc.name;
},
// create address and contact
() => frappe.click_link('Address & Contact'),
() => frappe.click_button('New Address'),
() => frappe.timeout(1),
() => frappe.set_control('address_line1', 'Gateway'),
() => frappe.set_control('city', 'Mumbai'),
() => cur_frm.save(),
() => frappe.timeout(3),
() => assert.equal(frappe.get_route()[1], 'Lead',
'back to lead form'),
() => frappe.click_link('Address & Contact'),
() => assert.ok($('.address-box').text().includes('Mumbai'),
'city is seen in address box'),
() => frappe.click_button('New Contact'),
() => frappe.timeout(1),
() => frappe.set_control('first_name', 'John'),
() => frappe.set_control('last_name', 'Doe'),
() => cur_frm.save(),
() => frappe.timeout(3),
() => frappe.set_route('Form', 'Lead', cur_frm.doc.links[0].link_name),
() => frappe.timeout(1),
() => frappe.click_link('Address & Contact'),
() => assert.ok($('.address-box').text().includes('John'),
'contact is seen in contact box'),
// make customer
() => frappe.click_button('Make'),
() => frappe.click_link('Customer'),
() => frappe.timeout(2),
() => assert.equal(cur_frm.doc.lead_name, frappe.lead_name,
'lead name correctly mapped'),
() => done()
]);
});

56
erpnext/crm/doctype/opportunity/test_opportunity.js

@ -1,56 +0,0 @@
QUnit.test("test: opportunity", function (assert) {
assert.expect(8);
let done = assert.async();
frappe.run_serially([
() => frappe.set_route('List', 'Opportunity'),
() => frappe.timeout(1),
() => frappe.click_button('New'),
() => frappe.timeout(1),
() => cur_frm.set_value('opportunity_from', 'Customer'),
() => cur_frm.set_value('customer', 'Test Customer 1'),
// check items
() => cur_frm.set_value('with_items', 1),
() => frappe.tests.set_grid_values(cur_frm, 'items', [
[
{item_code:'Test Product 1'},
{qty: 4}
]
]),
() => cur_frm.save(),
() => frappe.timeout(1),
() => {
assert.notOk(cur_frm.is_new(), 'saved');
frappe.opportunity_name = cur_frm.doc.name;
},
// close and re-open
() => frappe.click_button('Close'),
() => frappe.timeout(1),
() => assert.equal(cur_frm.doc.status, 'Closed',
'closed'),
() => frappe.click_button('Reopen'),
() => assert.equal(cur_frm.doc.status, 'Open',
'reopened'),
() => frappe.timeout(1),
// make quotation
() => frappe.click_button('Make'),
() => frappe.click_link('Quotation', 1),
() => frappe.timeout(2),
() => {
assert.equal(frappe.get_route()[1], 'Quotation',
'made quotation');
assert.equal(cur_frm.doc.customer, 'Test Customer 1',
'customer set in quotation');
assert.equal(cur_frm.doc.items[0].item_code, 'Test Product 1',
'item set in quotation');
assert.equal(cur_frm.doc.items[0].qty, 4,
'qty set in quotation');
assert.equal(cur_frm.doc.items[0].prevdoc_docname, frappe.opportunity_name,
'opportunity set in quotation');
},
() => done()
]);
});

24
erpnext/education/doctype/academic_term/test_academic_term.js

@ -1,24 +0,0 @@
// Testing Setup Module in Education
QUnit.module('education');
QUnit.test('Test: Academic Term', function(assert){
assert.expect(4);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Academic Term', [
{academic_year: '2016-17'},
{term_name: "Semester 1"},
{term_start_date: '2016-07-20'},
{term_end_date:'2017-06-20'},
]);
},
() => {
assert.ok(cur_frm.doc.academic_year=='2016-17');
assert.ok(cur_frm.doc.term_name=='Semester 1');
assert.ok(cur_frm.doc.term_start_date=='2016-07-20');
assert.ok(cur_frm.doc.term_end_date=='2017-06-20');
},
() => done()
]);
});

16
erpnext/education/doctype/assessment_criteria/test_assessment_criteria.js

@ -1,16 +0,0 @@
// Education Assessment module
QUnit.module('education');
QUnit.test('Test: Assessment Criteria', function(assert){
assert.expect(0);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Assessment Criteria', [
{assessment_criteria: 'Pass'},
{assessment_criteria_group: 'Reservation'}
]);
},
() => done()
]);
});

15
erpnext/education/doctype/assessment_criteria_group/test_assessment_criteria_group.js

@ -1,15 +0,0 @@
// Education Assessment module
QUnit.module('education');
QUnit.test('Test: Assessment Criteria Group', function(assert){
assert.expect(0);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Assessment Criteria Group', [
{assessment_criteria_group: 'Reservation'}
]);
},
() => done()
]);
});

65
erpnext/education/doctype/assessment_group/test_assessment_group.js

@ -1,65 +0,0 @@
// Education Assessment module
QUnit.module('education');
QUnit.test('Test: Assessment Group', function(assert){
assert.expect(4);
let done = assert.async();
frappe.run_serially([
() => frappe.set_route('Tree', 'Assessment Group'),
// Checking adding child without selecting any Node
() => frappe.tests.click_button('New'),
() => frappe.timeout(0.2),
() => {assert.equal($(`.msgprint`).text(), "Select a group node first.", "Error message success");},
() => frappe.tests.click_button('Close'),
() => frappe.timeout(0.2),
// Creating child nodes
() => frappe.tests.click_link('All Assessment Groups'),
() => frappe.map_group.make('Assessment-group-1'),
() => frappe.map_group.make('Assessment-group-4', "All Assessment Groups", 1),
() => frappe.tests.click_link('Assessment-group-4'),
() => frappe.map_group.make('Assessment-group-5', "Assessment-group-3", 0),
// Checking Edit button
() => frappe.timeout(0.5),
() => frappe.tests.click_link('Assessment-group-1'),
() => frappe.tests.click_button('Edit'),
() => frappe.timeout(0.5),
() => {assert.deepEqual(frappe.get_route(), ["Form", "Assessment Group", "Assessment-group-1"], "Edit route checks");},
// Deleting child Node
() => frappe.set_route('Tree', 'Assessment Group'),
() => frappe.timeout(0.5),
() => frappe.tests.click_link('Assessment-group-1'),
() => frappe.tests.click_button('Delete'),
() => frappe.timeout(0.5),
() => frappe.tests.click_button('Yes'),
// Checking Collapse and Expand button
() => frappe.timeout(2),
() => frappe.tests.click_link('Assessment-group-4'),
() => frappe.click_button('Collapse'),
() => frappe.tests.click_link('All Assessment Groups'),
() => frappe.click_button('Collapse'),
() => {assert.ok($('.opened').size() == 0, 'Collapsed');},
() => frappe.click_button('Expand'),
() => {assert.ok($('.opened').size() > 0, 'Expanded');},
() => done()
]);
});
frappe.map_group = {
make:function(assessment_group_name, parent_assessment_group = 'All Assessment Groups', is_group = 0){
return frappe.run_serially([
() => frappe.click_button('Add Child'),
() => frappe.timeout(0.2),
() => cur_dialog.set_value('is_group', is_group),
() => cur_dialog.set_value('assessment_group_name', assessment_group_name),
() => cur_dialog.set_value('parent_assessment_group', parent_assessment_group),
() => frappe.click_button('Create New'),
]);
}
};

54
erpnext/education/doctype/assessment_plan/test_assessment_plan.js

@ -1,54 +0,0 @@
// Testing Assessment Module in education
QUnit.module('education');
QUnit.test('Test: Assessment Plan', function(assert){
assert.expect(6);
let done = assert.async();
let room_name, instructor_name, assessment_name;
frappe.run_serially([
() => frappe.db.get_value('Room', {'room_name': 'Room 1'}, 'name'),
(room) => {room_name = room.message.name;}, // Fetching Room name
() => frappe.db.get_value('Instructor', {'instructor_name': 'Instructor 1'}, 'name'),
(instructor) => {instructor_name = instructor.message.name;}, // Fetching Instructor name
() => {
return frappe.tests.make('Assessment Plan', [
{assessment_name: "Test-Mid-Term"},
{assessment_group: 'Assessment-group-5'},
{maximum_assessment_score: 100},
{student_group: 'test-course-wise-group-2'},
{course: 'Test_Sub'},
{grading_scale: 'GTU'},
{schedule_date: frappe.datetime.nowdate()},
{room: room_name},
{examiner: instructor_name},
{supervisor: instructor_name},
{from_time: "12:30:00"},
{to_time: "2:30:00"}
]);
},
() => {
assessment_name = cur_frm.doc.name; // Storing the name of current Assessment Plan
assert.equal(cur_frm.doc.assessment_criteria[0].assessment_criteria, 'Pass', 'Assessment Criteria auto-filled correctly');
assert.equal(cur_frm.doc.assessment_criteria[0].maximum_score, 100, 'Maximum score correctly set');
}, // Checking if the table was auto-filled upon selecting appropriate fields
() => frappe.timeout(1),
() => frappe.tests.click_button('Submit'),
() => frappe.timeout(0.5),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.5),
() => {assert.equal(cur_frm.doc.docstatus, 1, "Assessment Plan submitted successfully");},
() => frappe.click_button('Assessment Result'), // Checking out Assessment Result button option
() => frappe.timeout(0.5),
() => {
assert.deepEqual(frappe.get_route(), ["Form", "Assessment Result Tool"], 'Assessment Result properly linked');
assert.equal(cur_frm.doc.assessment_plan, assessment_name, 'Assessment correctly set');
assert.equal(cur_frm.doc.student_group, 'test-course-wise-group-2', 'Course for Assessment correctly set');
},
() => done()
]);
});

73
erpnext/education/doctype/assessment_result/test_assessment_result.js

@ -1,73 +0,0 @@
// Education Assessment module
QUnit.module('education');
QUnit.test('Test: Assessment Result', function(assert){
assert.expect(25);
let done = assert.async();
let student_list = [];
let assessment_name;
let tasks = []
frappe.run_serially([
// Saving Assessment Plan name
() => frappe.db.get_value('Assessment Plan', {'assessment_name': 'Test-Mid-Term'}, 'name'),
(assessment_plan) => {assessment_name = assessment_plan.message.name;},
// Fetching list of Student for which Result is supposed to be set
() => frappe.set_route('Form', 'Assessment Plan', assessment_name),
() => frappe.timeout(1),
() => frappe.tests.click_button('Assessment Result'),
() => frappe.timeout(1),
() => cur_frm.refresh(),
() => frappe.timeout(1),
() => {
$("tbody tr").each( function(i, input){
student_list.push($(input).data().student);
});
},
// Looping through each student in the list and setting up their score
() => {
student_list.forEach(index => {
tasks.push(
() => frappe.set_route('List', 'Assessment Result', 'List'),
() => frappe.timeout(0.5),
() => frappe.tests.click_button('New'),
() => frappe.timeout(0.5),
() => cur_frm.set_value('student', index),
() => cur_frm.set_value('assessment_plan', assessment_name),
() => frappe.timeout(0.2),
() => cur_frm.doc.details[0].score = (39 + (15 * student_list.indexOf(index))),
() => cur_frm.save(),
() => frappe.timeout(0.5),
() => frappe.db.get_value('Assessment Plan', {'name': 'ASP00001'}, ['grading_scale', 'maximum_assessment_score']),
(assessment_plan) => {
assert.equal(cur_frm.doc.grading_scale, assessment_plan.message.grading_scale, 'Grading scale correctly fetched');
assert.equal(cur_frm.doc.maximum_score, assessment_plan.message.maximum_assessment_score, 'Maximum score correctly fetched');
frappe.call({
method: "erpnext.education.api.get_grade",
args: {
"grading_scale": assessment_plan.message.grading_scale,
"percentage": cur_frm.doc.total_score
},
callback: function(r){
assert.equal(cur_frm.doc.grade, r.message, "Grade correctly calculated");
}
});
},
() => frappe.tests.click_button('Submit'),
() => frappe.timeout(0.5),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.5),
() => {assert.equal();},
() => {assert.equal(cur_frm.doc.docstatus, 1, "Submitted successfully");},
);
});
return frappe.run_serially(tasks);
},
() => done()
]);
});

29
erpnext/education/doctype/assessment_result_tool/test_assessment_result_tool.js

@ -1,29 +0,0 @@
// Education Assessment module
QUnit.module('education');
QUnit.test('Test: Assessment Result Tool', function(assert){
assert.expect(1);
let done = assert.async();
let i, count = 0, assessment_name;
frappe.run_serially([
// Saving Assessment Plan name
() => frappe.db.get_value('Assessment Plan', {'assessment_name': 'Test-Mid-Term'}, 'name'),
(assessment_plan) => {assessment_name = assessment_plan.message.name;},
() => frappe.set_route('Form', 'Assessment Plan', assessment_name),
() => frappe.timeout(1),
() => frappe.tests.click_button('Assessment Result'),
() => frappe.timeout(1),
() => cur_frm.refresh(),
() => frappe.timeout(1),
() => {
for(i = 2; i < $('tbody tr').size() * 4; i = (i + 4)){
if(($(`tbody td:eq("${i}")`) != "") && ($(`tbody td:eq("${i+1}")`) != ""))
count++;
}
assert.equal($('tbody tr').size(), count, 'All grades correctly displayed');
},
() => done()
]);
});

36
erpnext/education/doctype/course/test_course.js

@ -1,36 +0,0 @@
// Testing Setup Module in education
QUnit.module('education');
QUnit.test('test course', function(assert) {
assert.expect(8);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Course', [
{course_name: 'Test_Subject'},
{course_code: 'Test_Sub'},
{department: 'Test Department'},
{course_abbreviation: 'Test_Sub'},
{course_intro: 'Test Subject Intro'},
{default_grading_scale: 'GTU'},
{assessment_criteria: [
[
{assessment_criteria: 'Pass'},
{weightage: 100}
]
]}
]);
},
() => {
assert.ok(cur_frm.doc.course_name == 'Test_Subject', 'Course name correctly set');
assert.ok(cur_frm.doc.course_code == 'Test_Sub', 'Course code correctly set');
assert.ok(cur_frm.doc.department == 'Test Department', 'Department selected correctly');
assert.ok(cur_frm.doc.course_abbreviation == 'Test_Sub');
assert.ok(cur_frm.doc.course_intro == 'Test Subject Intro');
assert.ok(cur_frm.doc.default_grading_scale == 'GTU', 'Grading scale selected correctly');
assert.ok(cur_frm.doc.assessment_criteria[0].assessment_criteria == 'Pass', 'Assessment criteria selected correctly');
assert.ok(cur_frm.doc.assessment_criteria[0].weightage == '100');
},
() => done()
]);
});

31
erpnext/education/doctype/education_settings/test_education_settings.js

@ -1,31 +0,0 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
// Testing Setup Module in Education
QUnit.module('education');
QUnit.test("test: Education Settings", function (assert) {
let done = assert.async();
assert.expect(3);
frappe.run_serially([
() => frappe.set_route("List", "Education Settings"),
() => frappe.timeout(0.4),
() => {
return frappe.tests.set_form_values(cur_frm, [
{current_academic_year: '2016-17'},
{current_academic_term: '2016-17 (Semester 1)'},
{attendance_freeze_date: '2016-07-20'}
]);
},
() => {
cur_frm.save();
assert.ok(cur_frm.doc.current_academic_year=="2016-17");
assert.ok(cur_frm.doc.current_academic_term=="2016-17 (Semester 1)");
assert.ok(cur_frm.doc.attendance_freeze_date=="2016-07-20");
},
() => done()
]);
});

31
erpnext/education/doctype/fees/test_fees.js

@ -1,31 +0,0 @@
/* eslint-disable */
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Fees", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially('Fees', [
// insert a new Fees
() => {
return frappe.tests.make('Fees', [
{student: 'STUD00001'},
{due_date: frappe.datetime.get_today()},
{fee_structure: 'FS00001'}
]);
},
() => {
assert.equal(cur_frm.doc.grand_total===cur_frm.doc.outstanding_amount);
},
() => frappe.timeout(0.3),
() => cur_frm.save(),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => done()
]);
});

102
erpnext/education/doctype/grading_scale/test_grading_scale.js

@ -1,102 +0,0 @@
// Education Assessment module
QUnit.module('education');
QUnit.test('Test: Grading Scale', function(assert){
assert.expect(3);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Grading Scale', [
{grading_scale_name: 'GTU'},
{description: 'The score will be set according to 100 based system.'},
{intervals: [
[
{grade_code: 'AA'},
{threshold: '95'},
{grade_description: 'First Class + Distinction'}
],
[
{grade_code: 'AB'},
{threshold: '90'},
{grade_description: 'First Class'}
],
[
{grade_code: 'BB'},
{threshold: '80'},
{grade_description: 'Distinction'}
],
[
{grade_code: 'BC'},
{threshold: '70'},
{grade_description: 'Second Class'}
],
[
{grade_code: 'CC'},
{threshold: '60'},
{grade_description: 'Third Class'}
],
[
{grade_code: 'CD'},
{threshold: '50'},
{grade_description: 'Average'}
],
[
{grade_code: 'DD'},
{threshold: '40'},
{grade_description: 'Pass'}
],
[
{grade_code: 'FF'},
{threshold: '0'},
{grade_description: 'Fail'}
],
]}
]);
},
() => {
return frappe.tests.make('Grading Scale', [
{grading_scale_name: 'GTU-2'},
{description: 'The score will be set according to 100 based system.'},
{intervals: [
[
{grade_code: 'AA'},
{threshold: '90'},
{grade_description: 'Distinction'}
],
[
{grade_code: 'FF'},
{threshold: '0'},
{grade_description: 'Fail'}
]
]}
]);
},
() => {
let grading_scale = ['GTU', 'GTU-2'];
let tasks = [];
grading_scale.forEach(index => {
tasks.push(
() => frappe.set_route('Form', 'Grading Scale', index),
() => frappe.timeout(0.5),
() => frappe.tests.click_button('Submit'),
() => frappe.timeout(0.5),
() => frappe.tests.click_button('Yes'),
() => {assert.equal(cur_frm.doc.docstatus, 1, 'Submitted successfully');}
);
});
return frappe.run_serially(tasks);
},
() => frappe.timeout(1),
() => frappe.set_route('Form', 'Grading Scale','GTU-2'),
() => frappe.timeout(0.5),
() => frappe.tests.click_button('Cancel'),
() => frappe.timeout(0.5),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.5),
() => {assert.equal(cur_frm.doc.docstatus, 2, 'Cancelled successfully');},
() => done()
]);
});

34
erpnext/education/doctype/guardian/test_guardian.js

@ -1,34 +0,0 @@
// Testing Student Module in education
QUnit.module('education');
QUnit.test('Test: Guardian', function(assert){
assert.expect(9);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Guardian', [
{guardian_name: 'Test Guardian'},
{email_address: 'guardian@testmail.com'},
{mobile_number: 9898980000},
{alternate_number: 8989890000},
{date_of_birth: '1982-07-22'},
{education: 'Testing'},
{occupation: 'Testing'},
{designation: 'Testing'},
{work_address: 'Testing address'}
]);
},
() => {
assert.ok(cur_frm.doc.guardian_name == 'Test Guardian');
assert.ok(cur_frm.doc.email_address == 'guardian@testmail.com');
assert.ok(cur_frm.doc.mobile_number == 9898980000);
assert.ok(cur_frm.doc.alternate_number == 8989890000);
assert.ok(cur_frm.doc.date_of_birth == '1982-07-22');
assert.ok(cur_frm.doc.education == 'Testing');
assert.ok(cur_frm.doc.occupation == 'Testing');
assert.ok(cur_frm.doc.designation == 'Testing');
assert.ok(cur_frm.doc.work_address == 'Testing address');
},
() => done()
]);
});

20
erpnext/education/doctype/instructor/test_instructor.js

@ -1,20 +0,0 @@
// Testing Setup Module in education
QUnit.module('education');
QUnit.test('Test: Instructor', function(assert){
assert.expect(2);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make("Instructor", [
{instructor_name: 'Instructor 1'},
{department: 'Test Department'}
]);
},
() => {
assert.ok(cur_frm.doc.instructor_name == 'Instructor 1');
assert.ok(cur_frm.doc.department = 'Test Department');
},
() => done()
]);
});

34
erpnext/education/doctype/program/test_program.js

@ -1,34 +0,0 @@
// Testing Setup Module in education
QUnit.module('education');
QUnit.test('Test: Program', function(assert){
assert.expect(6);
let done = assert.async();
let fee_structure_code;
frappe.run_serially([
() => {
return frappe.tests.make('Program', [
{program_name: 'Standard Test'},
{program_code: 'Standard Test'},
{department: 'Test Department'},
{program_abbreviation: 'Standard Test'},
{courses: [
[
{course: 'Test_Sub'},
{required: true}
]
]}
]);
},
() => {
assert.ok(cur_frm.doc.program_name == 'Standard Test');
assert.ok(cur_frm.doc.program_code == 'Standard Test');
assert.ok(cur_frm.doc.department == 'Test Department');
assert.ok(cur_frm.doc.program_abbreviation == 'Standard Test');
assert.ok(cur_frm.doc.courses[0].course == 'Test_Sub');
assert.ok(cur_frm.doc.courses[0].required == true);
},
() => done()
]);
});

22
erpnext/education/doctype/room/test_room.js

@ -1,22 +0,0 @@
// Testing Setup Module in Education
QUnit.module('education');
QUnit.test('Test: Room', function(assert){
assert.expect(3);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Room', [
{room_name: 'Room 1'},
{room_number: '1'},
{seating_capacity: '60'},
]);
},
() => {
assert.ok(cur_frm.doc.room_name == 'Room 1');
assert.ok(cur_frm.doc.room_number = '1');
assert.ok(cur_frm.doc.seating_capacity = '60');
},
() => done()
]);
});

40
erpnext/education/doctype/student_admission/test_student_admission.js

@ -1,40 +0,0 @@
// Testing Admission Module in Education
QUnit.module('education');
QUnit.test('Test: Student Admission', function(assert) {
assert.expect(10);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Student Admission', [
{academic_year: '2016-17'},
{admission_start_date: '2016-04-20'},
{admission_end_date: '2016-05-31'},
{title: '2016-17 Admissions'},
{enable_admission_application: 1},
{introduction: 'Test intro'},
{program_details: [
[
{'program': 'Standard Test'},
{'application_fee': 1000},
{'applicant_naming_series': 'AP'},
]
]}
]);
},
() => cur_frm.save(),
() => {
assert.ok(cur_frm.doc.academic_year == '2016-17');
assert.ok(cur_frm.doc.admission_start_date == '2016-04-20');
assert.ok(cur_frm.doc.admission_end_date == '2016-05-31');
assert.ok(cur_frm.doc.title == '2016-17 Admissions');
assert.ok(cur_frm.doc.enable_admission_application == 1);
assert.ok(cur_frm.doc.introduction == 'Test intro');
assert.ok(cur_frm.doc.program_details[0].program == 'Standard Test', 'Program correctly selected');
assert.ok(cur_frm.doc.program_details[0].application_fee == 1000);
assert.ok(cur_frm.doc.program_details[0].applicant_naming_series == 'AP');
assert.ok(cur_frm.doc.route == 'admissions/2016-17-Admissions', "Route successfully set");
},
() => done()
]);
});

95
erpnext/education/doctype/student_applicant/tests/test_student_applicant.js

@ -1,95 +0,0 @@
// Testing Admission module in Education
QUnit.module('education');
QUnit.test('Test: Student Applicant', function(assert){
assert.expect(24);
let done = assert.async();
let guradian_auto_code;
let guardian_name;
frappe.run_serially([
() => frappe.set_route('List', 'Guardian'),
() => frappe.timeout(0.5),
() => {$(`a:contains("Test Guardian"):visible`)[0].click();},
() => frappe.timeout(1),
() => {
guardian_name = cur_frm.doc.guardian_name;
guradian_auto_code = frappe.get_route()[2];
},
// Testing data entry for Student Applicant
() => {
return frappe.tests.make('Student Applicant',[
{first_name: 'Fname'},
{middle_name: 'Mname'},
{last_name: 'Lname'},
{program: 'Standard Test'},
{student_admission: '2016-17 Admissions'},
{academic_year: '2016-17'},
{date_of_birth: '1995-07-20'},
{student_email_id: 'test@testmail.com'},
{gender: 'Male'},
{student_mobile_number: '9898980000'},
{blood_group: 'O+'},
{address_line_1: 'Test appt, Test Society,'},
{address_line_2: 'Test district, Test city.'},
{city: 'Test'},
{state: 'Test'},
{pincode: '400086'}
]);
},
// Entry in Guardian child table
() => $('a:contains("Guardian Details"):visible').click(),
() => $('.btn:contains("Add Row"):visible').click(),
() => {
cur_frm.get_field("guardians").grid.grid_rows[0].doc.guardian = guradian_auto_code;
cur_frm.get_field("guardians").grid.grid_rows[0].doc.relation = "Father";
cur_frm.get_field("guardians").grid.grid_rows[0].doc.guardian_name = guardian_name;
$('a:contains("Guardian Details"):visible').click();
},
// Entry in Sibling child table
() => $('a:contains("Sibling Details"):visible').click(),
() => $('.btn:contains("Add Row"):visible').click(),
() => {
cur_frm.get_field("siblings").grid.grid_rows[0].doc.full_name = "Test Name";
cur_frm.get_field("siblings").grid.grid_rows[0].doc.gender = "Male";
cur_frm.get_field("siblings").grid.grid_rows[0].doc.institution = "Test Institution";
cur_frm.get_field("siblings").grid.grid_rows[0].doc.program = "Test Program";
cur_frm.get_field("siblings").grid.grid_rows[0].doc.date_of_birth = "1995-07-20";
$('span.hidden-xs.octicon.octicon-triangle-up').click();
cur_frm.save();
},
() => {
assert.ok(cur_frm.doc.first_name == 'Fname');
assert.ok(cur_frm.doc.middle_name == 'Mname');
assert.ok(cur_frm.doc.last_name == 'Lname');
assert.ok(cur_frm.doc.program == 'Standard Test', 'Program selected correctly');
assert.ok(cur_frm.doc.student_admission == '2016-17 Admissions', 'Student Admission entry correctly selected');
assert.ok(cur_frm.doc.academic_year == '2016-17');
assert.ok(cur_frm.doc.date_of_birth == '1995-07-20');
assert.ok(cur_frm.doc.student_email_id == 'test@testmail.com');
assert.ok(cur_frm.doc.gender == 'Male');
assert.ok(cur_frm.doc.student_mobile_number == '9898980000');
assert.ok(cur_frm.doc.blood_group == 'O+');
assert.ok(cur_frm.doc.address_line_1 == 'Test appt, Test Society,');
assert.ok(cur_frm.doc.address_line_2 == 'Test district, Test city.');
assert.ok(cur_frm.doc.city == 'Test');
assert.ok(cur_frm.doc.state == 'Test');
assert.ok(cur_frm.doc.pincode == '400086');
},
() => frappe.timeout(1),
() => $('a:contains("Guardian Details"):visible').click(),
() => {
assert.ok(cur_frm.get_field("guardians").grid.grid_rows[0].doc.guardian == guradian_auto_code, 'Guardian correctly selected from dropdown');
assert.ok(cur_frm.get_field("guardians").grid.grid_rows[0].doc.relation == 'Father');
assert.ok(cur_frm.get_field("guardians").grid.grid_rows[0].doc.guardian_name == guardian_name, 'Guardian name was correctly retrieved');
},
() => $('a:contains("Sibling Details"):visible').click(),
() => {
assert.ok(cur_frm.get_field("siblings").grid.grid_rows[0].doc.full_name == 'Test Name');
assert.ok(cur_frm.get_field("siblings").grid.grid_rows[0].doc.gender == 'Male');
assert.ok(cur_frm.get_field("siblings").grid.grid_rows[0].doc.institution == 'Test Institution');
assert.ok(cur_frm.get_field("siblings").grid.grid_rows[0].doc.program == 'Test Program');
assert.ok(cur_frm.get_field("siblings").grid.grid_rows[0].doc.date_of_birth == '1995-07-20');
},
() => done()
]);
});

87
erpnext/education/doctype/student_applicant/tests/test_student_applicant_dummy_data.js

@ -1,87 +0,0 @@
QUnit.module('Admission');
QUnit.test('Make Students', function(assert){
assert.expect(0);
let done = assert.async();
let tasks = [];
let loop = [1,2,3,4];
let fname;
frappe.run_serially([
// Making School House to be used in this test and later
() => frappe.set_route('Form', 'School House/New School House'),
() => frappe.timeout(0.5),
() => cur_frm.doc.house_name = 'Test_house',
() => cur_frm.save(),
// Making Student Applicant entries
() => {
loop.forEach(index => {
tasks.push(() => {
fname = "Fname" + index;
return frappe.tests.make('Student Applicant', [
{first_name: fname},
{middle_name: "Mname"},
{last_name: "Lname"},
{program: "Standard Test"},
{student_admission: "2016-17 Admissions"},
{date_of_birth: '1995-08-20'},
{student_email_id: ('test' + (index+3) + '@testmail.com')},
{gender: 'Male'},
{student_mobile_number: (9898980000 + index)},
{blood_group: 'O+'},
{address_line_1: 'Test appt, Test Society,'},
{address_line_2: 'Test district, Test city.'},
{city: 'Test'},
{state: 'Test'},
{pincode: '395007'}
]);
});
});
return frappe.run_serially(tasks);
},
// Using Program Enrollment Tool to enroll all dummy student at once
() => frappe.set_route('Form', 'Program Enrollment Tool'),
() => {
cur_frm.set_value("get_students_from", "Student Applicants");
cur_frm.set_value("academic_year", "2016-17");
cur_frm.set_value("program", "Standard Test");
},
() => frappe.tests.click_button("Get Students"),
() => frappe.timeout(1),
() => frappe.tests.click_button("Enroll Students"),
() => frappe.timeout(1.5),
() => frappe.tests.click_button("Close"),
// Submitting required data for each enrolled Student
() => {
tasks = [];
loop.forEach(index => {
tasks.push(
() => {fname = "Fname" + index + " Mname Lname";},
() => frappe.set_route('List', 'Program Enrollment/List'),
() => frappe.timeout(0.6),
() => frappe.tests.click_link(fname),
() => frappe.timeout(0.4),
() => {
cur_frm.set_value('program', 'Standard Test');
cur_frm.set_value('student_category', 'Reservation');
cur_frm.set_value('student_batch_name', 'A');
cur_frm.set_value('academic_year', '2016-17');
cur_frm.set_value('academic_term', '2016-17 (Semester 1)');
cur_frm.set_value('school_house', 'Test_house');
},
() => cur_frm.save(),
() => frappe.timeout(0.5),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.5)
);
});
return frappe.run_serially(tasks);
},
() => done()
]);
});

110
erpnext/education/doctype/student_applicant/tests/test_student_applicant_options.js

@ -1,110 +0,0 @@
// Testing Admission module in Education
QUnit.module('education');
QUnit.test('test student applicant', function(assert){
assert.expect(11);
let done = assert.async();
let testing_status;
frappe.run_serially([
() => frappe.set_route('List', 'Student Applicant'),
() => frappe.timeout(0.5),
() => {$(`a:contains("Fname Mname Lname"):visible`)[0].click();},
// Checking different options
// 1. Moving forward with Submit
() => frappe.timeout(0.5),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.5),
() => {
testing_status = $('span.indicator.orange').text();
assert.ok(testing_status.indexOf('Submit this document to confirm') == -1); // checking if submit has been successfull
},
// 2. Cancelling the Submit request
() => frappe.timeout(0.5),
() => frappe.tests.click_button('Cancel'),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.5),
() => {
testing_status = $('h1.editable-title').text();
assert.ok(testing_status.indexOf('Cancelled') != -1); // checking if cancel request has been successfull
},
// 3. Checking Amend option
() => frappe.timeout(0.5),
() => frappe.tests.click_button('Amend'),
() => cur_frm.doc.student_email_id = "test2@testmail.com", // updating email id since same id again is not allowed
() => cur_frm.save(),
() => frappe.timeout(0.5),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'), // Submitting again after amend
() => {
testing_status = $('span.indicator.orange').text();
assert.ok(testing_status.indexOf('Submit this document to confirm') == -1); // checking if submit has been successfull after amend
},
// Checking different Application status option
() => {
testing_status = $('h1.editable-title').text();
assert.ok(testing_status.indexOf('Applied') != -1); // checking if Applied has been successfull
},
() => cur_frm.set_value('application_status', "Rejected"), // Rejected Status
() => frappe.tests.click_button('Update'),
() => {
testing_status = $('h1.editable-title').text();
assert.ok(testing_status.indexOf('Rejected') != -1); // checking if Rejected has been successfull
},
() => cur_frm.set_value('application_status', "Admitted"), // Admitted Status
() => frappe.tests.click_button('Update'),
() => {
testing_status = $('h1.editable-title').text();
assert.ok(testing_status.indexOf('Admitted') != -1); // checking if Admitted has been successfull
},
() => cur_frm.set_value('application_status', "Approved"), // Approved Status
() => frappe.tests.click_button('Update'),
() => {
testing_status = $('h1.editable-title').text();
assert.ok(testing_status.indexOf('Approved') != -1); // checking if Approved has been successfull
},
// Clicking on Enroll button should add the applicant's entry in Student doctype, and take you to Program Enrollment page
() => frappe.timeout(0.5),
() => frappe.tests.click_button('Enroll'),
() => frappe.timeout(0.5),
() => {
assert.ok(frappe.get_route()[0] == 'Form'); // Checking if the current page is Program Enrollment page or not
assert.ok(frappe.get_route()[1] == 'Program Enrollment');
},
// Routing to Student List to check if the Applicant's entry has been made or not
() => frappe.timeout(0.5),
() => frappe.set_route('List', 'Student'),
() => frappe.timeout(0.5),
() => {$(`a:contains("Fname Mname Lname"):visible`)[0].click();},
() => frappe.timeout(0.5),
() => {assert.ok(($(`h1.editable-title`).text()).indexOf('Enabled') != -1, 'Student entry successfully created');}, // Checking if the Student entry has been enabled
// Enrolling the Student into a Program
() => {$('.form-documents .row:nth-child(1) .col-xs-6:nth-child(1) .octicon-plus').click();},
() => frappe.timeout(1),
() => cur_frm.set_value('program', 'Standard Test'),
() => frappe.timeout(1),
() => {
cur_frm.set_value('student_category', 'Reservation');
cur_frm.set_value('student_batch_name', 'A');
cur_frm.set_value('academic_year', '2016-17');
cur_frm.set_value('academic_term', '2016-17 (Semester 1)');
cur_frm.set_value('school_house', 'Test_house');
},
() => cur_frm.save(),
// Submitting Program Enrollment form for our Test Student
() => frappe.timeout(1),
() => frappe.tests.click_button('Submit'),
() => frappe.tests.click_button('Yes'),
() => {
assert.ok(cur_frm.doc.docstatus == 1, "Program enrollment successfully submitted");
},
() => done()
]);
});

31
erpnext/education/doctype/student_attendance/test_student_attendance.js

@ -1,31 +0,0 @@
// Testing Attendance Module in Education
QUnit.module('education');
QUnit.test('Test: Student Attendance', function(assert){
assert.expect(2);
let done = assert.async();
let student_code;
frappe.run_serially([
() => frappe.db.get_value('Student', {'student_email_id': 'test2@testmail.com'}, 'name'),
(student) => {student_code = student.message.name;}, // fetching student code from db
() => {
return frappe.tests.make('Student Attendance', [
{student: student_code},
{date: frappe.datetime.nowdate()},
{student_group: "test-batch-wise-group-2"},
{status: "Absent"}
]);
},
() => frappe.timeout(0.5),
() => {assert.equal(cur_frm.doc.status, "Absent", "Attendance correctly saved");},
() => frappe.timeout(0.5),
() => cur_frm.set_value("status", "Present"),
() => {assert.equal(cur_frm.doc.status, "Present", "Attendance correctly saved");},
() => done()
]);
});

85
erpnext/education/doctype/student_attendance_tool/test_student_attendance_tool.js

@ -1,85 +0,0 @@
// Testing Attendance Module in Education
QUnit.module('education');
QUnit.test('Test: Student Attendace Tool', function(assert){
assert.expect(10);
let done = assert.async();
let i, count = 0;
frappe.run_serially([
() => frappe.timeout(0.2),
() => frappe.set_route('Form', 'Student Attendance Tool'),
() => frappe.timeout(0.5),
() => {
if(cur_frm.doc.based_on == 'Student Group' || cur_frm.doc.based_on == 'Course Schedule'){
cur_frm.doc.based_on = 'Student Group';
assert.equal(1, 1, 'Attendance basis correctly set');
cur_frm.set_value("group_based_on", 'Batch');
cur_frm.set_value("student_group", "test-batch-wise-group");
cur_frm.set_value("date", frappe.datetime.nowdate());
}
},
() => frappe.timeout(0.5),
() => {
assert.equal($('input.students-check').size(), 5, "Student list based on batch correctly fetched");
assert.equal(frappe.datetime.nowdate(), cur_frm.doc.date, 'Current date correctly set');
cur_frm.set_value("student_group", "test-batch-wise-group-2");
assert.equal($('input.students-check').size(), 5, "Student list based on batch 2 correctly fetched");
cur_frm.set_value("group_based_on", 'Course');
cur_frm.set_value("student_group", "test-course-wise-group");
assert.equal($('input.students-check').size(), 5, "Student list based on course correctly fetched");
cur_frm.set_value("student_group", "test-course-wise-group-2");
assert.equal($('input.students-check').size(), 5, "Student list based on course 2 correctly fetched");
},
() => frappe.timeout(1),
() => frappe.tests.click_button('Check all'), // Marking all Student as checked
() => {
for(i = 0; i < $('input.students-check').size(); i++){
if($('input.students-check')[i].checked == true)
count++;
}
if(count == $('input.students-check').size())
assert.equal($('input.students-check').size(), count, "All students marked checked");
},
() => frappe.timeout(1),
() => frappe.tests.click_button('Uncheck all'), // Marking all Student as unchecked
() => {
count = 0;
for(i = 0; i < $('input.students-check').size(); i++){
if(!($('input.students-check')[i].checked))
count++;
}
if(count == $('input.students-check').size())
assert.equal($('input.students-check').size(), count, "All students marked checked");
},
() => frappe.timeout(1),
() => frappe.tests.click_button('Check all'),
() => frappe.tests.click_button('Mark Attendance'),
() => frappe.timeout(1),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(1),
() => {
assert.equal($('.msgprint').text(), "Attendance has been marked successfully.", "Attendance successfully marked");
frappe.tests.click_button('Close');
},
() => frappe.timeout(1),
() => frappe.set_route('List', 'Student Attendance/List'),
() => frappe.timeout(1),
() => {
assert.equal(cur_list.data.length, count, "Attendance list created");
},
() => done()
]);
});

19
erpnext/education/doctype/student_batch_name/test_student_batch_name.js

@ -1,19 +0,0 @@
// Testing Setup Module in Education
QUnit.module('education');
QUnit.test('Test: Student Batch Name', function(assert){
assert.expect(1);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Student Batch Name', [
{batch_name: 'A'}
]);
},
() => cur_frm.save(),
() => {
assert.ok(cur_frm.doc.batch_name=='A');
},
() => done()
]);
});

19
erpnext/education/doctype/student_category/test_student_category.js

@ -1,19 +0,0 @@
// Testing Setup Module in Education
QUnit.module('education');
QUnit.test('Test: Student Category', function(assert){
assert.expect(1);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Student Category', [
{category: 'Reservation'}
]);
},
() => cur_frm.save(),
() => {
assert.ok(cur_frm.doc.name=='Reservation');
},
() => done()
]);
});

56
erpnext/education/doctype/student_group/test_student_group.js

@ -1,56 +0,0 @@
// Testing Student Module in Education
QUnit.module('education');
QUnit.test('Test: Student Group', function(assert){
assert.expect(2);
let done = assert.async();
let group_based_on = ["test-batch-wise-group", "test-course-wise-group"];
let tasks = [];
frappe.run_serially([
// Creating a Batch and Course based group
() => {
return frappe.tests.make('Student Group', [
{academic_year: '2016-17'},
{academic_term: '2016-17 (Semester 1)'},
{program: "Standard Test"},
{group_based_on: 'Batch'},
{student_group_name: group_based_on[0]},
{max_strength: 10},
{batch: 'A'}
]);
},
() => {
return frappe.tests.make('Student Group', [
{academic_year: '2016-17'},
{academic_term: '2016-17 (Semester 1)'},
{program: "Standard Test"},
{group_based_on: 'Course'},
{student_group_name: group_based_on[1]},
{max_strength: 10},
{batch: 'A'},
{course: 'Test_Sub'},
]);
},
// Populating the created group with Students
() => {
tasks = [];
group_based_on.forEach(index => {
tasks.push(
() => frappe.timeout(0.5),
() => frappe.set_route("Form", ('Student Group/' + index)),
() => frappe.timeout(0.5),
() => frappe.tests.click_button('Get Students'),
() => frappe.timeout(1),
() => {
assert.equal(cur_frm.doc.students.length, 5, 'Successfully fetched list of students');
},
);
});
return frappe.run_serially(tasks);
},
() => done()
]);
});

84
erpnext/education/doctype/student_group_creation_tool/test_student_group_creation_tool.js

@ -1,84 +0,0 @@
QUnit.module('education');
QUnit.test('Test: Student Group Creation Tool', function(assert){
assert.expect(5);
let done = assert.async();
let instructor_code;
frappe.run_serially([
// Saving Instructor code beforehand
() => frappe.db.get_value('Instructor', {'instructor_name': 'Instructor 1'}, 'name'),
(instructor) => {instructor_code = instructor.message.name;},
// Setting up the creation tool to generate and save Student Group
() => frappe.set_route('Form', 'Student Group Creation Tool'),
() => frappe.timeout(0.5),
() => {
cur_frm.set_value("academic_year", "2016-17");
cur_frm.set_value("academic_term", "2016-17 (Semester 1)");
cur_frm.set_value("program", "Standard Test");
frappe.tests.click_button('Get Courses');
},
() => frappe.timeout(1),
() => {
let no_of_courses = $('input.grid-row-check.pull-left').size() - 1;
assert.equal(cur_frm.doc.courses.length, no_of_courses, 'Successfully created groups using the tool');
},
() => {
let d, grid, grid_row;
for(d = 0; d < cur_frm.doc.courses.length; d++)
{
grid = cur_frm.get_field("courses").grid;
grid_row = grid.get_row(d).toggle_view(true);
if(grid_row.doc.student_group_name == 'Standard Test/A/2016-17 (Semester 1)'){
grid_row.doc.max_strength = 10;
grid_row.doc.student_group_name = "test-batch-wise-group-2";
$(`.octicon.octicon-triangle-up`).click();
continue;
}
else if(grid_row.doc.student_group_name == 'Test_Sub/Standard Test/2016-17 (Semester 1)'){
grid_row.doc.max_strength = 10;
grid_row.doc.student_group_name = "test-course-wise-group-2";
$(`.octicon.octicon-triangle-up`).click();
continue;
}
}
},
// Generating Student Group
() => frappe.timeout(0.5),
() => frappe.tests.click_button("Create Student Groups"),
() => frappe.timeout(0.5),
() => frappe.tests.click_button("Close"),
// Goin to the generated group to set up student and instructor list
() => {
let group_name = ['Student Group/test-batch-wise-group-2', 'Student Group/test-course-wise-group-2'];
let tasks = [];
group_name.forEach(index => {
tasks.push(
() => frappe.timeout(1),
() => frappe.set_route("Form", index),
() => frappe.timeout(0.5),
() => {
assert.equal(cur_frm.doc.students.length, 5, 'Successfully fetched list of students');
},
() => frappe.timeout(0.5),
() => {
d = cur_frm.add_child('instructors');
d.instructor = instructor_code;
cur_frm.save();
},
() => {
assert.equal(cur_frm.doc.instructors.length, 1, 'Instructor detail stored successfully');
},
);
});
return frappe.run_serially(tasks);
},
() => done()
]);
});

69
erpnext/education/doctype/student_leave_application/test_student_leave_application.js

@ -1,69 +0,0 @@
// Testing Attendance Module in Education
QUnit.module('education');
QUnit.test('Test: Student Leave Application', function(assert){
assert.expect(4);
let done = assert.async();
let student_code;
let leave_code;
frappe.run_serially([
() => frappe.db.get_value('Student', {'student_email_id': 'test2@testmail.com'}, 'name'),
(student) => {student_code = student.message.name;}, // fetching student code from db
() => {
return frappe.tests.make('Student Leave Application', [
{student: student_code},
{from_date: '2017-08-02'},
{to_date: '2017-08-04'},
{mark_as_present: 0},
{reason: "Sick Leave."}
]);
},
() => frappe.tests.click_button('Submit'), // Submitting the leave application
() => frappe.timeout(0.7),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.7),
() => {
assert.equal(cur_frm.doc.docstatus, 1, "Submitted leave application");
leave_code = frappe.get_route()[2];
},
() => frappe.tests.click_button('Cancel'), // Cancelling the leave application
() => frappe.timeout(0.7),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(1),
() => {assert.equal(cur_frm.doc.docstatus, 2, "Cancelled leave application");},
() => frappe.tests.click_button('Amend'), // Amending the leave application
() => frappe.timeout(1),
() => {
cur_frm.doc.mark_as_present = 1;
cur_frm.save();
},
() => frappe.timeout(0.7),
() => frappe.tests.click_button('Submit'),
() => frappe.timeout(0.7),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.7),
() => {assert.equal(cur_frm.doc.amended_from, leave_code, "Amended successfully");},
() => frappe.timeout(0.5),
() => {
return frappe.tests.make('Student Leave Application', [
{student: student_code},
{from_date: '2017-08-07'},
{to_date: '2017-08-09'},
{mark_as_present: 0},
{reason: "Sick Leave."}
]);
},
() => frappe.tests.click_button('Submit'),
() => frappe.timeout(0.7),
() => frappe.tests.click_button('Yes'),
() => frappe.timeout(0.7),
() => {
assert.equal(cur_frm.doc.docstatus, 1, "Submitted leave application");
leave_code = frappe.get_route()[2];
},
() => done()
]);
});

35
erpnext/education/doctype/student_log/test_student_log.js

@ -1,35 +0,0 @@
// Testing Student Module in Education
QUnit.module('education');
QUnit.test('Test: Student Log', function(assert){
assert.expect(9);
let done = assert.async();
let student_code;
frappe.run_serially([
() => frappe.db.get_value('Student', {'student_email_id': 'test2@testmail.com'}, 'name'),
(student) => {student_code = student.message.name;},
() => {
return frappe.tests.make("Student Log", [
{student: student_code},
{academic_year: '2016-17'},
{academic_term: '2016-17 (Semester 1)'},
{program: "Standard Test"},
{date: '2017-07-31'},
{student_batch: 'A'},
{log: 'This is Test log.'}
]);
},
() => {
assert.equal(cur_frm.doc.student, student_code, 'Student code was fetched properly');
assert.equal(cur_frm.doc.student_name, 'Fname Mname Lname', 'Student name was correctly auto-fetched');
assert.equal(cur_frm.doc.type, 'General', 'Default type selected');
assert.equal(cur_frm.doc.academic_year, '2016-17');
assert.equal(cur_frm.doc.academic_term, '2016-17 (Semester 1)');
assert.equal(cur_frm.doc.program, 'Standard Test', 'Program correctly selected');
assert.equal(cur_frm.doc.student_batch, 'A');
assert.equal(cur_frm.doc.date, '2017-07-31');
assert.equal(cur_frm.doc.log, 'This is Test log.');
},
() => done()
]);
});

78
erpnext/erpnext_integrations/workspace/erpnext_integrations_settings/erpnext_integrations_settings.json

@ -1,78 +0,0 @@
{
"charts": [],
"content": "[{\"type\": \"header\", \"data\": {\"text\": \"Reports & Masters\", \"level\": 4, \"col\": 12}}, {\"type\": \"card\", \"data\": {\"card_name\": \"Integrations Settings\", \"col\": 4}}]",
"creation": "2020-07-31 10:38:54.021237",
"docstatus": 0,
"doctype": "Workspace",
"for_user": "",
"hide_custom": 0,
"icon": "setting",
"idx": 0,
"label": "ERPNext Integrations Settings",
"links": [
{
"hidden": 0,
"is_query_report": 0,
"label": "Integrations Settings",
"link_count": 0,
"onboard": 0,
"type": "Card Break"
},
{
"dependencies": "",
"hidden": 0,
"is_query_report": 0,
"label": "Woocommerce Settings",
"link_count": 0,
"link_to": "Woocommerce Settings",
"link_type": "DocType",
"onboard": 0,
"type": "Link"
},
{
"dependencies": "",
"hidden": 0,
"is_query_report": 0,
"label": "Amazon MWS Settings",
"link_count": 0,
"link_to": "Amazon MWS Settings",
"link_type": "DocType",
"onboard": 0,
"type": "Link"
},
{
"dependencies": "",
"hidden": 0,
"is_query_report": 0,
"label": "Plaid Settings",
"link_count": 0,
"link_to": "Plaid Settings",
"link_type": "DocType",
"onboard": 0,
"type": "Link"
},
{
"dependencies": "",
"hidden": 0,
"is_query_report": 0,
"label": "Exotel Settings",
"link_count": 0,
"link_to": "Exotel Settings",
"link_type": "DocType",
"onboard": 0,
"type": "Link"
}
],
"modified": "2021-11-23 04:30:33.106991",
"modified_by": "Administrator",
"module": "ERPNext Integrations",
"name": "ERPNext Integrations Settings",
"owner": "Administrator",
"parent_page": "",
"public": 1,
"restrict_to_domain": "",
"roles": [],
"sequence_id": 11,
"shortcuts": [],
"title": "ERPNext Integrations Settings"
}

2
erpnext/hooks.py

@ -374,7 +374,7 @@ scheduler_events = {
"erpnext.selling.doctype.quotation.quotation.set_expired_status",
"erpnext.buying.doctype.supplier_quotation.supplier_quotation.set_expired_status",
"erpnext.accounts.doctype.process_statement_of_accounts.process_statement_of_accounts.send_auto_email",
"erpnext.non_profit.doctype.membership.membership.set_expired_status"
"erpnext.non_profit.doctype.membership.membership.set_expired_status",
"erpnext.hr.doctype.interview.interview.send_daily_feedback_reminder"
],
"daily_long": [

17
erpnext/hr/doctype/appointment_letter/appointment_letter.py

@ -12,14 +12,15 @@ class AppointmentLetter(Document):
@frappe.whitelist()
def get_appointment_letter_details(template):
body = []
intro= frappe.get_list("Appointment Letter Template",
fields = ['introduction', 'closing_notes'],
filters={'name': template
})[0]
content = frappe.get_list("Appointment Letter content",
fields = ['title', 'description'],
filters={'parent': template
})
intro = frappe.get_list('Appointment Letter Template',
fields=['introduction', 'closing_notes'],
filters={'name': template}
)[0]
content = frappe.get_all('Appointment Letter content',
fields=['title', 'description'],
filters={'parent': template},
order_by='idx'
)
body.append(intro)
body.append({'description': content})
return body

57
erpnext/hr/doctype/appraisal/test_appraisal.js

@ -1,57 +0,0 @@
QUnit.module('hr');
QUnit.test("Test: Expense Claim [HR]", function (assert) {
assert.expect(3);
let done = assert.async();
let employee_name;
frappe.run_serially([
// Creating Appraisal
() => frappe.set_route('List','Appraisal','List'),
() => frappe.timeout(0.3),
() => frappe.click_button('Make a new Appraisal'),
() => {
cur_frm.set_value('kra_template','Test Appraisal 1'),
cur_frm.set_value('start_date','2017-08-21'),
cur_frm.set_value('end_date','2017-09-21');
},
() => frappe.timeout(1),
() => frappe.model.set_value('Appraisal Goal','New Appraisal Goal 1','score',4),
() => frappe.model.set_value('Appraisal Goal','New Appraisal Goal 1','score_earned',2),
() => frappe.model.set_value('Appraisal Goal','New Appraisal Goal 2','score',4),
() => frappe.model.set_value('Appraisal Goal','New Appraisal Goal 2','score_earned',2),
() => frappe.timeout(1),
() => frappe.db.get_value('Employee', {'employee_name': 'Test Employee 1'}, 'name'),
(r) => {
employee_name = r.message.name;
},
() => frappe.timeout(1),
() => cur_frm.set_value('employee',employee_name),
() => cur_frm.set_value('employee_name','Test Employee 1'),
() => cur_frm.set_value('company','For Testing'),
() => frappe.click_button('Calculate Total Score'),
() => frappe.timeout(1),
() => cur_frm.save(),
() => frappe.timeout(1),
() => cur_frm.save(),
// Submitting the Appraisal
() => frappe.click_button('Submit'),
() => frappe.click_button('Yes'),
() => frappe.timeout(3),
// Checking if the appraisal is correctly set for the employee
() => {
assert.equal('Submitted',cur_frm.get_field('status').value,
'Appraisal is submitted');
assert.equal('Test Employee 1',cur_frm.get_field('employee_name').value,
'Appraisal is created for correct employee');
assert.equal(4,cur_frm.get_field('total_score').value,
'Total score is correctly calculated');
},
() => done()
]);
});

29
erpnext/hr/doctype/appraisal_template/test_appraisal_template.js

@ -1,29 +0,0 @@
QUnit.module('hr');
QUnit.test("Test: Appraisal Template [HR]", function (assert) {
assert.expect(1);
let done = assert.async();
frappe.run_serially([
// Job Opening creation
() => {
frappe.tests.make('Appraisal Template', [
{ kra_title: 'Test Appraisal 1'},
{ description: 'This is just a test'},
{ goals: [
[
{ kra: 'Design'},
{ per_weightage: 50}
],
[
{ kra: 'Code creation'},
{ per_weightage: 50}
]
]},
]);
},
() => frappe.timeout(10),
() => {
assert.equal('Test Appraisal 1',cur_frm.doc.kra_title, 'Appraisal name correctly set');
},
() => done()
]);
});

39
erpnext/hr/doctype/attendance/test_attendance.js

@ -1,39 +0,0 @@
QUnit.module('hr');
QUnit.test("Test: Attendance [HR]", function (assert) {
assert.expect(4);
let done = assert.async();
frappe.run_serially([
// test attendance creation for one employee
() => frappe.set_route("List", "Attendance", "List"),
() => frappe.timeout(0.5),
() => frappe.new_doc("Attendance"),
() => frappe.timeout(1),
() => assert.equal("Attendance", cur_frm.doctype,
"Form for new Attendance opened successfully."),
// set values in form
() => cur_frm.set_value("company", "For Testing"),
() => {
frappe.db.get_value('Employee', {'employee_name':'Test Employee 1'}, 'name', function(r) {
cur_frm.set_value("employee", r.name)
});
},
() => frappe.timeout(1),
() => cur_frm.save(),
() => frappe.timeout(1),
// check docstatus of attendance before submit [Draft]
() => assert.equal("0", cur_frm.doc.docstatus,
"attendance is currently drafted"),
// check docstatus of attendance after submit [Present]
() => cur_frm.savesubmit(),
() => frappe.timeout(0.5),
() => frappe.click_button('Yes'),
() => assert.equal("1", cur_frm.doc.docstatus,
"attendance is saved after submit"),
// check if auto filled date is present day
() => assert.equal(frappe.datetime.nowdate(), cur_frm.doc.attendance_date,
"attendance for Present day is marked"),
() => done()
]);
});

40
erpnext/hr/doctype/employee/test_employee.js

@ -1,40 +0,0 @@
QUnit.module('hr');
QUnit.test("Test: Employee [HR]", function (assert) {
assert.expect(4);
let done = assert.async();
// let today_date = frappe.datetime.nowdate();
let employee_creation = (name, joining_date, birth_date) => {
frappe.run_serially([
// test employee creation
() => {
frappe.tests.make('Employee', [
{ employee_name: name},
{ salutation: 'Mr'},
{ company: 'For Testing'},
{ date_of_joining: joining_date},
{ date_of_birth: birth_date},
{ employment_type: 'Test Employment Type'},
{ holiday_list: 'Test Holiday List'},
{ branch: 'Test Branch'},
{ department: 'Test Department'},
{ designation: 'Test Designation'}
]);
},
() => frappe.timeout(2),
() => {
assert.ok(cur_frm.get_field('employee_name').value==name,
'Name of an Employee is correctly set');
assert.ok(cur_frm.get_field('gender').value=='Male',
'Gender of an Employee is correctly set');
},
]);
};
frappe.run_serially([
() => employee_creation('Test Employee 1','2017-04-01','1992-02-02'),
() => frappe.timeout(10),
() => employee_creation('Test Employee 3','2017-04-01','1992-02-02'),
() => frappe.timeout(10),
() => done()
]);
});

61
erpnext/hr/doctype/employee_attendance_tool/test_employee_attendance_tool.js

@ -1,61 +0,0 @@
QUnit.module('hr');
QUnit.test("Test: Employee attendance tool [HR]", function (assert) {
assert.expect(2);
let done = assert.async();
let today_date = frappe.datetime.nowdate();
let date_of_attendance = frappe.datetime.add_days(today_date, -2); // previous day
frappe.run_serially([
// create employee
() => {
return frappe.tests.make('Employee', [
{salutation: "Mr"},
{employee_name: "Test Employee 2"},
{company: "For Testing"},
{date_of_joining: frappe.datetime.add_months(today_date, -2)}, // joined 2 month from now
{date_of_birth: frappe.datetime.add_months(today_date, -240)}, // age is 20 years
{employment_type: "Test Employment type"},
{holiday_list: "Test Holiday list"},
{branch: "Test Branch"},
{department: "Test Department"},
{designation: "Test Designation"}
]);
},
() => frappe.set_route("Form", "Employee Attendance Tool"),
() => frappe.timeout(0.5),
() => assert.equal("Employee Attendance Tool", cur_frm.doctype,
"Form for Employee Attendance Tool opened successfully."),
// set values in form
() => cur_frm.set_value("date", date_of_attendance),
() => cur_frm.set_value("branch", "Test Branch"),
() => cur_frm.set_value("department", "Test Department"),
() => cur_frm.set_value("company", "For Testing"),
() => frappe.timeout(1),
() => frappe.click_button('Check all'),
() => frappe.click_button('Mark Present'),
// check if attendance is marked
() => frappe.set_route("List", "Attendance", "List"),
() => frappe.timeout(1),
() => {
return frappe.call({
method: "frappe.client.get_list",
args: {
doctype: "Employee",
filters: {
"branch": "Test Branch",
"department": "Test Department",
"company": "For Testing",
"status": "Active"
}
},
callback: function(r) {
let marked_attendance = cur_list.data.filter(d => d.attendance_date == date_of_attendance);
assert.equal(marked_attendance.length, r.message.length,
'all the attendance are marked for correct date');
}
});
},
() => done()
]);
});

22
erpnext/hr/doctype/employment_type/test_employment_type.js

@ -1,22 +0,0 @@
QUnit.module('hr');
QUnit.test("Test: Employment type [HR]", function (assert) {
assert.expect(1);
let done = assert.async();
frappe.run_serially([
// test employment type creation
() => frappe.set_route("List", "Employment Type", "List"),
() => frappe.new_doc("Employment Type"),
() => frappe.timeout(1),
() => frappe.quick_entry.dialog.$wrapper.find('.edit-full').click(),
() => frappe.timeout(1),
() => cur_frm.set_value("employee_type_name", "Test Employment type"),
// save form
() => cur_frm.save(),
() => frappe.timeout(1),
() => assert.equal("Test Employment type", cur_frm.doc.employee_type_name,
'name of employment type correctly saved'),
() => done()
]);
});

2
erpnext/hr/doctype/expense_claim/expense_claim.js

@ -171,7 +171,7 @@ frappe.ui.form.on("Expense Claim", {
['docstatus', '=', 1],
['employee', '=', frm.doc.employee],
['paid_amount', '>', 0],
['paid_amount', '>', 'claimed_amount']
['status', '!=', 'Claimed']
]
};
});

44
erpnext/hr/doctype/expense_claim/test_expense_claim.js

@ -1,44 +0,0 @@
QUnit.module('hr');
QUnit.test("Test: Expense Claim [HR]", function (assert) {
assert.expect(3);
let done = assert.async();
let employee_name;
let d;
frappe.run_serially([
// Creating Expense Claim
() => frappe.set_route('List','Expense Claim','List'),
() => frappe.timeout(0.3),
() => frappe.click_button('New'),
() => {
cur_frm.set_value('is_paid',1),
cur_frm.set_value('expenses',[]),
d = frappe.model.add_child(cur_frm.doc,'Expense Claim Detail','expenses'),
d.expense_date = '2017-08-01',
d.expense_type = 'Test Expense Type 1',
d.description = 'This is just to test Expense Claim',
d.amount = 2000,
d.sanctioned_amount=2000,
refresh_field('expenses');
},
() => frappe.timeout(1),
() => cur_frm.set_value('employee','Test Employee 1'),
() => cur_frm.set_value('company','For Testing'),
() => cur_frm.set_value('payable_account','Creditors - FT'),
() => cur_frm.set_value('cost_center','Main - FT'),
() => cur_frm.set_value('mode_of_payment','Cash'),
() => cur_frm.save(),
() => frappe.click_button('Submit'),
() => frappe.click_button('Yes'),
() => frappe.timeout(3),
// Checking if the amount is correctly reimbursed for the employee
() => {
assert.equal("Test Employee 1",cur_frm.doc.employee, 'Employee name set correctly');
assert.equal(1, cur_frm.doc.is_paid, 'Expense is paid as required');
assert.equal(2000, cur_frm.doc.total_amount_reimbursed, 'Amount is reimbursed correctly');
},
() => done()
]);
});

24
erpnext/hr/doctype/expense_claim/test_expense_claim.py

@ -10,15 +10,17 @@ from erpnext.accounts.doctype.account.test_account import create_account
from erpnext.hr.doctype.employee.test_employee import make_employee
from erpnext.hr.doctype.expense_claim.expense_claim import make_bank_entry
test_records = frappe.get_test_records('Expense Claim')
test_dependencies = ['Employee']
company_name = '_Test Company 4'
company_name = '_Test Company 3'
class TestExpenseClaim(unittest.TestCase):
def tearDown(self):
frappe.db.rollback()
def test_total_expense_claim_for_project(self):
frappe.db.sql("""delete from `tabTask` where project = "_Test Project 1" """)
frappe.db.sql("""delete from `tabProject` where name = "_Test Project 1" """)
frappe.db.sql("""delete from `tabTask`""")
frappe.db.sql("""delete from `tabProject`""")
frappe.db.sql("update `tabExpense Claim` set project = '', task = ''")
project = frappe.get_doc({
@ -37,12 +39,12 @@ class TestExpenseClaim(unittest.TestCase):
task_name = task.name
payable_account = get_payable_account(company_name)
make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC4", project.name, task_name)
make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC3", project.name, task_name)
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 200)
self.assertEqual(frappe.db.get_value("Project", project.name, "total_expense_claim"), 200)
expense_claim2 = make_expense_claim(payable_account, 600, 500, company_name, "Travel Expenses - _TC4", project.name, task_name)
expense_claim2 = make_expense_claim(payable_account, 600, 500, company_name, "Travel Expenses - _TC3", project.name, task_name)
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 700)
self.assertEqual(frappe.db.get_value("Project", project.name, "total_expense_claim"), 700)
@ -54,7 +56,7 @@ class TestExpenseClaim(unittest.TestCase):
def test_expense_claim_status(self):
payable_account = get_payable_account(company_name)
expense_claim = make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC4")
expense_claim = make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC3")
je_dict = make_bank_entry("Expense Claim", expense_claim.name)
je = frappe.get_doc(je_dict)
@ -73,7 +75,7 @@ class TestExpenseClaim(unittest.TestCase):
def test_expense_claim_gl_entry(self):
payable_account = get_payable_account(company_name)
taxes = generate_taxes()
expense_claim = make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC4",
expense_claim = make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC3",
do_not_submit=True, taxes=taxes)
expense_claim.submit()
@ -84,9 +86,9 @@ class TestExpenseClaim(unittest.TestCase):
self.assertTrue(gl_entries)
expected_values = dict((d[0], d) for d in [
['Output Tax CGST - _TC4',18.0, 0.0],
['Output Tax CGST - _TC3',18.0, 0.0],
[payable_account, 0.0, 218.0],
["Travel Expenses - _TC4", 200.0, 0.0]
["Travel Expenses - _TC3", 200.0, 0.0]
])
for gle in gl_entries:
@ -102,7 +104,7 @@ class TestExpenseClaim(unittest.TestCase):
"payable_account": payable_account,
"approval_status": "Rejected",
"expenses":
[{ "expense_type": "Travel", "default_account": "Travel Expenses - _TC4", "amount": 300, "sanctioned_amount": 200 }]
[{"expense_type": "Travel", "default_account": "Travel Expenses - _TC3", "amount": 300, "sanctioned_amount": 200}]
})
expense_claim.submit()

1
erpnext/hr/doctype/expense_claim/test_records.json

@ -1 +0,0 @@
[]

29
erpnext/hr/doctype/expense_claim_type/test_expense_claim_type.js

@ -1,29 +0,0 @@
QUnit.module('hr');
QUnit.test("Test: Expense Claim Type [HR]", function (assert) {
assert.expect(1);
let done = assert.async();
frappe.run_serially([
// Creating a Expense Claim Type
() => {
frappe.tests.make('Expense Claim Type', [
{ expense_type: 'Test Expense Type 1'},
{ description:'This is just a test'},
{ accounts: [
[
{ company: 'For Testing'},
{ default_account: 'Rounded Off - FT'}
]
]},
]);
},
() => frappe.timeout(5),
// Checking if the created type is present in the list
() => {
assert.equal('Test Expense Type 1', cur_frm.doc.expense_type,
'Expense Claim Type created successfully');
},
() => done()
]);
});

42
erpnext/hr/doctype/holiday_list/test_holiday_list.js

@ -1,42 +0,0 @@
QUnit.module('hr');
QUnit.test("Test: Holiday list [HR]", function (assert) {
assert.expect(3);
let done = assert.async();
let date = frappe.datetime.add_months(frappe.datetime.nowdate(), -2); // date 2 months from now
frappe.run_serially([
// test holiday list creation
() => frappe.set_route("List", "Holiday List", "List"),
() => frappe.new_doc("Holiday List"),
() => frappe.timeout(1),
() => cur_frm.set_value("holiday_list_name", "Test Holiday list"),
() => cur_frm.set_value("from_date", date),
() => cur_frm.set_value("weekly_off", "Sunday"), // holiday list for sundays
() => frappe.click_button('Get Weekly Off Dates'),
// save form
() => cur_frm.save(),
() => frappe.timeout(1),
() => assert.equal("Test Holiday list", cur_frm.doc.holiday_list_name,
'name of holiday list correctly saved'),
// check if holiday list contains correct days
() => {
var list = cur_frm.doc.holidays;
var list_length = list.length;
var i = 0;
for ( ; i < list_length; i++)
if (list[i].description != 'Sunday') break;
assert.equal(list_length, i, "all holidays are sundays in holiday list");
},
// check if to_date is set one year from from_date
() => {
var date_year_later = frappe.datetime.add_days(frappe.datetime.add_months(date, 12), -1); // date after one year
assert.equal(date_year_later, cur_frm.doc.to_date,
"to date set correctly");
},
() => done()
]);
});

28
erpnext/hr/doctype/job_applicant/test_job_applicant.js

@ -1,28 +0,0 @@
QUnit.module('hr');
QUnit.test("Test: Job Opening [HR]", function (assert) {
assert.expect(2);
let done = assert.async();
frappe.run_serially([
// Job Applicant creation
() => {
frappe.tests.make('Job Applicant', [
{ applicant_name: 'Utkarsh Goswami'},
{ email_id: 'goswamiutkarsh0@gmail.com'},
{ job_title: 'software-developer'},
{ cover_letter: 'Highly skilled in designing, testing, and developing software.'+
' This is just a test.'}
]);
},
() => frappe.timeout(4),
() => frappe.set_route('List','Job Applicant'),
() => frappe.timeout(3),
() => {
assert.ok(cur_list.data.length==1, 'Job Applicant created successfully');
assert.ok(cur_list.data[0].name=='Utkarsh Goswami - goswamiutkarsh0@gmail.com - software-developer',
'Correct job applicant with valid job title');
},
() => done()
]);
});

51
erpnext/hr/doctype/job_offer/test_job_offer.js

@ -1,51 +0,0 @@
QUnit.module('hr');
QUnit.test("Test: Job Offer [HR]", function (assert) {
assert.expect(3);
let done = assert.async();
frappe.run_serially([
// Job Offer Creation
() => {
frappe.tests.make('Job Offer', [
{ job_applicant: 'Utkarsh Goswami - goswamiutkarsh0@gmail.com - software-developer'},
{ applicant_name: 'Utkarsh Goswami'},
{ status: 'Accepted'},
{ designation: 'Software Developer'},
{ offer_terms: [
[
{offer_term: 'Responsibilities'},
{value: 'Design, installation, testing and maintenance of software systems.'}
],
[
{offer_term: 'Department'},
{value: 'Research & Development'}
],
[
{offer_term: 'Probationary Period'},
{value: 'The Probation period is for 3 months.'}
]
]},
]);
},
() => frappe.timeout(10),
() => frappe.click_button('Submit'),
() => frappe.timeout(2),
() => frappe.click_button('Yes'),
() => frappe.timeout(5),
// To check if the fields are correctly set
() => {
assert.ok(cur_frm.get_field('status').value=='Accepted',
'Status of job offer is correct');
assert.ok(cur_frm.get_field('designation').value=='Software Developer',
'Designation of applicant is correct');
},
() => frappe.set_route('List','Job Offer','List'),
() => frappe.timeout(2),
// Checking the submission of and Job Offer
() => {
assert.ok(cur_list.data[0].docstatus==1,'Job Offer Submitted successfully');
},
() => frappe.timeout(2),
() => done()
]);
});

26
erpnext/hr/doctype/job_opening/test_job_opening.js

@ -1,26 +0,0 @@
QUnit.module('hr');
QUnit.test("Test: Job Opening [HR]", function (assert) {
assert.expect(2);
let done = assert.async();
frappe.run_serially([
// Job Opening creation
() => {
frappe.tests.make('Job Opening', [
{ job_title: 'Software Developer'},
{ description:
'You might be responsible for writing and coding individual'+
' programmes or providing an entirely new software resource.'}
]);
},
() => frappe.timeout(4),
() => frappe.set_route('List','Job Opening'),
() => frappe.timeout(3),
() => {
assert.ok(cur_list.data.length==1, 'Job Opening created successfully');
assert.ok(cur_list.data[0].job_title=='Software Developer', 'Job title Correctly set');
},
() => done()
]);
});

41
erpnext/hr/doctype/leave_allocation/test_leave_allocation.js

@ -1,41 +0,0 @@
QUnit.module('hr');
QUnit.test("Test: Leave allocation [HR]", function (assert) {
assert.expect(3);
let done = assert.async();
let today_date = frappe.datetime.nowdate();
frappe.run_serially([
// test creating leave alloction
() => frappe.set_route("List", "Leave Allocation", "List"),
() => frappe.new_doc("Leave Allocation"),
() => frappe.timeout(1),
() => {
frappe.db.get_value('Employee', {'employee_name':'Test Employee 1'}, 'name', function(r) {
cur_frm.set_value("employee", r.name)
});
},
() => frappe.timeout(1),
() => cur_frm.set_value("leave_type", "Test Leave type"),
() => cur_frm.set_value("to_date", frappe.datetime.add_months(today_date, 2)), // for two months
() => cur_frm.set_value("description", "This is just for testing"),
() => cur_frm.set_value("new_leaves_allocated", 2),
() => frappe.click_check('Add unused leaves from previous allocations'),
// save form
() => cur_frm.save(),
() => frappe.timeout(1),
() => cur_frm.savesubmit(),
() => frappe.timeout(1),
() => assert.equal("Confirm", cur_dialog.title,
'confirmation for leave alloction shown'),
() => frappe.click_button('Yes'),
() => frappe.timeout(1),
// check auto filled from date
() => assert.equal(today_date, cur_frm.doc.from_date,
"from date correctly set"),
// check for total leaves
() => assert.equal(cur_frm.doc.unused_leaves + 2, cur_frm.doc.total_leaves_allocated,
"total leave calculation is correctly set"),
() => done()
]);
});

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

Loading…
Cancel
Save