Merge branch 'marination-account_stock_sync_error' into develop
This commit is contained in:
commit
2fd6814cbf
@ -163,16 +163,32 @@ def validate_account_for_perpetual_inventory(gl_map):
|
|||||||
.format(account), StockAccountInvalidTransaction)
|
.format(account), StockAccountInvalidTransaction)
|
||||||
|
|
||||||
elif account_bal != stock_bal:
|
elif account_bal != stock_bal:
|
||||||
error_reason = _("Account Balance ({0}) and Stock Value ({1}) is out of sync for account {2} and it's linked warehouses.").format(
|
precision = get_field_precision(frappe.get_meta("GL Entry").get_field("debit"),
|
||||||
account_bal, stock_bal, frappe.bold(account))
|
currency=frappe.get_cached_value('Company', gl_map[0].company, "default_currency"))
|
||||||
error_resolution = _("Please create adjustment Journal Entry for amount {0} ").format(frappe.bold(stock_bal - account_bal))
|
|
||||||
button_text = _("Make Adjustment Entry")
|
|
||||||
|
|
||||||
frappe.throw("""{0}<br></br>{1}<br></br>
|
diff = flt(stock_bal - account_bal, precision)
|
||||||
<div style="text-align:right;">
|
error_reason = _("Stock Value ({0}) and Account Balance ({1}) are out of sync for account {2} and it's linked warehouses.").format(
|
||||||
<button class="btn btn-primary" onclick="frappe.new_doc('Journal Entry')">{2}</button>
|
stock_bal, account_bal, frappe.bold(account))
|
||||||
</div>""".format(error_reason, error_resolution, button_text),
|
error_resolution = _("Please create adjustment Journal Entry for amount {0} ").format(frappe.bold(diff))
|
||||||
StockValueAndAccountBalanceOutOfSync, title=_('Account Balance Out Of Sync'))
|
stock_adjustment_account = frappe.db.get_value("Company",gl_map[0].company,"stock_adjustment_account")
|
||||||
|
|
||||||
|
db_or_cr_warehouse_account =('credit_in_account_currency' if diff < 0 else 'debit_in_account_currency')
|
||||||
|
db_or_cr_stock_adjustment_account = ('debit_in_account_currency' if diff < 0 else 'credit_in_account_currency')
|
||||||
|
|
||||||
|
journal_entry_args = {
|
||||||
|
'accounts':[
|
||||||
|
{'account': account, db_or_cr_warehouse_account : abs(diff)},
|
||||||
|
{'account': stock_adjustment_account, db_or_cr_stock_adjustment_account : abs(diff) }]
|
||||||
|
}
|
||||||
|
|
||||||
|
frappe.msgprint(msg="""{0}<br></br>{1}<br></br>""".format(error_reason, error_resolution),
|
||||||
|
raise_exception=StockValueAndAccountBalanceOutOfSync,
|
||||||
|
title=_('Values Out Of Sync'),
|
||||||
|
primary_action={
|
||||||
|
'label': 'Make Journal Entry',
|
||||||
|
'client_action': 'erpnext.route_to_adjustment_jv',
|
||||||
|
'args': journal_entry_args
|
||||||
|
})
|
||||||
|
|
||||||
def validate_cwip_accounts(gl_map):
|
def validate_cwip_accounts(gl_map):
|
||||||
cwip_enabled = any([cint(ac.enable_cwip_accounting) for ac in frappe.db.get_all("Asset Category","enable_cwip_accounting")])
|
cwip_enabled = any([cint(ac.enable_cwip_accounting) for ac in frappe.db.get_all("Asset Category","enable_cwip_accounting")])
|
||||||
|
@ -64,7 +64,7 @@ frappe.ui.form.on(cur_frm.doctype, {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on('Sales Invoice Payment', {
|
frappe.ui.form.on('Sales Invoice Payment', {
|
||||||
@ -355,4 +355,4 @@ cur_frm.pformat.taxes= function(doc){
|
|||||||
out += '</table></td></tr></table></div>';
|
out += '</table></td></tr></table></div>';
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
@ -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