added invoice sepa last date fix script
This commit is contained in:
39
scripts/invoice/fix-sepa-last-date.php
Normal file
39
scripts/invoice/fix-sepa-last-date.php
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$me = new User(1);
|
||||
|
||||
define("INTERNAL_USER_ID", $me->id);
|
||||
define("INTERNAL_USER_USERNAME", $me->username);
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach(InvoiceModel::search(["invoice_date>=" => 1722470400]) as $invoice) {
|
||||
if(!$invoice->sepa_id) continue;
|
||||
//if(!$invoice->sepa_last_date) continue;
|
||||
|
||||
// find last invoice
|
||||
$last_invoice = InvoiceModel::getLast(["sepa_id" => $invoice->sepa_id, "invoice_date<" => 1722470400]);
|
||||
if(!$last_invoice) continue;
|
||||
|
||||
$last_date = new DateTime("@".$last_invoice->invoice_date);
|
||||
$last_date->setTimezone(new DateTimeZone("Europe/Vienna"));
|
||||
|
||||
$invoice->sepa_last_date = $last_date->format("Y-m-d");
|
||||
$invoice->save();
|
||||
|
||||
$i++;
|
||||
|
||||
}
|
||||
|
||||
echo "updated $i invoices\n";
|
||||
Reference in New Issue
Block a user