fix: Exchange gain and loss on advance jv allocation
This commit is contained in:
parent
c3e1f0e369
commit
31883b699d
@ -30,6 +30,9 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.
|
|||||||
onload() {
|
onload() {
|
||||||
super.onload();
|
super.onload();
|
||||||
|
|
||||||
|
// Ignore linked advances
|
||||||
|
this.frm.ignore_doctypes_on_cancel_all = ['Journal Entry', 'Payment Entry'];
|
||||||
|
|
||||||
if(!this.frm.doc.__islocal) {
|
if(!this.frm.doc.__islocal) {
|
||||||
// show credit_to in print format
|
// show credit_to in print format
|
||||||
if(!this.frm.doc.supplier && this.frm.doc.credit_to) {
|
if(!this.frm.doc.supplier && this.frm.doc.credit_to) {
|
||||||
|
@ -33,7 +33,9 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
|
|||||||
var me = this;
|
var me = this;
|
||||||
super.onload();
|
super.onload();
|
||||||
|
|
||||||
this.frm.ignore_doctypes_on_cancel_all = ['POS Invoice', 'Timesheet', 'POS Invoice Merge Log', 'POS Closing Entry'];
|
this.frm.ignore_doctypes_on_cancel_all = ['POS Invoice', 'Timesheet', 'POS Invoice Merge Log',
|
||||||
|
'POS Closing Entry', 'Journal Entry', 'Payment Entry'];
|
||||||
|
|
||||||
if(!this.frm.doc.__islocal && !this.frm.doc.customer && this.frm.doc.debit_to) {
|
if(!this.frm.doc.__islocal && !this.frm.doc.customer && this.frm.doc.debit_to) {
|
||||||
// show debit_to in print format
|
// show debit_to in print format
|
||||||
this.frm.set_df_property("debit_to", "print_hide", 0);
|
this.frm.set_df_property("debit_to", "print_hide", 0);
|
||||||
|
@ -3116,6 +3116,62 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
si.reload()
|
si.reload()
|
||||||
self.assertTrue(si.items[0].serial_no)
|
self.assertTrue(si.items[0].serial_no)
|
||||||
|
|
||||||
|
def test_gain_loss_with_advance_entry(self):
|
||||||
|
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
||||||
|
|
||||||
|
unlink_enabled = frappe.db.get_value(
|
||||||
|
"Accounts Settings", "Accounts Settings", "unlink_payment_on_cancel_of_invoice"
|
||||||
|
)
|
||||||
|
|
||||||
|
frappe.db.set_value(
|
||||||
|
"Accounts Settings", "Accounts Settings", "unlink_payment_on_cancel_of_invoice", 1
|
||||||
|
)
|
||||||
|
|
||||||
|
jv = make_journal_entry("_Test Receivable USD - _TC", "_Test Bank - _TC", -7000, save=False)
|
||||||
|
|
||||||
|
jv.accounts[0].exchange_rate = 70
|
||||||
|
jv.accounts[0].credit_in_account_currency = 100
|
||||||
|
jv.accounts[0].party_type = "Customer"
|
||||||
|
jv.accounts[0].party = "Overseas Customer"
|
||||||
|
|
||||||
|
jv.save()
|
||||||
|
jv.submit()
|
||||||
|
|
||||||
|
si = create_sales_invoice(
|
||||||
|
customer="Overseas Customer",
|
||||||
|
debit_to="_Test Receivable USD - _TC",
|
||||||
|
currency="USD",
|
||||||
|
conversion_rate=75,
|
||||||
|
do_not_save=1,
|
||||||
|
rate=100,
|
||||||
|
)
|
||||||
|
|
||||||
|
si.append(
|
||||||
|
"advances",
|
||||||
|
{
|
||||||
|
"reference_type": "Journal Entry",
|
||||||
|
"reference_name": jv.name,
|
||||||
|
"reference_row": jv.accounts[0].name,
|
||||||
|
"advance_amount": 100,
|
||||||
|
"allocated_amount": 100,
|
||||||
|
"ref_exchange_rate": 70,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
si.save()
|
||||||
|
si.submit()
|
||||||
|
|
||||||
|
expected_gle = [
|
||||||
|
["_Test Receivable USD - _TC", 7500.0, 500],
|
||||||
|
["Exchange Gain/Loss - _TC", 500.0, 0.0],
|
||||||
|
["Sales - _TC", 0.0, 7500.0],
|
||||||
|
]
|
||||||
|
|
||||||
|
check_gl_entries(self, si.name, expected_gle, nowdate())
|
||||||
|
|
||||||
|
frappe.db.set_value(
|
||||||
|
"Accounts Settings", "Accounts Settings", "unlink_payment_on_cancel_of_invoice", unlink_enabled
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_sales_invoice_for_e_invoice():
|
def get_sales_invoice_for_e_invoice():
|
||||||
si = make_sales_invoice_for_ewaybill()
|
si = make_sales_invoice_for_ewaybill()
|
||||||
|
@ -1980,7 +1980,7 @@ def get_advance_journal_entries(
|
|||||||
select
|
select
|
||||||
"Journal Entry" as reference_type, t1.name as reference_name,
|
"Journal Entry" as reference_type, t1.name as reference_name,
|
||||||
t1.remark as remarks, t2.{0} as amount, t2.name as reference_row,
|
t1.remark as remarks, t2.{0} as amount, t2.name as reference_row,
|
||||||
t2.reference_name as against_order
|
t2.reference_name as against_order, t2.exchange_rate
|
||||||
from
|
from
|
||||||
`tabJournal Entry` t1, `tabJournal Entry Account` t2
|
`tabJournal Entry` t1, `tabJournal Entry Account` t2
|
||||||
where
|
where
|
||||||
|
Loading…
Reference in New Issue
Block a user