tundebabzy | 40a0276 | 2017-10-25 07:54:34 +0100 | [diff] [blame] | 1 | import unittest |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 2 | |
tundebabzy | 40a0276 | 2017-10-25 07:54:34 +0100 | [diff] [blame] | 3 | from frappe.test_runner import make_test_objects |
| 4 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 5 | from erpnext.accounts.party import get_party_shipping_address |
rohitwaghchaure | 058d983 | 2021-09-07 12:14:40 +0530 | [diff] [blame] | 6 | from erpnext.accounts.utils import get_future_stock_vouchers, get_voucherwise_gl_entries |
| 7 | from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 8 | |
tundebabzy | 40a0276 | 2017-10-25 07:54:34 +0100 | [diff] [blame] | 9 | |
| 10 | class TestUtils(unittest.TestCase): |
| 11 | @classmethod |
| 12 | def setUpClass(cls): |
| 13 | super(TestUtils, cls).setUpClass() |
rohitwaghchaure | 058d983 | 2021-09-07 12:14:40 +0530 | [diff] [blame] | 14 | make_test_objects("Address", ADDRESS_RECORDS) |
tundebabzy | 40a0276 | 2017-10-25 07:54:34 +0100 | [diff] [blame] | 15 | |
| 16 | def test_get_party_shipping_address(self): |
rohitwaghchaure | 058d983 | 2021-09-07 12:14:40 +0530 | [diff] [blame] | 17 | address = get_party_shipping_address("Customer", "_Test Customer 1") |
| 18 | self.assertEqual(address, "_Test Billing Address 2 Title-Billing") |
tundebabzy | 40a0276 | 2017-10-25 07:54:34 +0100 | [diff] [blame] | 19 | |
| 20 | def test_get_party_shipping_address2(self): |
rohitwaghchaure | 058d983 | 2021-09-07 12:14:40 +0530 | [diff] [blame] | 21 | address = get_party_shipping_address("Customer", "_Test Customer 2") |
| 22 | self.assertEqual(address, "_Test Shipping Address 2 Title-Shipping") |
| 23 | |
| 24 | def test_get_voucher_wise_gl_entry(self): |
| 25 | |
| 26 | pr = make_purchase_receipt( |
| 27 | item_code="_Test Item", |
| 28 | posting_date="2021-02-01", |
| 29 | rate=100, |
| 30 | qty=1, |
| 31 | warehouse="Stores - TCP1", |
| 32 | company="_Test Company with perpetual inventory", |
| 33 | ) |
| 34 | |
| 35 | future_vouchers = get_future_stock_vouchers("2021-01-01", "00:00:00", for_items=["_Test Item"]) |
| 36 | |
| 37 | voucher_type_and_no = ("Purchase Receipt", pr.name) |
| 38 | self.assertTrue( |
| 39 | voucher_type_and_no in future_vouchers, |
| 40 | msg="get_future_stock_vouchers not returning correct value", |
| 41 | ) |
| 42 | |
| 43 | posting_date = "2021-01-01" |
| 44 | gl_entries = get_voucherwise_gl_entries(future_vouchers, posting_date) |
| 45 | self.assertTrue( |
| 46 | voucher_type_and_no in gl_entries, msg="get_voucherwise_gl_entries not returning expected GLes", |
| 47 | ) |
tundebabzy | 40a0276 | 2017-10-25 07:54:34 +0100 | [diff] [blame] | 48 | |
| 49 | |
| 50 | ADDRESS_RECORDS = [ |
| 51 | { |
| 52 | "doctype": "Address", |
| 53 | "address_type": "Billing", |
| 54 | "address_line1": "Address line 1", |
| 55 | "address_title": "_Test Billing Address Title", |
| 56 | "city": "Lagos", |
| 57 | "country": "Nigeria", |
| 58 | "links": [ |
rohitwaghchaure | 058d983 | 2021-09-07 12:14:40 +0530 | [diff] [blame] | 59 | {"link_doctype": "Customer", "link_name": "_Test Customer 2", "doctype": "Dynamic Link"} |
| 60 | ], |
tundebabzy | 40a0276 | 2017-10-25 07:54:34 +0100 | [diff] [blame] | 61 | }, |
| 62 | { |
| 63 | "doctype": "Address", |
| 64 | "address_type": "Shipping", |
| 65 | "address_line1": "Address line 2", |
| 66 | "address_title": "_Test Shipping Address 1 Title", |
| 67 | "city": "Lagos", |
| 68 | "country": "Nigeria", |
| 69 | "links": [ |
rohitwaghchaure | 058d983 | 2021-09-07 12:14:40 +0530 | [diff] [blame] | 70 | {"link_doctype": "Customer", "link_name": "_Test Customer 2", "doctype": "Dynamic Link"} |
| 71 | ], |
tundebabzy | 40a0276 | 2017-10-25 07:54:34 +0100 | [diff] [blame] | 72 | }, |
| 73 | { |
| 74 | "doctype": "Address", |
| 75 | "address_type": "Shipping", |
| 76 | "address_line1": "Address line 3", |
| 77 | "address_title": "_Test Shipping Address 2 Title", |
| 78 | "city": "Lagos", |
| 79 | "country": "Nigeria", |
| 80 | "is_shipping_address": "1", |
| 81 | "links": [ |
rohitwaghchaure | 058d983 | 2021-09-07 12:14:40 +0530 | [diff] [blame] | 82 | {"link_doctype": "Customer", "link_name": "_Test Customer 2", "doctype": "Dynamic Link"} |
| 83 | ], |
tundebabzy | 40a0276 | 2017-10-25 07:54:34 +0100 | [diff] [blame] | 84 | }, |
| 85 | { |
| 86 | "doctype": "Address", |
| 87 | "address_type": "Billing", |
| 88 | "address_line1": "Address line 4", |
| 89 | "address_title": "_Test Billing Address 2 Title", |
| 90 | "city": "Lagos", |
| 91 | "country": "Nigeria", |
| 92 | "is_shipping_address": "1", |
| 93 | "links": [ |
rohitwaghchaure | 058d983 | 2021-09-07 12:14:40 +0530 | [diff] [blame] | 94 | {"link_doctype": "Customer", "link_name": "_Test Customer 1", "doctype": "Dynamic Link"} |
| 95 | ], |
| 96 | }, |
tundebabzy | 40a0276 | 2017-10-25 07:54:34 +0100 | [diff] [blame] | 97 | ] |