Overview
Comment: | Ajout entité compte bancaire |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
80bb6a9ff8d07ee24db685ff1309cf8a |
User & Date: | bohwaz on 2019-03-08 17:03:32 |
Other Links: | branch diff | manifest | tags |
Context
2019-09-23
| ||
21:30 | Fusion des changements et correctifs effectués dans le trunk check-in: c0a510c18c user: bohwaz tags: dev | |
2019-03-08
| ||
17:03 | Ajout entité compte bancaire check-in: 80bb6a9ff8 user: bohwaz tags: dev | |
2019-02-20
| ||
17:28 | Classe compte et categorie check-in: f75cec84a3 user: bohwaz tags: dev | |
Changes
Modified src/include/lib/Garradin/Compta/Categorie.php from [cb4aae3ddf] to [18c8c13e3d].
︙ | ︙ | |||
8 9 10 11 12 13 14 | use Garradin\Entity; /** * Catégories comptables */ class Categorie extends Entity { | | | | | | | | | | | | | | > > > > > > > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | use Garradin\Entity; /** * Catégories comptables */ class Categorie extends Entity { const DEPENSE = 1; const RECETTE = 2; const VIREMENT = 3; const DETTE_ADHERENT = 5; const DETTE_FOURNISSEUR = 6; const CREANCE_ADHERENT = 7; const CREANCE_FOURNISSEUR = 8; protected $id; protected $type; protected $intitule; protected $description; protected $compte; protected $_fields = [ 'type' => 'required|in:1,2,3', 'intitule' => 'required|string', 'description' => 'string', 'compte' => 'required|alpha_num|in_table:compta_comptes,id', ]; } |
Modified src/include/lib/Garradin/Compta/Compte.php from [8a97063326] to [c219124f46].
1 2 3 4 5 6 7 8 9 10 | <?php namespace Garradin\Compta; use Garradin\DB; use Garradin\Utils; use Garradin\UserException; class Compte extends Entity { | | | | | | | | | | | > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <?php namespace Garradin\Compta; use Garradin\DB; use Garradin\Utils; use Garradin\UserException; class Compte extends Entity { const PASSIF = 1; const ACTIF = 2; const ACTIF_PASSIF = 3; const PRODUIT = 4; const CHARGE = 5; const PRODUIT_CHARGE = 6; const BANQUE = 7; const CAISSE = 8; const A_ENCAISSER = 9; protected $id; protected $parent; protected $libelle; protected $position; protected $plan_comptable; protected $_fields = [ 'id' => 'required|string|alpha_num', 'libelle' => 'required|string', 'parent' => 'required|string|alpha_num|in_table:comptes,id', 'position' => 'required|integer', 'plan_comptable' => 'integer|min:0|max:1', ]; } |
Added src/include/lib/Garradin/Compta/Compte_Bancaire.php version [03377fbdd1].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | <?php namespace Garradin\Compta; use Garradin\DB; use Garradin\Utils; use Garradin\ValidationException; class Compte_Bancaire extends Compte { protected $banque; protected $iban; protected $bic; protected $_extra_fields = [ 'banque' => 'required|string', 'iban' => 'alpha_num|max:34', 'bic' => 'alpha_num|max:11|min:8' ]; public function __construct($id = null) { $this->_fields = array_merge($this->_fields, $this->_extra_fields); parent::__construct($id); } public function filterUserEntry($key, $value) { $value = parent::filterUserEntry($key, $value); if ($key == 'iban' || $key == 'bic') { // Ne garder que les lettres et chiffres $value = preg_replace('![^\dA-Z]!', '', strtoupper($value)); } return $value; } public function selfValidate() { parent::selfValidate(); if (null !== $this->iban && !Utils::checkIBAN($this->iban)) { throw new ValidationException('Code IBAN invalide'); } if (null !== $this->bic && !Utils::checkBIC($this->bic)) { throw new ValidationException('Code BIC/SWIFT invalide'); } } } |
Modified src/include/lib/Garradin/Compta/Ligne.php from [a0e19da1f4] to [b871bf3705].
︙ | ︙ | |||
10 11 12 13 14 15 16 | protected $table = 'compta_mouvements_lignes'; protected $id; protected $id_mouvement; protected $credit = 0; protected $debit = 0; | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | protected $table = 'compta_mouvements_lignes'; protected $id; protected $id_mouvement; protected $credit = 0; protected $debit = 0; protected $_fields = [ 'id_mouvement' => 'required|integer|in_table:compta_mouvements,id', 'compte' => 'required|alpha_num|in_table:compta_comptes,id', 'credit' => 'required|integer|min:0', 'debit' => 'required|integer|min:0' ]; public function filterUserEntry($key, $value) |
︙ | ︙ |
Modified src/include/lib/Garradin/Compta/Mouvement.php from [84872ed692] to [e4b2eec8c2].
︙ | ︙ | |||
26 27 28 29 30 31 32 | protected $prev_hash; protected $id_exercice; protected $id_auteur; protected $id_categorie; protected $id_projet; | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | protected $prev_hash; protected $id_exercice; protected $id_auteur; protected $id_categorie; protected $id_projet; protected $_fields = [ 'libelle' => 'required|string', 'remarques' => 'string|max:20000', 'numero_piece' => 'string|max:200', 'reference_paiement' => 'string|max:200', 'date' => 'required|date', 'moyen_paiement' => 'string|in_table:compta_moyens_paiement,code|required_with:id_categorie', 'validation' => 'bool', |
︙ | ︙ | |||
122 123 124 125 126 127 128 | } public function selfCheck() { $db = DB::getInstance(); $config = Config::getInstance(); | > | | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | } public function selfCheck() { $db = DB::getInstance(); $config = Config::getInstance(); // ID d'exercice obligatoire s'il existe déjà des exercices if (null === $this->id_exercice && $db->firstColumn('SELECT 1 FROM compta_exercices LIMIT 1;')) { throw new ValidationException('Aucun exercice spécifié.'); } if (null !== $this->id_exercice && !$db->test('compta_exercices', 'id = ? AND debut <= ? AND fin >= ?;', $this->id_exercice, $this->date, $this->date)) { throw new ValidationException('La date ne correspond pas à l\'exercice sélectionné.'); } } } |
Modified src/include/lib/Garradin/Entity.php from [ecdd24ee0e] to [60b139db0d].
︙ | ︙ | |||
55 56 57 58 59 60 61 62 63 64 65 66 | } $this->modified = []; return $return; } public function selfCheck() { return true; } | > > > > > > > | | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | } $this->modified = []; return $return; } /** * Vérifier la cohérence de l'objet avant enregistrement */ public function selfCheck() { return true; } /** * Valider les champs avant enregistrement * @throws ValidationException Si une erreur de validation survient */ public function selfValidate() { $errors = []; if (!Form::validate($this->_fields, $errors, $this->toArray())) { $messages = []; foreach ($errors as $error) { $messages[] = $this->getValidationMessage($error); } |
︙ | ︙ | |||
97 98 99 100 101 102 103 | public function __get($key) { return $this->$key; } public function __set($key, $value) { | | > > > > > > > > > | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | public function __get($key) { return $this->$key; } public function __set($key, $value) { if (!in_array($key, $this->_fields)) { throw new ValidationException(sprintf('Le champ "%s" ne peut être modifié.', $key)); } $value = $this->filterUserEntry($key, $value); $this->$key = $value; $this->modified[$key] = $value; } public function __isset($key) { return property_exists($this, $key); } /** * Filtrer/sanitiser la valeur entrée par l'utilisateur pour un champ de l'entité * (effectué au set) */ public function filterUserEntry($key, $value) { return trim($value); } public function toArray() { $out = []; foreach ($this->_fields as $key) { $out[$key] = $this->$key; } return $out; } } |