Js tests added for write off difference amount

This commit is contained in:
Nabin Hait 2017-08-17 14:05:57 +05:30
parent 6c3618be37
commit ded8d11728
4 changed files with 82 additions and 3 deletions

View File

@ -299,7 +299,7 @@ class PaymentEntry(AccountsController):
total_deductions = sum([flt(d.amount) for d in self.get("deductions")])
self.difference_amount = flt(self.difference_amount - total_deductions,
self.difference_amount = flt(self.difference_amount - total_deductions,
self.precision("difference_amount"))
def clear_unallocated_reference_document_rows(self):

View File

@ -288,7 +288,7 @@ class TestPaymentEntry(unittest.TestCase):
self.assertEqual(pe.unallocated_amount, 0)
self.assertEqual(pe.difference_amount, 0)
pe.submit()
expected_gle = dict((d[0], d) for d in [
@ -316,7 +316,7 @@ class TestPaymentEntry(unittest.TestCase):
self.assertEqual(pe.unallocated_amount, 0)
self.assertEqual(pe.difference_amount, 0)
pe.submit()
expected_gle = dict((d[0], d) for d in [

View File

@ -0,0 +1,67 @@
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: '_Test Company'},
{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 - _TC"),
() => 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 - _TC', '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", "_Test Company", "write_off_account", "_Test Write Off - _TC");
frappe.timeout(1);
frappe.db.set_value("Company", "_Test Company",
"exchange_gain_loss_account", "_Test Exchange Gain/Loss - _TC");
},
() => 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()
]);
});

View File

@ -205,6 +205,18 @@ $.extend(frappe.test_data, {
{title: "Test Term 2"}
]
},
"Item Price": {
"ITEM-PRICE-00001": [
{item_code: 'Test Product 1'},
{price_list: '_Test Price List'},
{price_list_rate: 100}
],
"ITEM-PRICE-00002": [
{item_code: 'Test Product 2'},
{price_list: '_Test Price List'},
{price_list_rate: 200}
]
}
});