/* ----------------------------------------------------------------------------------------------------------------
*	
Function:	addMarkUpDollarPerQty

Functionality:
Adds markup price (in $) entered at line item to the amount at line item.
Amount = (Rate + Markup) * Quantity.

Deployment:
The script can be deployed on Sales Order.

Event triggering the script:
	1) validate Line.

Custom Fields:
+-----------------------------------------------------------------------------------------------------------------+
| S. No.|	Id					|	Type			|	Level	|		Description							
+-----------------------------------------------------------------------------------------------------------------+
| (1)	|	_markupdollar		|	Currency		|	Column	|	It holds markup price at line items.		|

Create above custom fields with their id and type as mentioned in table.
*------------------------------------------------------------------------------------------------------------------
*/

function addMarkUpDollarPerQty()
{
	var markUp = nlapiGetCurrentLineItemValue('item', 'custcol_markupdollar');
	if (markUp == null || markUp.length == 0 || isNaN(markUp))
	{
		markUp = 0;
	}
	
	var qty = nlapiGetCurrentLineItemValue('item', 'quantity');
	if (qty == null || qty.length == 0 || isNaN(qty))
	{
		qty = 0;
	}

	var amt = nlapiGetCurrentLineItemValue('item', 'amount');
	if (amt == null || amt.length == 0 || isNaN(amt))
	{
		amt = 0;
	}

	var rate = nlapiGetCurrentLineItemValue('item', 'rate');
	if (rate == null || rate.length == 0 || isNaN(rate))
	{
		rate = 0;
	}
	
	amt = parseFloat( (parseFloat(rate) + parseFloat(markUp)) * parseInt(qty) );
	nlapiSetCurrentLineItemValue('item', 'amount', amt);
	return true;
}