How do I mass apply a payment against open sales o...
# ask-stanley-ai
g
How do I mass apply a payment against open sales orders
c
AI generated answer (using internal Slack threads):
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** To mass apply a payment against open sales orders in NetSuite, you can use a SuiteScript. Here is a sample script that was discussed in the threads:
Copy code
var payment = record.load({
    type: record.Type.CUSTOMER_PAYMENT,
    id: srch.id,
    isDynamic: true
});
var unappliedAmount = payment.getValue('unapplied');
if (unappliedAmount > 0){
    payment.selectNewLine({
        sublistId: "apply"
    });

    payment.setCurrentSublistValue({
        sublistId: 'apply',
        fieldId: 'apply',
        value: true
    });
    payment.setCurrentSublistValue({
        sublistId: 'apply',
        fieldId: 'payment',
        value: unappliedAmount
    });
    payment.setCurrentSublistValue({
        sublistId: 'apply',
        fieldId: 'internalid',
        value: openInvoices[i].id
    });
    payment.commitLine({
        sublistId: 'item'
    });
    var saveRet = payment.save({
        enableSourcing: false,
        ignoreMandatoryFields: true
    });
    log.debug("saveRet", saveRet);
}
This script loads a payment record, checks if there is an unapplied amount, and if so, applies it to an open invoice. For mass billing of sales orders that are in the state of "Pending Billing", you can use the "Invoice Sales Orders" batch process. This process will create Cash Sales when appropriate (credit card associated to SO or Cash payment). If there is a customer deposit against the sales order, then an invoice will be generated and the deposit will be automatically applied leaving the invoice in the fully paid status. For sales orders with payment terms of prepaid, you can use a custom field (not stored) that gets its source from a saved search, calculating up all the deposit amounts applied to the SO. Then use a Scheduled Workflow to check every 30min and update the Customer Payment status or even just an Applied Deposit Amount field on the SO.
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.817317486
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.812322497
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.80902791
Please provide your feedback on this answer.