My customer system is up and running and is working great. I've got only one new problem.
I did make een invoice form like the one you have made on your sample nuFinancial module.
The problem I've got is: when I copy the calculating script from nuFinancial I wil get een blank screen and can't do anything.
it starts with the "Before open" tab:
Code: Select all
//build JavaScript for screen
$javascript = createJavaScriptSharedFunctions();
addJSFunction($javascript);
on the "before safe" tab I've got
Code: Select all
//--
Code: Select all
function nuLoadThis() {
calcinv_total();
}
function nuBeforeSave(){
if ( !validateCloseDate() )
return false;
calcinv_total();
return true;
}
function calclinetotal(pthis) {
if (pthis.length == 18) {
// Parameter passed through from tri_product_id
PRE = pthis;
} else {
// Parameter passed through from tri_units or tri_cost
PRE = pthis.name.substring(0,18);
}
//calculate the total of the line by quantity * cost
unit = Number(document.getElementById(PRE+'fac_item_stuks').value);
unitCost = Number(document.getElementById(PRE+'fac_item_prijs').value);
taxPercent = Number(document.getElementById(PRE+'fac_btw_pro').value);
//Make sure rounding is correct before setting field value
total = Math.round(unit * unitCost);
taxAmount = Math.round(unit * unitCost)/ (100 + taxPercent) * taxPercent;
price = total - taxAmount;
document.getElementById(PRE+'fac_item_netto').value = price;
document.getElementById(PRE+'fac_item_btw').value = taxAmount;
document.getElementById(PRE+'fac_item_totaal').value = total;
//if the values of the total field is blank then fill them in
if(document.getElementById(PRE+'fac_item_totaal').value < '0'){
document.getElementById(PRE+'fac_item_netto').value = price;
document.getElementById(PRE+'fac_item_btw').value = taxAmount;
document.getElementById(PRE+'fac_item_totaal').value = total;
}
nuFormat(document.getElementById(PRE+'fac_item_stuks'));
nuFormat(document.getElementById(PRE+'fac_item_prijs'));
nuFormat(document.getElementById(PRE+'fac_item_totaal'));
calcinv_total();
}
function calcinv_total() {
//calculate the entire total of all the line totals
theRows = Number(document.getElementById('rowssub_fac_item').value);
invAmount = '0';
invTax = '0';
//for every line...
for (int = 0;int < theRows; ++int) {
strlength = '0000'+int;
pstrlength = strlength.length;
PRE = 'sub_fac_item' + ('0000'+int).substring(pstrlength-4);
price = Number(document.getElementById(PRE+'fac_item_netto').value);
taxAmount = Number(document.getElementById(PRE+'fac_item_btw').value);
total = Number(document.getElementById(PRE+'fac_item_totaal').value);
//if delete is not checked then add prices
if (document.getElementById("row"+PRE).checked != true) {
invAmount = Number(invAmount) + price;
invTax = Number(invTax) + taxAmount;
nuFormat(document.getElementById(PRE+'fac_item_netto'));
nuFormat(document.getElementById(PRE+'fac_item_btw'));
nuFormat(document.getElementById(PRE+'fac_item_totaal'));
//else set to zero and don't add
} else {
document.getElementById(PRE+'fac_item_netto').value = 0;
document.getElementById(PRE+'fac_item_btw').value = 0;
document.getElementById(PRE+'fac_item_totaal').value = 0;
nuFormat(document.getElementById(PRE+'fac_item_netto'));
nuFormat(document.getElementById(PRE+'fac_item_btw'));
nuFormat(document.getElementById(PRE+'fac_item_totaal'));
}
}
document.getElementById('fac_netto').value = invAmount;
document.getElementById('fac_btw').value = invTax;
document.getElementById('fac_totaal').value = invAmount + invTax;
nuFormat(document.getElementById('fac_netto'));
nuFormat(document.getElementById('fac_btw'));
nuFormat(document.getElementById('fac_totaal'));
}
function getRowPrefixFromLookup(pthis) {
// Needed to update row price totals if user changes a product lookup
PRE = pthis.name.substring(4,22);
nuCreateCookie('row_name_for_transaction_item', PRE, 0);
calclinetotal(nuReadCookie('row_name_for_transaction_item'));
}
Thanks you verry much.
Jeroen