Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Clicking Into an IG Column that is Calculated Makes it Go To 0.00

Dj SteeleFeb 22 2019 — edited Feb 28 2019

Goodmorning Community,

I am using APEX 5.1.0.00.45 with Oracle 12c Database & Google Chrome

-----------------------------------------------------------------------------------------------------------------------------------------------

I have an IG where a User would Enter a Number (# of Items to Refund; Qty to Refund Field) takes that number and multiplies by a Cost Column to Equal an Extended Price
This Calculation is done in Javascript which then adds all the totals in the Extended Price Column to set a Subtotal Page Item

The Problem is ( If the User Happens to Click in the Extended Price Field at Some Point After the Calculation the Extended Price Column will go to '0.00')

The Extended Price Column is Disabled through a D.A.

Here are some Screen Shots to further Explain

I will also try to replicate to see if I can Replicate the Scenario

pastedImage_0.png

If I or the User Clicks into the Extended Price Column it takes the Calculation to '0.00 '

The User would simple hit the Button "Complete Partial Refund" But if they Purposely or Accidentally Click in the Extended Price Field the Column again goes to '0.00'

but the Subtotal , Tax , and Receipt Amount stay Calculated Correctly

pastedImage_1.png

Here is the Javascript Code that is setting the Extended Price Column and then Looping through setting the Subtotal Column Dynamically

//alert('Beginning');

//function to verify if a given number is an integer or a decimal; https://codereview.stackexchange.com/questions/101484/simple-function-to-verify-if-a-number-is-integer

//function isInteger(num){

// var numCopy = parseFloat(num);

// return !isNaN(numCopy) && numCopy == numCopy.toFixed();

//}

//Get the link element that was clicked

var $te = $(this.triggeringElement);

//Get the ID of the row

var rowId = $te.closest('tr').data('id');

//Identify the particular interactive grid

var ig$ = apex.region("gridRefundReceiptLog").widget();

//Fetch the model for the interactive grid

var model = ig$.interactiveGrid("getViews","grid").model;

//Fetch the record for the particular rowId

var record = model.getRecord(rowId);

var thisrowOrigItemQty = model.getValue(record,"ORIGINAL_ITEM_QTY");

var thisrowItemCost = model.getValue(record,"ITEM_COST");

var thisrowItemQty = this.triggeringElement.value;

var nSumOfExtended = 0;

if ( thisrowItemQty >= 0 ) {

if ( Math.abs(thisrowItemQty) > thisrowOrigItemQty ) {

    //function getInput\_confirmRefund() {

    apex.item(this.triggeringElement).setValue(0);

    model.setValue(record,"EXTENDED\_PRICE", 0);

    apex.item("P98\_SUBTOTAL").setValue(0);

    if (parseFloat($v("P98\_SUBTOTAL").replace(/\[^\\d\\.\\-eE+\]/g, "")) == 0)  {

    apex.item( "btnCompletePartialRefund" ).disable();     

    }

    else{

    apex.item( "btnCompletePartialRefund" ).enable();

    }  

    //sweetAlert("Validation Error","\\n\<b>Qty To Refund Entered\\n was Greater Than \\nAvailable Qty To Refund\<b/>");

    swal({ title: 'Validation Error: ', text: '\\nQty To Refund Entered\\n was Greater Than \\nAvailable Qty To Refund', showCloseButton: true})

}       

else {                // We have a valid number. Let's do this.

    var newExtendedPrice = thisrowItemQty \* thisrowItemCost \* -1;

    model.setValue(record,"EXTENDED\_PRICE", newExtendedPrice.toFixed(2));

   // var nChangedValue = Number(thisrowApply).toFixed(2); nChangedValue was where newExtendedPrice is now

$('.myExtended').each(function() {  

    cCurrentValue = $(this).text().replace(/\[^0-9\\.\]+/g,"");

    nCurrentValue = Number(cCurrentValue).toFixed(2);

    nSumOfExtended = nSumOfExtended + (+nCurrentValue ? +nCurrentValue : 0); 

});

nSumOfExtended = newExtendedPrice + nSumOfExtended - newExtendedPrice;    

nSumOfExtended = nSumOfExtended \* -1;  

$s("P98\_SUBTOTAL", nSumOfExtended.toFixed(2).replace(/(\\d+),(?=\\d{3}(\\D|$))/g, "$1"));

}

if (parseFloat($v("P98\_SUBTOTAL").replace(/\[^\\d\\.\\-eE+\]/g, "")) == 0)  {

    apex.item( "btnCompletePartialRefund" ).disable();     

}

else{

    apex.item( "btnCompletePartialRefund" ).enable();

} 

return true;

}

/*

else {

 apex.item(this.triggeringElement).setValue(0);

 //model.setValue(record,"EXTENDED\_PRICE", 0);

//$("#btnCompletePartialRefund").addClass("apex\_disabled");    //Both versions of this work

//alert(parseFloat($v("P98_SUBTOTAL").replace(/[^\d\.\-eE+]/g, "")));

if (parseFloat($v("P98\_SUBTOTAL").replace(/\[^\\d\\.\\-eE+\]/g, "")) == 0)  {

 apex.item( "btnCompletePartialRefund" ).disable();     

}

else{

   apex.item( "btnCompletePartialRefund" ).enable();

}

}

*/

If Additional Information is Necessary Please Let Me Know

Thank You

DSteele41

This post has been answered by J-Lig on Feb 28 2019
Jump to Answer
Comments
Post Details
Added on Feb 22 2019
9 comments
795 views