fix: make journal entry to sync stock and account balance
This commit is contained in:
parent
aff4a67954
commit
1ed1c4e6a4
@ -163,7 +163,10 @@ def validate_account_for_perpetual_inventory(gl_map):
|
|||||||
.format(account), StockAccountInvalidTransaction)
|
.format(account), StockAccountInvalidTransaction)
|
||||||
|
|
||||||
elif account_bal != stock_bal:
|
elif account_bal != stock_bal:
|
||||||
diff = flt(stock_bal - account_bal)
|
precision = get_field_precision(frappe.get_meta("GL Entry").get_field("debit"),
|
||||||
|
currency=frappe.get_cached_value('Company', gl_map[0].company, "default_currency"))
|
||||||
|
|
||||||
|
diff = flt(stock_bal - account_bal, precision)
|
||||||
error_reason = _("Stock Value ({0}) and Account Balance ({1}) are out of sync for account {2} and it's linked warehouses.").format(
|
error_reason = _("Stock Value ({0}) and Account Balance ({1}) are out of sync for account {2} and it's linked warehouses.").format(
|
||||||
stock_bal, account_bal, frappe.bold(account))
|
stock_bal, account_bal, frappe.bold(account))
|
||||||
error_resolution = _("Please create adjustment Journal Entry for amount {0} ").format(frappe.bold(diff))
|
error_resolution = _("Please create adjustment Journal Entry for amount {0} ").format(frappe.bold(diff))
|
||||||
@ -182,7 +185,7 @@ def validate_account_for_perpetual_inventory(gl_map):
|
|||||||
raise_exception=StockValueAndAccountBalanceOutOfSync,
|
raise_exception=StockValueAndAccountBalanceOutOfSync,
|
||||||
title=_('Values Out Of Sync'),
|
title=_('Values Out Of Sync'),
|
||||||
primary_action={
|
primary_action={
|
||||||
'label': 'Make JV',
|
'label': 'Make Journal Entry',
|
||||||
'client_action': 'erpnext.route_to_adjustment_jv',
|
'client_action': 'erpnext.route_to_adjustment_jv',
|
||||||
'args': journal_entry_args
|
'args': journal_entry_args
|
||||||
})
|
})
|
||||||
|
@ -355,20 +355,4 @@ cur_frm.pformat.taxes= function(doc){
|
|||||||
out += '</table></td></tr></table></div>';
|
out += '</table></td></tr></table></div>';
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
|
||||||
|
|
||||||
erpnext.route_to_adjustment_jv = (args) => {
|
|
||||||
frappe.model.with_doctype('Journal Entry', () => {
|
|
||||||
// route to adjustment Journal Entry to handle Account Balance and Stock Value mismatch
|
|
||||||
let journal_entry = frappe.model.get_new_doc('Journal Entry');
|
|
||||||
|
|
||||||
args.accounts.forEach((je_account) => {
|
|
||||||
let child_row = frappe.model.add_child(journal_entry, "accounts");
|
|
||||||
child_row.account = je_account.account;
|
|
||||||
child_row.debit_in_account_currency = je_account.debit_in_account_currency;
|
|
||||||
child_row.credit_in_account_currency = je_account.credit_in_account_currency;
|
|
||||||
child_row.party_type = "" ;
|
|
||||||
});
|
|
||||||
frappe.set_route('Form','Journal Entry', journal_entry.name);
|
|
||||||
});
|
|
||||||
}
|
}
|
@ -74,6 +74,22 @@ $.extend(erpnext, {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
route_to_adjustment_jv: (args) => {
|
||||||
|
frappe.model.with_doctype('Journal Entry', () => {
|
||||||
|
// route to adjustment Journal Entry to handle Account Balance and Stock Value mismatch
|
||||||
|
let journal_entry = frappe.model.get_new_doc('Journal Entry');
|
||||||
|
|
||||||
|
args.accounts.forEach((je_account) => {
|
||||||
|
let child_row = frappe.model.add_child(journal_entry, "accounts");
|
||||||
|
child_row.account = je_account.account;
|
||||||
|
child_row.debit_in_account_currency = je_account.debit_in_account_currency;
|
||||||
|
child_row.credit_in_account_currency = je_account.credit_in_account_currency;
|
||||||
|
child_row.party_type = "" ;
|
||||||
|
});
|
||||||
|
frappe.set_route('Form','Journal Entry', journal_entry.name);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user