Posting GL Entries using Server Script

Hi,
I am posting the gl entries using server script after submitting Sales Invoice as well as Purchase Invoice. But after a while those GL entries gets deleted on it’s own. I think there is a background script running which detects any custom GL entry and deletes from the db.

Does anyone know about this?

Why? What are your JEs doing that can’t be solved in the invoice?

There are a few different things that could do this, depending on how you’ve got your GL Entries defined. In any case, this is generally a bad idea. GL Entries weren’t meant to be created directly.

Basically,

Client wants GL entries on internal transfer. We are doing internal transfer using Sales Invoice & Purchase invoice.

This is not enough of an explanation to be able to begin to help you with this problem. Is this an intercompany transaction? There’s a built in feature for that that I promise will work better. This sounds like a requirement that is coming from a previous system and it’s likely not required (or is automatic) in ERPNext.

Yes, this is intercompany stock transfer using Sales Invoice & Purchase Invoice.

Actually the scenario is, I am creating internal transfers between 2 companies using Sales Invoice & Purchase Invoice. Now, The records are created perfectly and even Stock is getting transferred correctly.

Now, the problem arises in trial balance. Item Valuation are incorrect. Since GL is not impacted in internal transfers by default. Hence, I used server script to create those entries. GL entries are created successfully. But it get’s deleted automatically.

Since GL is not impacted in internal transfers by default.

Your related parties aren’t configured correctly. This absolutely happens in correctly configured intercompany transactions. You shouldn’t be creating GL entries without a source document. If you do the work to connect the handwritten GL entries, you’ll end reproducing the work that already exists for intercompany transactions.

My advice is to fix your process and remove your script.