如何在 NetSuite 中查找与客户退款相关的客户存款
How to find the Customer Deposits associated with a Customer Refund in NetSuite
我有客户退款记录,现在我需要查找关联的客户存款记录?我查看了 SuiteScript 记录浏览器,但没有看到其中的数据字段来连接它们。
谢谢,
拉斯
如果您仍在尝试处理特定销售订单的存款,您可以进行简单的搜索:
nlapiSearchRecord('customerdeposit', null, new nlobjSearchFilter('createdfrom', null, 'is', 1217));
//1217 is internal id of original sales order
但是,如果您仍然要求退还特定押金,您还应该知道正确创建客户退款的方法仍未记录在案:
var cr = nlapiCreateRecord('customerrefund',{entity:127}); // id of customer
cr.setFieldValue('paymentmethod', 1);
//may need to cycle through deposit lines to find the right one(s)
//cr.setLineItemValue('deposit', 'doc', 1, '1226');
//cr.setLineItemValue('deposit', 'amount', 1, 500);
cr.setLineItemValue('deposit', 'apply', 1, 'T'); // need this for at least one line.
nlapiSubmitRecord(cr);
然后如果你想再次找到受影响的存款,那就很奇怪了。如果您可以从退款的文件编号开始,您将收集应用它的交易 ID,然后获取适用于这些交易的交易:
var appliedIds = nlapiSearchRecord('customerrefund', null, [new nlobjSearchFilter('tranid', null, 'is', '2073'),
new nlobjSearchFilter('applyingtransaction', null, 'noneof', ['@NONE@'])
], [
new nlobjSearchColumn('tranid'),
new nlobjSearchColumn('applyingtransaction'),
new nlobjSearchColumn('applyinglinktype')
]).map(function(cr) {
console.log(cr.getValue('deposit', 'applying'));
console.log(cr.getValue('applyinglinktype'));
if ('payment' == cr.getValue('applyinglinktype')) {
return cr.getValue('applyingtransaction');
}
return null;
}).filter(function(id) {
return id;
});
nlapiSearchRecord('depositapplication', null, [
new nlobjSearchFilter('internalid', null, 'anyof', appliedIds),
new nlobjSearchFilter('appliedtolinktype', null, 'anyof', ['DepAppl'])
], new nlobjSearchColumn('appliedtotransaction')).
forEach(function(da) {
console.log(da.getValue('appliedtotransaction'));
});
我有客户退款记录,现在我需要查找关联的客户存款记录?我查看了 SuiteScript 记录浏览器,但没有看到其中的数据字段来连接它们。
谢谢, 拉斯
如果您仍在尝试处理特定销售订单的存款,您可以进行简单的搜索:
nlapiSearchRecord('customerdeposit', null, new nlobjSearchFilter('createdfrom', null, 'is', 1217));
//1217 is internal id of original sales order
但是,如果您仍然要求退还特定押金,您还应该知道正确创建客户退款的方法仍未记录在案:
var cr = nlapiCreateRecord('customerrefund',{entity:127}); // id of customer
cr.setFieldValue('paymentmethod', 1);
//may need to cycle through deposit lines to find the right one(s)
//cr.setLineItemValue('deposit', 'doc', 1, '1226');
//cr.setLineItemValue('deposit', 'amount', 1, 500);
cr.setLineItemValue('deposit', 'apply', 1, 'T'); // need this for at least one line.
nlapiSubmitRecord(cr);
然后如果你想再次找到受影响的存款,那就很奇怪了。如果您可以从退款的文件编号开始,您将收集应用它的交易 ID,然后获取适用于这些交易的交易:
var appliedIds = nlapiSearchRecord('customerrefund', null, [new nlobjSearchFilter('tranid', null, 'is', '2073'),
new nlobjSearchFilter('applyingtransaction', null, 'noneof', ['@NONE@'])
], [
new nlobjSearchColumn('tranid'),
new nlobjSearchColumn('applyingtransaction'),
new nlobjSearchColumn('applyinglinktype')
]).map(function(cr) {
console.log(cr.getValue('deposit', 'applying'));
console.log(cr.getValue('applyinglinktype'));
if ('payment' == cr.getValue('applyinglinktype')) {
return cr.getValue('applyingtransaction');
}
return null;
}).filter(function(id) {
return id;
});
nlapiSearchRecord('depositapplication', null, [
new nlobjSearchFilter('internalid', null, 'anyof', appliedIds),
new nlobjSearchFilter('appliedtolinktype', null, 'anyof', ['DepAppl'])
], new nlobjSearchColumn('appliedtotransaction')).
forEach(function(da) {
console.log(da.getValue('appliedtotransaction'));
});