Can I refund a customer based on calculated item p...
# suitescript
d
Can I refund a customer based on calculated item price. Let say I have a $40/month item, Customer has used for 15days and he is cancelling then I need to refund him $20.
b
what sort of transaction do you wish to make
common choices are cash refund or customer refund
d
Customer refund I am looking at but do we need to manually calculate refund amount?
Copy code
var ref = nlapiCreateRecord('customerrefund', {entity:996,customform:41});
for(var i = ref.getLineItemCount('apply'); i>0; i--){
    if(1189 == ref.getLineItemValue('apply', 'doc', i)){
    ref.setLineItemValue('apply', 'apply', i, 'T');
    ref.setLineItemValue('apply', 'amount', i, ref.getLineItemValue('apply', 'due', i));
}
console.log(
i +' '+
ref.getLineItemValue('apply', 'doc', i) +' '+ 
ref.getLineItemValue('apply', 'apply', i) +' '+ 
ref.getLineItemValue('apply', 'amount', i) + ' '+
ref.getLineItemValue('apply', 'total', i));
}
console.log(nlapiSubmitRecord(ref, true));
@battk ^^
b
customer refund is more aimed at refunding a transaction rather than an item
you probably want to create a credit memo first, and then refund the credit memo
that said, i believe customer refund auto calculates the refund amount from the apply sublist
d
Thanks for the information and help I will dig into more.