2016-01-29 55 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

我還沒有機會嘗試此操作,但它看起來像我在找什麼。 –