2016-01-29 57 views

回答

1

如果你仍在努力应对存款对于特定的销售订单,你可以做一个简单的搜索:

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,然后获取适用的交易ID:

var appliedIds = nlapiSearchRecord('customerrefund', null, [new nlobjSearchFilter('tranid', null, 'is', '2073'), 
    new nlobjSearchFilter('applyingtransaction', null, 'noneof', ['@[email protected]']) 
], [ 
    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')); 
}); 
+0

我还没有机会尝试此操作,但它看起来像我在找什么。 –

相关问题