adjusted cost base




JavaScript Source Code 3000: Calculators: Adjusted Cost Base







































Adjusted Cost Base







Computes the average cost base (or cost per share) for a series of stock or mutual fund purchases. When a sale is entered, the capital gain (or loss) is calculated.








Adjusted Cost Base Calculator

# of Units



Cost per Unit



Transaction Type
Bought
Sold






Total Units


Total Cost



Adjusted Base Cost



Gain or Loss










JavaScript Source Code 3000: Calculators: Adjusted Cost Base
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!!





    





<!-- TWO STEPS TO INSTALL ADJUSTED COST BASE:

1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Gordon Coverley (gordonc@mondenet.com) -->

<! >
<! >

<!-- Begin
var tot_units = 0;
var tot_cost = 0;
function acbCalc(acbForm) {
with (acbForm) {
if (!unitsnum.value || isNaN(unitsnum.value) || !unitscost.value || isNaN(unitscost.value) ) {
alert("Please re-enter the units and cost amounts again.");
return;
}
else {
if (saletype[0].checked) { // bought
CapGain.value = "";
tot_units += unitsnum.value*1;
total_units.value = tot_units;
tot_cost += (unitsnum.value*1) * (unitscost.value*1);
total_cost.value = d_places(tot_cost, 4);
acb.value = d_places(tot_cost/tot_units, 4);
CapGain.value = "-- sales only --";
}
else { // sold
if ((unitsnum.value*-1 + tot_units*1) >= 0) {
tot_units -= unitsnum.value;
total_units.value = tot_units;
tot_cost = tot_units * acb.value;
total_cost.value = d_places(tot_cost, 4);
CapGain.value = d_places(unitsnum.value*(unitscost.value - acb.value), 2);
}
else {
alert("You don't have that many units to sell."); return;
}
}
}
}
// sets the decimal precision
function d_places(n,p) {
var factor = 1;
var ans = 0;
var j = 0;
for (j = 1; j <= p; j++)
factor = factor * 10.0;
ans = (Math.round((n + 0.05 / (factor) ) * factor)) / factor;
return ans;
}
}
// End -->
</script>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<center>
<form>
<table border=1 cellpadding=5 cellspacing=0><tr><td>
<table>
<th colspan=2>Adjusted Cost Base Calculator<p></th>
<tr>
<td># of Units</td>
<td><input type=text name=unitsnum size=15 maxlength=10></td>
</tr>
<tr>
<td>Cost per Unit</td>
<td><input type=text name=unitscost size=15 maxlength=10></td>
</tr>
<tr>
<td>Transaction Type</td>
<td><input type=radio name=saletype value="1" checked>Bought
<br><input type=radio name=saletype value="-1">Sold
</td>
</tr>
<tr>
<td colspan=2 align=center><input type=button value="Add This Transaction" onClick="acbCalc(this.form);"></td>
</tr>
<tr>
<td>Total Units</td>
<td><input type=text name=total_units size=15 readonly></td>
</tr>
<td>Total Cost</td>
<td><input type=text name=total_cost size=15 maxlength=10 readonly></td>
</tr>
<tr>
<td>Adjusted Base Cost</td>
<td><input type=text name=acb size=15 readonly></td>
</tr>
<tr>
<td>Gain or Loss</td>
<td><input type=text name=CapGain size=15 maxlength=10 readonly></td>
</tr>
</table>
</td></tr></table>
</form>
</center>



<!-- Script Size: 2.84 KB -->











Wyszukiwarka

Podobne podstrony:
base (4)
Lab31 R1 Base Cfg
techniques de base
Larry Niven Passing Perry Crater Base, Time Uncertain
BUILDING A SHED BASE
3E D&D Adventure 05 Base of Operations
SAS Base 2006
base (3)
URI Base
cost
function base convert
base c
2005 12 Reaching Base Building a Database Application Using Ooo Base
base (2)
Stitch Ladder Stitch Base Row
base

więcej podobnych podstron