fnb-api icon indicating copy to clipboard operation
fnb-api copied to clipboard

Not All 150 rows on Transaction History page

Open Hartjies opened this issue 1 year ago • 1 comments

Hi Dev's

I have recently discovered that not all 150 rows are shown when puppeteer navigates to Transaction History page. I noticed that on some occasions transactions would disappear and later re-appear. Only 61 rows are available on json. FNB has induced a "More" button on the bottom of page that will allow the full view of 150 row.

Elements found:

<div id="footerButtonsContainer" style="margin-left: 1173px;">
<div class="gridCol grid10 footerBtn ">
<a onclick="fnb.controls.controller.eventsObject.raiseEvent('loadUrlToWorkspace', {url: '/banking/Controller?nav=transactionhistory.navigator.TransactionHistoryRedirect&amp;productCode=DDA&amp;anrfn=*num*&amp;initial=false&amp;FARFN=*ref*&amp;pN=*key*==',preLoadingCallBack:''}); return false;" href="#">More</a>
</div>
<div class="gridCol grid10 footerBtn ">
<a onclick="fnb.controls.controller.eventsObject.raiseEvent('loadUrlToWorkspace', {url: '/banking/Controller?nav=accounts.summaryofaccountbalances.navigator.SummaryOfAccountBalances',preLoadingCallBack:''}); return false;" href="#">Close</a>
</div></div>

Any suggestions on how we can incorporate this more button, if exist? Kind Regards.

Hartjies avatar Aug 08 '24 07:08 Hartjies

Hi, I managed to get a work around by replacing scrapeChequeOrSavings function in scrape-transactions.js

function scrapeChequeOrSavings(page) {
    return __awaiter(this, void 0, void 0, function () {
        var rows;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, page.evaluate(function () {
                        /* tslint:disable */
                    // Function to check if "More" button exists and click it
                    function clickMoreButtonIfExists() {
                        var moreButton = document.querySelector('.footerBtn a[onclick*="loadUrlToWorkspace"]');
                        if (moreButton) {
                            moreButton.click();
                            return true;
                        }
                        return false;
                    }
                    // Click "More" button once if it exists
                    clickMoreButtonIfExists();
                    // Wait for a short time to allow new rows to load (adjust as needed)
                    return new Promise(resolve => setTimeout(resolve, 2000)).then(function() {
                        var data = [];
                        var rows = $('.tableRow');
                        for (var i = 0; i < rows.length; i++) {
                            var row = $(rows[i]);
                            var cells = row.find('.tableCell .tableCellItem');
                            data.push({
                                date: cells[0].innerText,
                                description: cells[1].innerText,
                                reference: cells[2].innerText,
                                serviceFee: cells[3].innerText,
                                amount: cells[4].innerText,
                                balance: cells[5].innerText,
                                status: 'Successful'
                            });
                        }
                        return data;
                    });
                    /* tslint:enable */
                })];
                case 1:
                    rows = _a.sent();
                    return [2 /*return*/, rows.map(function (x) { return ({
                            date: moment_1.default(x.date, 'DD MMM YYYY').format('YYYY/MM/DD'),
                            description: x.description,
                            reference: x.reference,
                            serviceFee: cleanNumber(x.serviceFee),
                            amount: cleanNumber(x.amount),
                            balance: cleanNumber(x.balance),
                            status: transaction_status_1.TransactionStatus.Successful
                        }); })];
            }
        });
    });
}

I also added a fix for moment module miss handeling SAST for UTC timezone as date changes on json result with 1 day. Unnessesary trailing "T22:00:00.000Z" also removed by passing to desired format function.

Regards.

Hartjies avatar Aug 20 '24 09:08 Hartjies