Function to create a customer deposit for Shopify order

/**
* @description the function for creating a customer deposit
* @param customerID{Number|String}- the customer record Internal ID
* @param salesOrderID{Number|String} -the internal ID of the sales order
* @param shopifyRecordId{Number|String} - the shopify integration custom record Internal ID
* @returns {Number|String}
*/
createCustomerDeposit(
customerID,
salesOrderID,
listOrder,
shopifyRecordId
) {
try {
var customerDepositRecord = record.create({
type: record.Type.CUSTOMER_DEPOSIT,
isDynamic: true,
});
customerDepositRecord.setValue({
fieldId: "customer",
value: customerID,
});
customerDepositRecord.setValue({
fieldId: "salesorder",
value: salesOrderID,
});
customerDepositRecord.setValue({
fieldId: "payment",
value: listOrder.subtotal_price.toString().trim(),
});
customerDepositRecord.setValue({
fieldId: "paymentmethod",
value: PAYMENT_METHOD
});
var cDRecordID = customerDepositRecord.save({
enableSourcing: true,
ignoreMandatoryFields: true
});
log.debug("CDRecordID", cDRecordID);

record.submitFields({
type: "customrecord_shopify_int_info",
id: shopifyRecordId,
values: {
custrecord_jj_cust_deposit: cDRecordID,
custrecord_jj_err_on_cust_creation: "",
},
options: {enableSourcing: true, ignoreMandatoryFields: true},
});
return jjUtil.checkForParameter(cDRecordID) ? cDRecordID : false;

} catch (err) {
log.error("error@createCustomerDeposit", err);
record.submitFields({
type: "customrecord_shopify_int_info",
id: shopifyRecordId,
values: {
"custrecord_jj_err_on_cust_creation": JSON.stringify(err),
},
options: {enableSourcing: true, ignoreMandatoryFields: true},
});
return false;
}
},

Leave a comment

Your email address will not be published. Required fields are marked *