|
@ -231,25 +231,25 @@ class TestPurchaseInvoice(unittest.TestCase): |
|
|
self.assertEqual(expected_values[gle.account][2], gle.credit) |
|
|
self.assertEqual(expected_values[gle.account][2], gle.credit) |
|
|
|
|
|
|
|
|
def test_purchase_invoice_with_exchange_rate_difference(self): |
|
|
def test_purchase_invoice_with_exchange_rate_difference(self): |
|
|
pr = make_purchase_receipt(currency = "USD", conversion_rate = 70) |
|
|
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice as create_purchase_invoice |
|
|
pi = make_purchase_invoice(currency = "USD", conversion_rate = 80, do_not_save = "True") |
|
|
|
|
|
|
|
|
|
|
|
pi.items[0].purchase_receipt = pr.name |
|
|
pr = make_purchase_receipt(company="_Test Company with perpetual inventory", warehouse='Stores - TCP1', |
|
|
pi.items[0].pr_detail = pr.items[0].name |
|
|
currency = "USD", conversion_rate = 70) |
|
|
|
|
|
|
|
|
|
|
|
pi = create_purchase_invoice(pr.name) |
|
|
|
|
|
pi.conversion_rate = 80 |
|
|
|
|
|
|
|
|
pi.insert() |
|
|
pi.insert() |
|
|
pi.submit() |
|
|
pi.submit() |
|
|
|
|
|
|
|
|
# fetching the latest GL Entry with 'Exchange Gain/Loss - _TC' account |
|
|
# Get exchnage gain and loss account |
|
|
gl_entries = frappe.get_all('GL Entry', filters = {'account': 'Exchange Gain/Loss - _TC'}) |
|
|
exchange_gain_loss_account = frappe.db.get_value('Company', pi.company, 'exchange_gain_loss_account') |
|
|
voucher_no = frappe.get_value('GL Entry', gl_entries[0]['name'], 'voucher_no') |
|
|
|
|
|
|
|
|
|
|
|
self.assertEqual(pi.name, voucher_no) |
|
|
|
|
|
|
|
|
|
|
|
exchange_gain_loss_amount = frappe.get_value('GL Entry', gl_entries[0]['name'], 'debit') |
|
|
# fetching the latest GL Entry with exchange gain and loss account account |
|
|
|
|
|
amount = frappe.db.get_value('GL Entry', {'account': exchange_gain_loss_account, 'voucher_no': pi.name}, 'debit') |
|
|
discrepancy_caused_by_exchange_rate_diff = abs(pi.items[0].base_net_amount - pr.items[0].base_net_amount) |
|
|
discrepancy_caused_by_exchange_rate_diff = abs(pi.items[0].base_net_amount - pr.items[0].base_net_amount) |
|
|
|
|
|
|
|
|
self.assertEqual(exchange_gain_loss_amount, discrepancy_caused_by_exchange_rate_diff) |
|
|
self.assertEqual(discrepancy_caused_by_exchange_rate_diff, amount) |
|
|
|
|
|
|
|
|
def test_purchase_invoice_change_naming_series(self): |
|
|
def test_purchase_invoice_change_naming_series(self): |
|
|
pi = frappe.copy_doc(test_records[1]) |
|
|
pi = frappe.copy_doc(test_records[1]) |
|
@ -1031,22 +1031,21 @@ class TestPurchaseInvoice(unittest.TestCase): |
|
|
# Check GLE for Purchase Invoice |
|
|
# Check GLE for Purchase Invoice |
|
|
# Zero net effect on final TDS Payable on invoice |
|
|
# Zero net effect on final TDS Payable on invoice |
|
|
expected_gle = [ |
|
|
expected_gle = [ |
|
|
['_Test Account Cost for Goods Sold - _TC', 30000, 0], |
|
|
['_Test Account Cost for Goods Sold - _TC', 30000], |
|
|
['_Test Account Excise Duty - _TC', 0, 3000], |
|
|
['_Test Account Excise Duty - _TC', -3000], |
|
|
['Creditors - _TC', 0, 27000], |
|
|
['Creditors - _TC', -27000], |
|
|
['TDS Payable - _TC', 3000, 3000] |
|
|
['TDS Payable - _TC', 0] |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
gl_entries = frappe.db.sql("""select account, debit, credit |
|
|
gl_entries = frappe.db.sql("""select account, sum(debit - credit) as amount |
|
|
from `tabGL Entry` |
|
|
from `tabGL Entry` |
|
|
where voucher_type='Purchase Invoice' and voucher_no=%s |
|
|
where voucher_type='Purchase Invoice' and voucher_no=%s |
|
|
|
|
|
group by account |
|
|
order by account asc""", (purchase_invoice.name), as_dict=1) |
|
|
order by account asc""", (purchase_invoice.name), as_dict=1) |
|
|
|
|
|
|
|
|
print(gl_entries) |
|
|
|
|
|
for i, gle in enumerate(gl_entries): |
|
|
for i, gle in enumerate(gl_entries): |
|
|
self.assertEqual(expected_gle[i][0], gle.account) |
|
|
self.assertEqual(expected_gle[i][0], gle.account) |
|
|
self.assertEqual(expected_gle[i][1], gle.debit) |
|
|
self.assertEqual(expected_gle[i][1], gle.amount) |
|
|
self.assertEqual(expected_gle[i][2], gle.credit) |
|
|
|
|
|
|
|
|
|
|
|
def update_tax_witholding_category(company, account, date): |
|
|
def update_tax_witholding_category(company, account, date): |
|
|
from erpnext.accounts.utils import get_fiscal_year |
|
|
from erpnext.accounts.utils import get_fiscal_year |
|
|