Skip to content

Commit

Permalink
fix: inicializa parâmetro initial_date
Browse files Browse the repository at this point in the history
Certifica que o parâmetro _initial_date_ seja inicializado na ativação do módulo e caso ausente especifica valor padrão para a rotina de seleção de fila.

refs: #132
  • Loading branch information
andrekutianski committed Sep 1, 2022
1 parent c6d9072 commit 8cc2f65
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ public function run()
$serviceInvoicesTable = $this->serviceInvoicesRepo->tableName();
$storage = new \WHMCSExpert\Addon\Storage($storageKey);
$dataAtual = date('Y-m-d H:i:s');
$initialDate = $storage->get('initial_date');
// caso não exista valor para initial_date inicia define data que garanta a execução da rotina
$initialDate = empty($storage->get('initial_date')) ? $storage->get('initial_date') : '1970-01-01';

// atualiza a data da ultima cron
$storage->set('last_cron', $dataAtual);

$hasNfWaiting = Capsule::table($serviceInvoicesTable)->whereBetween('created_at', [$initialDate, $dataAtual])->where('status', '=', 'Waiting')->count();
logModuleCall('NFEioServiceInvoices', 'Hook - AfterCronJob', "{$hasNfWaiting} notas a serem geradas", $hasNfWaiting);

if ($hasNfWaiting) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ public function initDefaultValues()
$functions->gnfe_insert_issue_nfe_cond_in_database();
// define 'on' como padrão para discount_items
$storage->set('discount_items', 'on');

// inicia valor para a chave initial_date
$date = date('Y-m-d');
$storage->set('initial_date', $date);

}

Expand Down

0 comments on commit 8cc2f65

Please sign in to comment.