give me an example of a custom GL Plugin script, w...
# ask-stanley-ai
m
give me an example of a custom GL Plugin script, which adjusts the G/L impact on a transaction
c
AI generated answer (using internal Slack threads):
Here is an example of a custom GL Plugin script that adjusts the G/L impact on a transaction:
Copy code
javascript
function customizeGlImpact(transactionRecord, standardLines, customLines, book) {
    var currLine = standardLines.getLine(0);
    var entityId = currLine.getEntityId();
    var recordType = transactionRecord.getRecordType();
    
    if(recordType == 'customerdeposit') {
        var gl_custdep = customLines.addNewLine();
        gl_custdep.setDebitAmount(standardLines.getLine(1).getCreditAmount());
        gl_custdep.setAccountId(standardLines.getLine(1).getAccountId());
        gl_custdep.setEntityId(entityId);
        gl_custdep.setMemo("Custom GL going to Deferred Revenue");

        var gl_defrev = customLines.addNewLine();
        gl_defrev.setCreditAmount(standardLines.getLine(1).getCreditAmount()); 
        gl_defrev.setAccountId(1283);
        gl_defrev.setEntityId(entityId);
        gl_defrev.setMemo("Custom GL going to Deferred Revenue");
    }
}
This script is designed to adjust the G/L impact of a 'customerdeposit' transaction. It adds two new lines to the G/L impact: one that debits the same amount and account as the original line, and another that credits a specific account (in this case, account 1283) with the same amount. Both lines are associated with the same entity and have a memo indicating that they are custom G/L lines going to Deferred Revenue. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.85869664
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.847262204
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.8400231
Please provide your feedback on this answer.