UNPKG

@accounter/israeli-vat-scraper

Version:
48 lines (47 loc) 1.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MonthFixesHandler = void 0; const browser_util_js_1 = require("../utils/browser-util.js"); const evaluation_functions_js_1 = require("../utils/evaluation-functions.js"); const page_util_js_1 = require("../utils/page-util.js"); class MonthFixesHandler { config; prompt; location; index; page = null; constructor(config, prompt, location, index) { this.config = config; this.prompt = prompt; this.location = [...location, 'Fixes']; this.index = index; } handle = async (logger) => { this.prompt.update(this.location, 'Fetching...', logger); try { this.page = await (0, browser_util_js_1.newPageByMonth)(this.config.visibleBrowser, this.location[0], this.index, logger); const button = await this.page .waitForSelector('#ContentUsersPage_lnkHeshboniotBeforeTikun') .catch(() => { return; }); if (!button) { this.prompt.update(this.location, 'Done - no data found', logger); return undefined; } await button.click(); // get fixes const fixesTable = await (0, page_util_js_1.waitForSelectorPlus)(this.page, '#ContentUsersPage_DgIskNosfu', logger); const fixes = (await fixesTable?.evaluate(evaluation_functions_js_1.getReportExpansionFixes)) ?? []; this.page.browser().close(); this.prompt.update(this.location, 'Done', logger); return fixes; } catch (e) { this.prompt.addError(this.location, e?.message || e, logger); this.page?.browser().close(); return undefined; } }; } exports.MonthFixesHandler = MonthFixesHandler;