Billing Schedule
This record enables you to create a billing schedule that can be applied to a sales order, a line item on a sales order, or a project. SuiteScript supports all five types of billing schedules (charge-based, fixed bid interval, fixed bid milestone, standard, and time and materials).
The internal ID for this record is billingschedule
.
To use the billing schedule record, you must enable the Advanced Billing feature, at Setup > Company > Enable Features, on the Transactions subtab. In the UI, you access this record at Lists > Accounting > Billing Schedules > New. You can access a billing schedule of fixed bid milestone type through the project record’s Financial tab.
For help working with this record in the UI, see Billing Schedules.
See the SuiteScript Records Browser for all internal IDs associated with this record.
For information about using the SuiteScript Records Browser, see Working with the SuiteScript Records Browser in the NetSuite Help Center.
For information about scripting with this record in SuiteScript, see the following help topics:
Supported Script Types
Billing Schedule is scriptable in server SuiteScript only.
Both beforeSubmit
, and afterSubmit
user events are supported.
Supported Functions
This record is fully scriptable, which means that the record can be created, updated, copied, deleted, and searched using SuiteScript.
Usage Notes
Additionally, note the following:
-
To set a value for schedule type, which is a required body field, you must use initializeValues, not setValue. For examples, see the following section.
-
If you choose a schedule type of fixed bid milestone, you must identify an existing project record (or job record). You do so using initializeValues. Then, to create a link between the project and the new billing schedule, you must update the project record — this relationship is not established automatically when you create the billing schedule.
-
The Recurrence sublist is available only when schedule type is set to Standard and frequency to Custom.
-
The Milestone sublist is available only when schedule type is set to Fixed Bid Milestone.
Code Samples
The following samples show how to create different types of billing schedules.
Creating a Charge-Based Billing Schedule
The following sample shows how to create a charge-based billing schedule.
var SCHEDULE_TYPE = 'CB'; //Charge-Based
var recName = SCHEDULE_TYPE + 'record';
var initValues = new Array();
initValues.schedtype = SCHEDULE_TYPE;
//Create record
var myBillingSched = record.create({
type: record.Type.BILLING_SCHEDULE,
defaultValues: {
'schedtype': SCHEDULE_TYPE
}
});
myBillingSched.setValue({
fieldId: 'externalid',
value: 'EXTID001'
});
myBillingSched.setValue({
fieldId: 'name',
value: recName
});
myBillingSched.setValue({
fieldId: 'frequency',
value: 'DAILY'
});
myBillingSched.setValue({
fieldId: 'dayperiod',
value: '3'
});
var recId = myBillingSched.save();
Creating a Fixed Bid Milestone Billing Schedule
The following sample shows how to create a billing schedule of fixed bid milestone type. Note that this sample references a particular project record during the creation of the billing schedule. However, you still have to establish the relationship between the billing schedule and the project as a separate step.
var SCHEDULE_TYPE = 'FBM'; // Fixed Bid, Milestone
var P1 = '117'; // Project1
var P1M1 = '112'; // Project1 - Milestone1
var P1M2 = '113'; // Project2 - Milestone2
var recId = null;
var recName = SCHEDULE_TYPE + " record";
var initValues = new Array();
initValues.schedtype = SCHEDULE_TYPE;
initValues.project = P1;
//Create record
var myBillingSched = record.create({
type: record.Type.BILLING_SCHEDULE,
isDynamic: true,
defaultValues: initValues
});
myBillingSched.setValue({
fieldId: 'name',
value: recName
});
myBillingSched.setValue({
fieldId: 'initialamount',
value: '10' // 10%
});
//Create the sublist
myBillingSched.selectNewLine({
sublistId: 'milestone'
});
myBillingSched.setCurrentSublistValue({
sublistId: 'milestone',
fieldId: 'milestoneamount',
value: '25' // 25%
});
myBillingSched.setCurrentSublistValue({
sublistId: 'milestone',
fieldId: 'milestonedate',
value: new Date('November 21, 2013')
});
myBillingSched.setCurrentSublistValue({
sublistId: 'milestone',
fieldId: 'projecttask',
value: P1M1
});
myBillingSched.commitLine({
sublistId: 'milestone'
});
recId = myBillingSched.save();
//Update the project (link it with the newly created Billing Schedule)
var project = record.load({
type: record.Type.JOB,
id: P1
});
project.setValue({
fieldId: 'jobbillingtype',
value: SCHEDULE_TYPE
});
project.setValue({
fieldId: 'billingschedule',
value: recId
});
var pId = project.save();