Utiliser des entiers au lieu de float tel Garradin
This commit is contained in:
parent
11974482f2
commit
ede7c789d7
13 changed files with 189 additions and 139 deletions
51
upgrade.php
51
upgrade.php
|
|
@ -32,7 +32,7 @@ if (version_compare($infos->version, '0.3.0', '<'))
|
|||
$db->exec('DROP TABLE `plugin_facturation_config`;');
|
||||
}
|
||||
|
||||
// 0.3.0 - Migration Facturation\Config vers la table plugins
|
||||
// 0.4.0 - Migration Facturation\Config vers la table plugins
|
||||
if (version_compare($infos->version, '0.4.0', '<'))
|
||||
{
|
||||
$db->exec(<<<EOT
|
||||
|
|
@ -66,8 +66,6 @@ if (version_compare($infos->version, '0.4.0', '<'))
|
|||
moyen_paiement TEXT NOT NULL,
|
||||
contenu TEXT NOT NULL,
|
||||
total REAL DEFAULT 0
|
||||
|
||||
-- FOREIGN KEY(moyen_paiement) REFERENCES plugin_facturation_paiement(code)
|
||||
);
|
||||
|
||||
INSERT INTO plugin_facturation_factures_tmp SELECT * FROM plugin_facturation_factures;
|
||||
|
|
@ -78,3 +76,50 @@ EOT
|
|||
);
|
||||
|
||||
}
|
||||
|
||||
// 0.6.0 - Migration Facturation\Config vers la table plugins
|
||||
if (version_compare($infos->version, '0.6.0', '<'))
|
||||
{
|
||||
// SQL -> total integer
|
||||
$db->exec(<<<EOT
|
||||
|
||||
CREATE TABLE IF NOT EXISTS plugin_facturation_factures_tmp
|
||||
(
|
||||
id INTEGER PRIMARY KEY,
|
||||
type_facture INTEGER NOT NULL DEFAULT 0,
|
||||
numero TEXT NOT NULL UNIQUE,
|
||||
receveur_membre INTEGER NOT NULL, -- bool
|
||||
receveur_id INTEGER NOT NULL,
|
||||
date_emission TEXT NOT NULL, -- CHECK (date(date_emission) IS NOT NULL AND date(date_emission) = date_emission),
|
||||
date_echeance TEXT NOT NULL, -- CHECK (date(date_echeance) IS NOT NULL AND date(date_echeance) = date_echeance),
|
||||
reglee INTEGER DEFAULT 0, -- bool
|
||||
archivee INTEGER DEFAULT 0, -- bool
|
||||
moyen_paiement TEXT NOT NULL,
|
||||
contenu TEXT NOT NULL,
|
||||
total INTEGER DEFAULT 0
|
||||
);
|
||||
|
||||
INSERT INTO plugin_facturation_factures_tmp SELECT id, type_facture, numero, receveur_membre, receveur_id, date_emission, date_echeance, reglee, archivee, moyen_paiement, contenu, CAST(total * 100 as INT) as total FROM plugin_facturation_factures;
|
||||
DROP TABLE plugin_facturation_factures;
|
||||
ALTER TABLE plugin_facturation_factures_tmp RENAME TO plugin_facturation_factures;
|
||||
EOT
|
||||
);
|
||||
|
||||
|
||||
foreach($factures = $facture->listAll() as $k=>$f)
|
||||
{
|
||||
foreach($f->contenu as $line => $content)
|
||||
{
|
||||
$contenu[] = ['designation' => $content['designation'],
|
||||
'prix' => (int) ($content['prix'] * 100) ];
|
||||
}
|
||||
$f->contenu = $contenu;
|
||||
$data = (array) $f;
|
||||
unset($data['id']);
|
||||
unset($data['date_emission']);
|
||||
unset($data['date_echeance']);
|
||||
var_dump($data);
|
||||
$facture->edit($f->id, $data);
|
||||
unset($contenu);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue