Merge pull request #26322 from deepeshgarg007/party_dashboard_develop
fix: Do not consider cancelled entries in party dashboard
This commit is contained in:
commit
381c05eb87
@ -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)
|
# 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')
|
||||||
exchange_gain_loss_amount = frappe.get_value('GL Entry', gl_entries[0]['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,21 +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)
|
||||||
|
|
||||||
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
|
||||||
|
@ -542,6 +542,7 @@ def get_dashboard_info(party_type, party, loyalty_program=None):
|
|||||||
select company, sum(debit_in_account_currency) - sum(credit_in_account_currency)
|
select company, sum(debit_in_account_currency) - sum(credit_in_account_currency)
|
||||||
from `tabGL Entry`
|
from `tabGL Entry`
|
||||||
where party_type = %s and party=%s
|
where party_type = %s and party=%s
|
||||||
|
and is_cancelled = 0
|
||||||
group by company""", (party_type, party)))
|
group by company""", (party_type, party)))
|
||||||
|
|
||||||
for d in companies:
|
for d in companies:
|
||||||
|
@ -1054,30 +1054,30 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
|
|
||||||
def test_purchase_receipt_with_exchange_rate_difference(self):
|
def test_purchase_receipt_with_exchange_rate_difference(self):
|
||||||
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice as create_purchase_invoice
|
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice as create_purchase_invoice
|
||||||
|
from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import make_purchase_receipt as create_purchase_receipt
|
||||||
pi = create_purchase_invoice(currency = "USD", conversion_rate = 70)
|
|
||||||
|
|
||||||
create_warehouse("_Test Warehouse for Valuation", company="_Test Company with perpetual inventory",
|
|
||||||
properties={"account": '_Test Account Stock In Hand - TCP1'})
|
|
||||||
|
|
||||||
pr = make_purchase_receipt(warehouse = '_Test Warehouse for Valuation - TCP1',
|
pi = create_purchase_invoice(company="_Test Company with perpetual inventory",
|
||||||
company="_Test Company with perpetual inventory", currency = "USD", conversion_rate = 80,
|
cost_center = "Main - TCP1",
|
||||||
do_not_save = "True")
|
warehouse = "Stores - TCP1",
|
||||||
|
expense_account ="_Test Account Cost for Goods Sold - TCP1",
|
||||||
|
currency = "USD", conversion_rate = 70)
|
||||||
|
|
||||||
|
pr = create_purchase_receipt(pi.name)
|
||||||
|
pr.conversion_rate = 80
|
||||||
pr.items[0].purchase_invoice = pi.name
|
pr.items[0].purchase_invoice = pi.name
|
||||||
pr.items[0].purchase_invoice_item = pi.items[0].name
|
pr.items[0].purchase_invoice_item = pi.items[0].name
|
||||||
|
|
||||||
pr.insert()
|
pr.save()
|
||||||
pr.submit()
|
pr.submit()
|
||||||
|
|
||||||
# fetching the latest GL Entry with 'Exchange Gain/Loss - TCP1' account
|
# Get exchnage gain and loss account
|
||||||
gl_entries = frappe.get_all('GL Entry', filters = {'account': 'Exchange Gain/Loss - TCP1'})
|
exchange_gain_loss_account = frappe.db.get_value('Company', pr.company, 'exchange_gain_loss_account')
|
||||||
voucher_no = frappe.get_value('GL Entry', gl_entries[0]['name'], 'voucher_no')
|
|
||||||
self.assertEqual(pr.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': pr.name}, 'credit')
|
||||||
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 get_sl_entries(voucher_type, voucher_no):
|
def get_sl_entries(voucher_type, voucher_no):
|
||||||
return frappe.db.sql(""" select actual_qty, warehouse, stock_value_difference
|
return frappe.db.sql(""" select actual_qty, warehouse, stock_value_difference
|
||||||
|
@ -81,6 +81,7 @@ class TestServiceLevelAgreement(unittest.TestCase):
|
|||||||
|
|
||||||
# check SLA custom fields created for leads
|
# check SLA custom fields created for leads
|
||||||
sla_fields = get_service_level_agreement_fields()
|
sla_fields = get_service_level_agreement_fields()
|
||||||
|
frappe.clear_cache(doctype=doctype)
|
||||||
meta = frappe.get_meta(doctype, cached=False)
|
meta = frappe.get_meta(doctype, cached=False)
|
||||||
|
|
||||||
for field in sla_fields:
|
for field in sla_fields:
|
||||||
|
Loading…
Reference in New Issue
Block a user