Inter Company Journal Entry (#13683)
* rebase with enterprise_sprint * Add Inter company account checkbox in Account master * Add Inter Company Journal Entry Voucher Type in Journal Entry * Make Inter Company Journal Entry button * Dialog to select company for Inter Company Journal Entry * Map relevant fields in the Inter Company Journal Entry and reference links * Rebase * Add Documentation
This commit is contained in:
parent
6f3594b2e4
commit
ecb9315ea1
File diff suppressed because it is too large
Load Diff
@ -37,6 +37,55 @@ frappe.ui.form.on("Journal Entry", {
|
||||
|
||||
// hide /unhide fields based on currency
|
||||
erpnext.journal_entry.toggle_fields_based_on_currency(frm);
|
||||
|
||||
if ((frm.doc.voucher_type == "Inter Company Journal Entry") && (frm.doc.docstatus == 1) && (!frm.doc.inter_company_journal_entry_reference)) {
|
||||
frm.add_custom_button(__("Make Inter Company Journal Entry"),
|
||||
function() {
|
||||
frm.trigger("make_inter_company_journal_entry");
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
make_inter_company_journal_entry: function(frm) {
|
||||
var d = new frappe.ui.Dialog({
|
||||
title: __("Select Company"),
|
||||
fields: [
|
||||
{
|
||||
'fieldname': 'company',
|
||||
'fieldtype': 'Link',
|
||||
'label': __('Company'),
|
||||
'options': 'Company',
|
||||
"get_query": function () {
|
||||
return {
|
||||
filters: [
|
||||
["Company", "name", "!=", frm.doc.company]
|
||||
]
|
||||
};
|
||||
},
|
||||
'reqd': 1
|
||||
}
|
||||
],
|
||||
});
|
||||
d.set_primary_action(__("Make"), function() {
|
||||
d.hide();
|
||||
var args = d.get_values();
|
||||
frappe.call({
|
||||
args: {
|
||||
"name": frm.doc.name,
|
||||
"voucher_type": frm.doc.voucher_type,
|
||||
"company": args.company
|
||||
},
|
||||
method: "erpnext.accounts.doctype.journal_entry.journal_entry.make_inter_company_journal_entry",
|
||||
callback: function (r) {
|
||||
if (r.message) {
|
||||
var doc = frappe.model.sync(r.message)[0];
|
||||
frappe.set_route("Form", doc.doctype, doc.name);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
d.show();
|
||||
},
|
||||
|
||||
multi_currency: function(frm) {
|
||||
@ -549,9 +598,15 @@ $.extend(erpnext.journal_entry, {
|
||||
},
|
||||
|
||||
account_query: function(frm) {
|
||||
var inter_company = 0;
|
||||
if (frm.doc.voucher_type == "Inter Company Journal Entry") {
|
||||
inter_company = 1;
|
||||
}
|
||||
|
||||
var filters = {
|
||||
company: frm.doc.company,
|
||||
is_group: 0
|
||||
is_group: 0,
|
||||
inter_company_account: inter_company
|
||||
};
|
||||
if(!frm.doc.multi_currency) {
|
||||
$.extend(filters, {
|
||||
|
@ -96,7 +96,7 @@
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "voucher_type",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "Journal Entry\nBank Entry\nCash Entry\nCredit Card Entry\nDebit Note\nCredit Note\nContra Entry\nExcise Entry\nWrite Off Entry\nOpening Entry\nDepreciation Entry",
|
||||
"options": "Journal Entry\nInter Company Journal Entry\nBank Entry\nCash Entry\nCredit Card Entry\nDebit Note\nCredit Note\nContra Entry\nExcise Entry\nWrite Off Entry\nOpening Entry\nDepreciation Entry",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
@ -830,7 +830,7 @@
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
@ -841,6 +841,39 @@
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.voucher_type== \"Inter Company Journal Entry\"",
|
||||
"fieldname": "inter_company_journal_entry_reference",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Inter Company Journal Entry Reference",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Journal Entry",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
@ -1520,7 +1553,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"menu_index": 0,
|
||||
"modified": "2018-04-16 17:34:38.429196",
|
||||
"modified": "2018-05-02 11:12:55.090374",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Journal Entry",
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe, erpnext, json
|
||||
from frappe.utils import cstr, flt, fmt_money, formatdate, getdate
|
||||
from frappe.utils import cstr, flt, fmt_money, formatdate, getdate, nowdate
|
||||
from frappe import msgprint, _, scrub
|
||||
from erpnext.controllers.accounts_controller import AccountsController
|
||||
from erpnext.accounts.utils import get_balance_on, get_account_currency
|
||||
@ -40,15 +40,17 @@ class JournalEntry(AccountsController):
|
||||
self.validate_credit_debit_note()
|
||||
self.validate_empty_accounts_table()
|
||||
self.set_account_and_party_balance()
|
||||
self.validate_inter_company_accounts()
|
||||
if not self.title:
|
||||
self.title = self.get_title()
|
||||
|
||||
def on_submit(self):
|
||||
self.check_credit_limit()
|
||||
self.make_gl_entries()
|
||||
self.update_loan()
|
||||
self.update_advance_paid()
|
||||
self.update_expense_claim()
|
||||
self.update_loan()
|
||||
self.update_inter_company_jv()
|
||||
|
||||
def get_title(self):
|
||||
return self.pay_to_recd_from or self.accounts[0].account
|
||||
@ -64,6 +66,20 @@ class JournalEntry(AccountsController):
|
||||
for voucher_no in list(set(order_list)):
|
||||
frappe.get_doc(voucher_type, voucher_no).set_total_advance_paid()
|
||||
|
||||
def validate_inter_company_accounts(self):
|
||||
if self.voucher_type == "Inter Company Journal Entry" and self.inter_company_journal_entry_reference:
|
||||
doc = frappe.get_doc("Journal Entry", self.inter_company_journal_entry_reference)
|
||||
account_currency = frappe.db.get_value("Company", self.company, "default_currency")
|
||||
previous_account_currency = frappe.db.get_value("Company", doc.company, "default_currency")
|
||||
if account_currency == previous_account_currency:
|
||||
if self.total_credit != doc.total_debit or self.total_debit != doc.total_credit:
|
||||
frappe.throw(_("Total Credit/ Debit Amount should be same as linked Journal Entry"))
|
||||
|
||||
def update_inter_company_jv(self):
|
||||
if self.voucher_type == "Inter Company Journal Entry" and self.inter_company_journal_entry_reference:
|
||||
frappe.db.set_value("Journal Entry", self.inter_company_journal_entry_reference,\
|
||||
"inter_company_journal_entry_reference", self.name)
|
||||
|
||||
def on_cancel(self):
|
||||
from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
|
||||
from erpnext.hr.doctype.salary_slip.salary_slip import unlink_ref_doc_from_salary_slip
|
||||
@ -75,6 +91,7 @@ class JournalEntry(AccountsController):
|
||||
self.update_loan()
|
||||
self.unlink_advance_entry_reference()
|
||||
self.unlink_asset_reference()
|
||||
self.unlink_inter_company_jv()
|
||||
|
||||
def unlink_advance_entry_reference(self):
|
||||
for d in self.get("accounts"):
|
||||
@ -97,6 +114,13 @@ class JournalEntry(AccountsController):
|
||||
asset.db_set("value_after_depreciation", asset.value_after_depreciation)
|
||||
asset.set_status()
|
||||
|
||||
def unlink_inter_company_jv(self):
|
||||
if self.voucher_type == "Inter Company Journal Entry" and self.inter_company_journal_entry_reference:
|
||||
frappe.db.set_value("Journal Entry", self.inter_company_journal_entry_reference,\
|
||||
"inter_company_journal_entry_reference", "")
|
||||
frappe.db.set_value("Journal Entry", self.name,\
|
||||
"inter_company_journal_entry_reference", "")
|
||||
|
||||
def validate_party(self):
|
||||
for d in self.get("accounts"):
|
||||
account_type = frappe.db.get_value("Account", d.account, "account_type")
|
||||
@ -907,4 +931,13 @@ def get_average_exchange_rate(account):
|
||||
bank_balance_in_company_currency = get_balance_on(account, in_account_currency=False)
|
||||
exchange_rate = bank_balance_in_company_currency / bank_balance_in_account_currency
|
||||
|
||||
return exchange_rate
|
||||
return exchange_rate
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_inter_company_journal_entry(name, voucher_type, company):
|
||||
journal_entry = frappe.new_doc('Journal Entry')
|
||||
journal_entry.voucher_type = voucher_type
|
||||
journal_entry.company = company
|
||||
journal_entry.posting_date = nowdate()
|
||||
journal_entry.inter_company_journal_entry_reference = name
|
||||
return journal_entry.as_dict()
|
BIN
erpnext/docs/assets/img/accounts/inter-company-jv-submit.png
Normal file
BIN
erpnext/docs/assets/img/accounts/inter-company-jv-submit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 233 KiB |
BIN
erpnext/docs/assets/img/accounts/inter-company-jv.png
Normal file
BIN
erpnext/docs/assets/img/accounts/inter-company-jv.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 109 KiB |
BIN
erpnext/docs/assets/img/accounts/internal-account.png
Normal file
BIN
erpnext/docs/assets/img/accounts/internal-account.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 216 KiB |
BIN
erpnext/docs/assets/img/accounts/linked-jv.png
Normal file
BIN
erpnext/docs/assets/img/accounts/linked-jv.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 186 KiB |
BIN
erpnext/docs/assets/img/accounts/select-company-jv.png
Normal file
BIN
erpnext/docs/assets/img/accounts/select-company-jv.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 185 KiB |
@ -5,6 +5,7 @@ point-of-sale-pos-invoice
|
||||
purchase-invoice
|
||||
payments
|
||||
journal-entry
|
||||
inter-company-journal-entry
|
||||
payment-entry
|
||||
subscription
|
||||
multi-currency-accounting
|
||||
|
@ -0,0 +1,45 @@
|
||||
# Inter Company Journal Entry
|
||||
|
||||
You can also create Inter Company Journal Entry if you are making transactions with multiple Companies.
|
||||
You can select the Accounts which you wish to use in the Inter Company transactions.
|
||||
Just go to,
|
||||
|
||||
> Accounts > Company and Accounts > Chart Of Accounts
|
||||
|
||||
Select the Account which you would like to set as an Internal Account for the transaction, and check the **Inter Company Account** checkbox. It can now be used for Inter Company Journal Entry Transactions.
|
||||
|
||||
<img class="screenshot" alt="Internal Account" src="{{docs_base_url}}/assets/img/accounts/internal-account.png">
|
||||
|
||||
You need to do the same for all the Companies' Accounts which you want to use for Inter Company Journal Entry transactions.
|
||||
|
||||
Now, to create an Inter Company Journal Entry go to:
|
||||
|
||||
> Accounts > Company and Accounts > Journal Entry > New
|
||||
|
||||
<img class="screenshot" alt="Inter Company Journal Entry" src="{{docs_base_url}}/assets/img/accounts/inter-company-jv.png">
|
||||
|
||||
In the Journal Entry, you must select,
|
||||
|
||||
* Type of Voucher - **Inter Company Journal Entry**.
|
||||
* Add rows for the individual accounting entries. In each row, you must specify:
|
||||
* The Internal account that will be affected.
|
||||
* The amount to Debit or Credit.
|
||||
* The Cost Center (If it is an Income or Expense).
|
||||
|
||||
On submitting the Journal Entry, you will find a button on the top right corner, **Make Inter Company Journal Entry**.
|
||||
|
||||
<img class="screenshot" alt="Submitted Inter Company Journal Entry" src="{{docs_base_url}}/assets/img/accounts/inter-company-jv-submit.png">
|
||||
|
||||
Click on the button, you will be asked to select the Company against which you wish to create the linked Journal Entry.
|
||||
|
||||
<img class="screenshot" alt="Select Company" src="{{docs_base_url}}/assets/img/accounts/select-company-jv.png">
|
||||
|
||||
On selecting the Company, you will be routed to another Journal Entry where the relevant fields will be mapped, i.e. Company, Voucher Type, Inter Company Journal Entry Reference etc.
|
||||
|
||||
<img class="screenshot" alt="Linked Journal Entry" src="{{docs_base_url}}/assets/img/accounts/linked-jv.png">
|
||||
|
||||
Select the Internal accounts for the Company selected and submit the Journal Entry, make sure the total Debit and Credit Amounts are same as the previously created Journal Entry's total Credit and Debit Amounts respectively.
|
||||
|
||||
You can also find the reference link at the bottom, which will be added in both the linked Journal Entries and will be removed if any of the Journal Entries are cancelled.
|
||||
|
||||
{next}
|
Loading…
x
Reference in New Issue
Block a user