how to show a sales order with zero amount and no ...
# ask-stanley-ai
h
how to show a sales order with zero amount and no billing schedule as billed
c
AI generated answer (using internal Slack threads):
To show a sales order with zero amount and no billing schedule as billed, you can follow these steps: 1. Create a custom field on the sales order line level that will be used to indicate whether the line should be billed or not. This field can be a checkbox type. 2. Use a SuiteScript to set this custom field to 'true' for the lines that should be billed and 'false' for the lines that should not be billed. This script can be triggered on the 'create' and 'edit' events of the sales order. 3. When creating the invoice from the sales order, use another SuiteScript to check this custom field on each line. If the field is 'true', include the line in the invoice. If the field is 'false', skip the line. 4. After the invoice is created, you can mark the sales order as 'billed' by setting the 'status' field to 'Billed'. This can be done using a SuiteScript. Here is a sample SuiteScript code for step 2:
Copy code
javascript
function beforeSubmit(type) {
    if (type == 'create' || type == 'edit') {
        var record = nlapiGetNewRecord();
        var lineCount = record.getLineItemCount('item');
        for (var i = 1; i <= lineCount; i++) {
            var amount = record.getLineItemValue('item', 'amount', i);
            var billingSchedule = record.getLineItemValue('item', 'billingschedule', i);
            if (amount == 0 && !billingSchedule) {
                record.setLineItemValue('item', 'custcol_should_be_billed', i, 'F');
            } else {
                record.setLineItemValue('item', 'custcol_should_be_billed', i, 'T');
            }
        }
    }
}
Please replace 'custcol_should_be_billed' with the actual ID of your custom field. ****** 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.824589789
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.822114766
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.818396628
Please provide your feedback on this answer.