netsuite SyncQtyRate-CarlZeng
function SyncQtyRate()206{207 var form = document.forms[‘item_form’];208 // Make sure all the fields are there. Otherwise, bail out.209 if (!(form.elements[‘rateschedule’] && form.elements[‘quantity’]…
function SyncQtyRate()
206{
207 var form = document.forms[‘item_form’];
208 // Make sure all the fields are there. Otherwise, bail out.
209 if (!(form.elements[‘rateschedule’] && form.elements[‘quantity’]))
210 return;
211 // If this line is a credit of some other doc, retain the original QtyRate on the line
212 if ( (form.elements[‘orderdoc’] && form.elements[‘orderdoc’].value.length > 0) || (form.elements[‘srcline’] && form.elements[‘srcline’].value.length > 0) )
213 return;
214 var schedstr = form.elements[‘rateschedule’].value;
215 var qty = parseFloat(form.elements[‘quantity’].value);
216 var marginal = ‘T’ == form.elements[‘marginal’].value;
217 var overallqtydisc = form.elements[‘overallqtydisc’].value;
218 if (overallqtydisc.length>0)
219 {
220 var linecount=item_machine.getNextIndex()-1;
221 var linenum=item_machine.getMachineIndex();
222 var qtygroup=parseInt(form.elements[‘qtygroup’].value);
223 for (var j=1; j <= linecount; j++)
224 if (j != linenum && getEncodedValue(‘item’,j,’overallqtydisc’) == overallqtydisc && parseInt(getEncodedValue(‘item’,j,’qtygroup’)) == qtygroup && parseFloat(getEncodedValue(‘item’,j,’quantity’))>0) qty += parseFloat(getEncodedValue(‘item’,j,’quantity’));
225 }
226 var bCustomPriceLevel = form.elements[‘price’] != null && parseFloat(form.elements[‘price’].value) == -1;
227
228 if (schedstr.length>0 && !isNaN(qty) && !bCustomPriceLevel)
229 {
230 form.elements[‘rate’].value=format_rate(round_float(getQtyRate(schedstr,qty,marginal)));
231 fireProperOnChange(form.elements[‘rate’]);
232 }
233}