Intercompany Journal Entry

Hello! I’m new using Frappe/ERPNext and I have a task to do.

The company is a group of 15 companies or so and when I need to make a new entry regarding intercompany transfers, I have to make an outcome entry for the main company and then make an income entry for one of the companies involved.

Is there a way to customize a form so I can make this entry once for both companies?

Hi @Gstv-web

The following documentation will help;

https://docs.frappe.io/erpnext/user/manual/en/inter-company-journal-entry

Yeah, I read this before, but this way I need to make the other entry manually, right?

Is there a way to do this once for both sides?

I’m not being routed to the other entry as the doc shows, no matter what I do.

Since company is a legal entity therefore you should pass JV separately under two companies.
Transfer of fund should be treated as investment/loan.

In Company A books
Company B debit xxx
Bank/Cash credit xxx

In Company B books
Bank/Cash debit xxx
Company A credit xxx

I understand that, but is it possible to create some custom stuff so I don’t need to access both books?

Yes, through customisation you can implement required functionality.

Is there a topic related to this?
I saw some instructions of creating custom doctypes by creating an app with bench commands, everything went well until install-app, the UI start crashing saying that a module was not found.

I’m using the frappe_docker repo for this. Is this the correct way?

You don’t need to create a custom doctype for this. Look into Server Scripts. They’ll do everything you need.

I’ve read about this and seems to be the way for it, but it was so difficult creating a new field that I’m not really sure now on what is not working after doing some tests. Keeps making just one register.

Hey, I was trying all these days to make a server script for this, but I’m getting NameError: name ‘inplacevar’ is not defined every time and I can’t find where.

Is there a nice topic about that?

I’m getting an error saying both debit and credit cannot be zero, but these are the unused fields of that line. I can’t print type() in server script and I really don’t know whats going on. I tried empty fields as well and getting the same error.

If you post your code, people might be able to spot the issue.

It’s not the complete code. I’m putting the info where things go wrong:

debit = float(doc.accounts[0].debit)
credit = float(doc.accounts[1].credit)

# new journal entry with swapped values
novo = frappe.get_doc({
    "doctype": "Journal Entry",
    "voucher_type": vtype,
    "company": nova_principal,
    "posting_date": post_date,
    "is_system_generated": 1,
    "accounts": [
        {
            "account": "Bancos - AUT",
            "debit": 0.0,
            "credit": debit,
            "custom_empresa_contraparte": nova_contraparte
        },
        {
            "account": "Transf entre empresas a receber - AUT",
            "debit": credit,
            "credit": 0.0,
            "custom_empresa_contraparte": nova_contraparte
        }
    ]
})
novo.insert(ignore_permissions=True)
novo.submit()

The error says that both debit and credit can’t be zero.

What have you done to troubleshoot? Are you sure accounts[0].debit and accounts[1].credit have values when the script gets called? You can output values to the javascript console by calling print().

I’m pretty sure, I’m using frappe.msgprint() to show the values after saving.
I get the debit from the first account row (credit is empty) and then the credit from second row (debit is empty).

I’m basically mirroring the values I already have, but there’s no warning keeping those fields empty while doing from the UI

Is there a model somewhere of a journal entry code? I couldn’t find anything that could help me.