Forums: [SOLVED] Tender amount & change due - Forums

Jump to content

Page 1 of 1

[SOLVED] Tender amount & change due Amend invoice template to include "Tender amount" & change

#1 User is offline   mtpocket 

  • Member
  • PipPip
  • Group: Members
  • Posts: 20
  • Joined: 06-December 15

Posted 18 February 2017 - 11:23 PM

Hi,

I'm playing with PHPRunner 9.6(Eval) with invoice template & battling to include amount tendered & change due. I know it must occur @ events Add Page, Javascript on load event. This is the original sample:


Runner.pages.constants.CANCEL_GIF = "remove";
Runner.lang.constants.TEXT_CANCEL = "Delete Item";

Runner.Invoice.initInvoiceButtons();
Runner.Invoice.initShortCuts();
Runner.Invoice.initSortableGrid();

var ctrlInvNum = Runner.getControl(pageid, "invoice_number"),
ctrlbiBuyerInfo = Runner.getControl(pageid, "buyer_info"),
ctrlCompanyName = Runner.getControl(pageid, "company_name"),
ctrlDate = Runner.getControl(pageid, 'date'),
url = Runner.pages.getUrl( pageObj.tName, pageObj.pageType );

Runner.Invoice.initInvoiceNumberAdjustment( ctrlInvNum, url );

if ( typeof ctrlbiBuyerInfo.doAutoCompleteFields === "function" ) {
ctrlbiBuyerInfo.doAutoCompleteFields();
}

if ( ctrlCompanyName ) {
ctrlCompanyName.addStyle('font-size: 32px; line-height: normal;');
}

if ( ctrlDate ) {
ctrlDate.setValue( Runner.Invoice.refineDate( new Date() ) );
ctrlDate.addStyle('text-align: right; vertical-align: bottom;');
}

Runner.Invoice.prepareField(pageid, "buyer_info");
Runner.Invoice.prepareField(pageid, "buyer_address");
Runner.Invoice.prepareField(pageid, "seller_info");
Runner.Invoice.prepareField(pageid, "company_name");
Runner.Invoice.prepareField(pageid, "date");



var currency = proxy.currency,
ctrlSubtotal = Runner.getControl(pageid, 'subtotal'),
ctrlTotal = Runner.getControl(pageid, 'total'),
ctrlTax = Runner.getControl(pageid, 'tax'),
$hiddenSubtotal = $("div.hidden-subtotal"),
$hiddenTotal = $("div.hidden-total"),
$calcTaxCont = $("div.calc-tax"),
calcTax = 0;

$hiddenSubtotal.html( ctrlSubtotal.getValue() );
$hiddenTotal.html( ctrlTotal.getValue() );
$calcTaxCont.html( Runner.Invoice.currencyFormat(calcTax.toFixed(2), currency) );

// Calculating Subtotal if Tax is changed
ctrlTax.on('keyup', function() {
var tax = Runner.Invoice.getCommaReplacedValue( this.getValue() ),
subTotal = parseFloat( $hiddenSubtotal.html() ),
total = subTotal * (1 + tax / 100),
calcTax = subTotal * tax / 100;

ctrlTotal.setValue( Runner.Invoice.currencyFormat(total.toFixed(2), currency) );
$hiddenTotal.html( total.toFixed(2) );
$calcTaxCont.html( Runner.Invoice.currencyFormat(calcTax.toFixed(2), currency) );
});


this.on('beforeSave', function( formObj, fieldControlsArr, pageObj ) {
formObj.baseParams['subtotal'] = parseFloat( $hiddenSubtotal.html() );
formObj.baseParams['total'] = parseFloat( $hiddenTotal.html() );
});


And this is what I've added:

//calculating Tender Amount & Change
var ctrlTender_Amount = Runner.getControl(pageid,'Tender_Amount');
var ctrlChange_Due = Runner.getControl(pageid,'Change_Due');
function func() {
ctrlChange_Due.setValue(Number(ctrlTender_Amount.getValue())-(Number(ctrlTotal.getValue())));
};
ctrlTender_Amount.on('keyup',func);
ctrlChange_Due.on('keyup',func);


Somehow it just doesn't want to display the change due... I've tried numerous ways to get the bottom of "(Number(ctrlTotal.getValue())))" with no success.
When I replace "(Number(ctrlTotal.getValue())))" with a static number it does the calculation.
What should the "ctrlTotal.getvalue" be?

Thanks
0

#2 User is offline   mtpocket 

  • Member
  • PipPip
  • Group: Members
  • Posts: 20
  • Joined: 06-December 15

Posted 22 February 2017 - 09:09 PM

SOLVED.

This is what it looks like now.

var ctrlTender_Amount = Runner.getControl(pageid,'Tender_Amount');
var ctrlChange_Due = Runner.getControl(pageid,'Change_Due');
function func() {
ctrlChange_Due.setValue(Number(ctrlTender_Amount.getValue())-(Number(parseFloat( $hiddenTotal.html() ))));
};
ctrlTender_Amount.on('keyup',func);
ctrlChange_Due.on('keyup',func);
0

Page 1 of 1


Fast Reply