[fix] Asset test cases and added make_sales_invoice (#11800)
* [fix] Asset test cases and added make_sales_invoice * vehicle trip test cases
This commit is contained in:
parent
e761b9de40
commit
e34ef60e3e
@ -41,7 +41,7 @@ frappe.ui.form.on('Asset', {
|
|||||||
});
|
});
|
||||||
|
|
||||||
frm.add_custom_button("Sell Asset", function() {
|
frm.add_custom_button("Sell Asset", function() {
|
||||||
erpnext.asset.make_sales_invoice(frm);
|
frm.trigger("make_sales_invoice");
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (frm.doc.status=='Scrapped') {
|
} else if (frm.doc.status=='Scrapped') {
|
||||||
@ -168,6 +168,21 @@ frappe.ui.form.on('Asset', {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
make_sales_invoice: function(frm) {
|
||||||
|
frappe.call({
|
||||||
|
args: {
|
||||||
|
"asset": frm.doc.name,
|
||||||
|
"item_code": frm.doc.item_code,
|
||||||
|
"company": frm.doc.company
|
||||||
|
},
|
||||||
|
method: "erpnext.accounts.doctype.asset.asset.make_sales_invoice",
|
||||||
|
callback: function(r) {
|
||||||
|
var doclist = frappe.model.sync(r.message);
|
||||||
|
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
create_asset_maintenance: function(frm) {
|
create_asset_maintenance: function(frm) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
args: {
|
args: {
|
||||||
|
@ -234,8 +234,9 @@ class TestAsset(unittest.TestCase):
|
|||||||
|
|
||||||
expected_gle = (
|
expected_gle = (
|
||||||
("_Test Accumulated Depreciations - _TC", 30000.0, 0.0),
|
("_Test Accumulated Depreciations - _TC", 30000.0, 0.0),
|
||||||
|
("_Test Depreciations - _TC", 70000.0, 0.0),
|
||||||
("_Test Fixed Asset - _TC", 0.0, 100000.0),
|
("_Test Fixed Asset - _TC", 0.0, 100000.0),
|
||||||
("_Test Gain/Loss on Asset Disposal - _TC", 45000.0, 0.0),
|
("_Test Gain/Loss on Asset Disposal - _TC", 0.0, 25000.0),
|
||||||
("Debtors - _TC", 25000.0, 0.0)
|
("Debtors - _TC", 25000.0, 0.0)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ class TestVehicle(unittest.TestCase):
|
|||||||
"acquisition_date":frappe.utils.nowdate(),
|
"acquisition_date":frappe.utils.nowdate(),
|
||||||
"location": "Mumbai",
|
"location": "Mumbai",
|
||||||
"chassis_no": "1234ABCD",
|
"chassis_no": "1234ABCD",
|
||||||
|
"uom": "Litre",
|
||||||
"vehicle_value":frappe.utils.flt(500000)
|
"vehicle_value":frappe.utils.flt(500000)
|
||||||
})
|
})
|
||||||
vehicle.insert()
|
vehicle.insert()
|
||||||
|
@ -20,6 +20,7 @@ class TestVehicleLog(unittest.TestCase):
|
|||||||
"acquisition_date":frappe.utils.nowdate(),
|
"acquisition_date":frappe.utils.nowdate(),
|
||||||
"location": "Mumbai",
|
"location": "Mumbai",
|
||||||
"chassis_no": "1234ABCD",
|
"chassis_no": "1234ABCD",
|
||||||
|
"uom": "Litre",
|
||||||
"vehicle_value":frappe.utils.flt(500000)
|
"vehicle_value":frappe.utils.flt(500000)
|
||||||
})
|
})
|
||||||
try:
|
try:
|
||||||
|
@ -8,26 +8,30 @@ import erpnext
|
|||||||
import unittest
|
import unittest
|
||||||
from frappe.utils import nowdate, add_days
|
from frappe.utils import nowdate, add_days
|
||||||
from erpnext.tests.utils import create_test_contact_and_address
|
from erpnext.tests.utils import create_test_contact_and_address
|
||||||
from erpnext.stock.doctype.delivery_trip.delivery_trip import notify_customers
|
from erpnext.stock.doctype.delivery_trip.delivery_trip import notify_customers, get_contact_and_address
|
||||||
|
|
||||||
class TestDeliveryTrip(unittest.TestCase):
|
class TestDeliveryTrip(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
create_driver()
|
create_driver()
|
||||||
create_vehicle()
|
create_vehicle()
|
||||||
|
create_delivery_notfication()
|
||||||
create_test_contact_and_address()
|
create_test_contact_and_address()
|
||||||
|
|
||||||
def test_delivery_trip(self):
|
def test_delivery_trip(self):
|
||||||
|
contact = get_contact_and_address("_Test Customer")
|
||||||
|
|
||||||
if not frappe.db.exists("Delivery Trip", "TOUR-00000"):
|
if not frappe.db.exists("Delivery Trip", "TOUR-00000"):
|
||||||
delivery_trip = frappe.new_doc("Delivery Trip")
|
delivery_trip = frappe.new_doc("Delivery Trip")
|
||||||
delivery_trip.company = erpnext.get_default_company()
|
delivery_trip.company = erpnext.get_default_company()
|
||||||
delivery_trip.date = add_days(nowdate(), 5)
|
delivery_trip.date = add_days(nowdate(), 5)
|
||||||
delivery_trip.driver = "Newton Scmander"
|
delivery_trip.driver = "DRIVER-00001"
|
||||||
delivery_trip.vehicle = "JB 007"
|
delivery_trip.vehicle = "JB 007"
|
||||||
delivery_trip.append("delivery_stops", {
|
delivery_trip.append("delivery_stops", {
|
||||||
"customer": "_Test Customer",
|
"customer": "_Test Customer",
|
||||||
"address": "_Test Address for Customer",
|
"address": contact.shipping_address.parent,
|
||||||
"contact": '_Test Contact for _Test Customer - _Test Customer'
|
"contact": contact.contact_person.parent
|
||||||
})
|
})
|
||||||
|
delivery_trip.delivery_notification = 'Delivery Notification'
|
||||||
delivery_trip.insert()
|
delivery_trip.insert()
|
||||||
sender_email = frappe.db.get_value("User", frappe.session.user, "email")
|
sender_email = frappe.db.get_value("User", frappe.session.user, "email")
|
||||||
notify_customers(docname=delivery_trip.name, date=delivery_trip.date, driver=delivery_trip.driver,
|
notify_customers(docname=delivery_trip.name, date=delivery_trip.date, driver=delivery_trip.driver,
|
||||||
@ -36,7 +40,6 @@ class TestDeliveryTrip(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEquals(delivery_trip.get("delivery_stops")[0].notified_by_email, 1)
|
self.assertEquals(delivery_trip.get("delivery_stops")[0].notified_by_email, 1)
|
||||||
|
|
||||||
|
|
||||||
def create_driver():
|
def create_driver():
|
||||||
if not frappe.db.exists("Driver", "Newton Scmander"):
|
if not frappe.db.exists("Driver", "Newton Scmander"):
|
||||||
driver = frappe.new_doc("Driver")
|
driver = frappe.new_doc("Driver")
|
||||||
@ -45,6 +48,15 @@ def create_driver():
|
|||||||
driver.license_number = "B809"
|
driver.license_number = "B809"
|
||||||
driver.insert()
|
driver.insert()
|
||||||
|
|
||||||
|
def create_delivery_notfication():
|
||||||
|
if not frappe.db.exists("Standard Reply", "Delivery Notification"):
|
||||||
|
frappe.get_doc({
|
||||||
|
'doctype': 'Standard Reply',
|
||||||
|
'name': 'Delivery Notification',
|
||||||
|
'response': 'Test Delivery Trip',
|
||||||
|
'subject': 'Test Subject',
|
||||||
|
'owner': frappe.session.user
|
||||||
|
}).insert()
|
||||||
|
|
||||||
def create_vehicle():
|
def create_vehicle():
|
||||||
if not frappe.db.exists("Vehicle", "JB 007"):
|
if not frappe.db.exists("Vehicle", "JB 007"):
|
||||||
@ -57,6 +69,7 @@ def create_vehicle():
|
|||||||
"acquisition_date": frappe.utils.nowdate(),
|
"acquisition_date": frappe.utils.nowdate(),
|
||||||
"location": "Mumbai",
|
"location": "Mumbai",
|
||||||
"chassis_no": "1234ABCD",
|
"chassis_no": "1234ABCD",
|
||||||
|
"uom": "Litre",
|
||||||
"vehicle_value": frappe.utils.flt(500000)
|
"vehicle_value": frappe.utils.flt(500000)
|
||||||
})
|
})
|
||||||
vehicle.insert()
|
vehicle.insert()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user