WIP: ecommerce

This commit is contained in:
2025-10-06 07:13:09 +00:00
parent e6d9326872
commit 7200d0e6af
4 changed files with 16 additions and 13 deletions

View File

@@ -1,14 +1,21 @@
<?php
// enable error reporting
error_reporting(LC_ALL);
ini_set('display_errors', 1);
// ?XDEBUG_SESSION_START=PHPSTORM
//importInvoices();
importInvoices();
function importInvoices()
{
$apilo_config = loadApiloConfiguration();
$db = $GLOBALS['db'];
$GLOBALS['log']->info('----- Importing invoices from Apilo, config', $apilo_config);
$dbRes = $db->query("SELECT COUNT(id) as last_id FROM ecommerce_invoices WHERE origin LIKE 'apilo%'");
$offset = intval($db->fetchByAssoc($dbRes)['last_id']);
$GLOBALS['log']->info('----- Importing invoices from Apilo, offset', $offset);
$invoices = loadApiloInvoices($apilo_config['token'], $offset);
if (isset($invoices->error)) {
if (refreshApiloToken($apilo_config['refreshToken'], $apilo_config['clientId'], $apilo_config['clientSecret']) == true) {
@@ -19,6 +26,10 @@ function importInvoices()
}
}
brecho(count($invoices->documents));
$GLOBALS['log']->info('----- Importing invoices from Apilo, documents count', count($invoices->documents));
$platforms = loadApiloPlatformsList($apilo_config['token']);
if (!$platforms) {