-
Notifications
You must be signed in to change notification settings - Fork 70
Pouvoir archiver un compte bancaire #1896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 7 commits
412937a
ca21292
66f9e3f
4a27876
fda58f4
ac38722
915b338
235850e
6110bc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
admin_accounting_accounts_edit: | ||
path: /accounts/edit/{id} | ||
defaults: {_controller: AppBundle\Controller\Admin\Accounting\Configuration\EditAccountAction} | ||
requirements: | ||
id: '\d+' | ||
|
||
admin_accounting_accounts_add: | ||
path: /accounts/add | ||
defaults: {_controller: AppBundle\Controller\Admin\Accounting\Configuration\AddAccountAction} | ||
|
||
admin_accounting_accounts_archive: | ||
path: /accounts/archive/{id} | ||
defaults: {_controller: AppBundle\Controller\Admin\Accounting\Configuration\ArchiveAccountAction} | ||
requirements: | ||
id: '\d+' | ||
|
||
admin_accounting_accounts_restore: | ||
path: /accounts/restore/{id} | ||
defaults: {_controller: AppBundle\Controller\Admin\Accounting\Configuration\RestoreAccountAction} | ||
requirements: | ||
id: '\d+' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
final class AddArchivedAtOnAccount extends AbstractMigration | ||
{ | ||
public function change(): void | ||
{ | ||
$this->execute('ALTER TABLE compta_compte ADD COLUMN archived_at DATETIME DEFAULT NULL'); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -33,14 +33,7 @@ | |||||
$listPeriode = $compta->obtenirListPeriode(); | ||||||
$smarty->assign('listPeriode', $listPeriode); | ||||||
|
||||||
$listeComptes = [ | ||||||
'1' => 'Courant', | ||||||
'5' => 'Courant CM', | ||||||
'2' => 'Espece', | ||||||
'3' => 'Livret A', | ||||||
'6' => 'Livret A CM', | ||||||
'4' => 'Paypal', | ||||||
]; | ||||||
$listeComptes = $compta->obtenirListeComptesActifs(''); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. C'est déjà la valeur par défaut donc tu peux enlever la valeur :
Suggested change
|
||||||
$smarty->assign('listeComptes', $listeComptes); | ||||||
$smarty->assign('compte_id', $compte); | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,8 @@ | |
$formulaire = instancierFormulaire(); | ||
|
||
if ($action === 'modifier') { | ||
$champsRecup = $compta->obtenirListCategories('',$_GET['id']); | ||
$champs['categorie'] = $champsRecup['categorie']; | ||
$champsRecup = $compta->obtenirListComptes('',$_GET['id']); | ||
$champs['nom_compte'] = $champsRecup['nom_compte']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Au lieu de modifier ce code, il vaudrait mieux supprimer ce qui a été remplacé par du Symfony (tout sauf la liste des compte). Là actuellement les anciennes urls de modification et création fonctionnent encore. Après si tu compte refaire la liste des comptes en Symfony ça peut attendre. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. J'ai une branche locale avec la refonte de la page de listing sous SF. Si besoin, je peux l'intégrer à la PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Mopolo au final j'ai ajouté la suppression de la page legacy de listing des comptes |
||
|
||
$formulaire->setDefaults($champs); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AppBundle\Accounting\Form; | ||
|
||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
class AccountType extends AbstractType | ||
{ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder->add('name', TextType::class, [ | ||
'label' => 'Nom du compte', | ||
'required' => true, | ||
'constraints' => [ | ||
new Assert\NotBlank(), | ||
new Assert\Type('string'), | ||
], | ||
]); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AppBundle\Accounting\Model; | ||
|
||
use CCMBenchmark\Ting\Entity\NotifyProperty; | ||
use CCMBenchmark\Ting\Entity\NotifyPropertyInterface; | ||
use DateTime; | ||
|
||
class Account implements NotifyPropertyInterface | ||
{ | ||
use NotifyProperty; | ||
|
||
private ?int $id = null; | ||
|
||
private ?string $name = null; | ||
|
||
private ?DateTime $archivedAt = null; | ||
|
||
public function getId(): ?int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function setId(int $id): self | ||
{ | ||
$this->propertyChanged('id', $this->id, $id); | ||
$this->id = $id; | ||
return $this; | ||
} | ||
|
||
public function getName(): ?string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function setName(?string $name): self | ||
{ | ||
$this->propertyChanged('name', $this->name, $name); | ||
$this->name = $name; | ||
|
||
return $this; | ||
} | ||
|
||
public function getArchivedAt(): ?DateTime | ||
{ | ||
return $this->archivedAt; | ||
} | ||
|
||
public function setArchivedAt(?DateTime $archivedAt): self | ||
{ | ||
$this->propertyChanged('archivedAt', $this->archivedAt, $archivedAt); | ||
$this->archivedAt = $archivedAt; | ||
|
||
return $this; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AppBundle\Accounting\Model\Repository; | ||
|
||
use AppBundle\Accounting\Model\Account; | ||
use CCMBenchmark\Ting\Repository\Metadata; | ||
use CCMBenchmark\Ting\Repository\MetadataInitializer; | ||
use CCMBenchmark\Ting\Repository\Repository; | ||
use CCMBenchmark\Ting\Serializer\SerializerFactoryInterface; | ||
|
||
/** | ||
* @extends Repository<Account> | ||
*/ | ||
class AccountRepository extends Repository implements MetadataInitializer | ||
{ | ||
public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) | ||
{ | ||
$metadata = new Metadata($serializerFactory); | ||
|
||
$metadata->setEntity(Account::class); | ||
$metadata->setConnectionName('main'); | ||
$metadata->setDatabase($options['database']); | ||
$metadata->setTable('compta_compte'); | ||
|
||
$metadata | ||
->addField([ | ||
'columnName' => 'id', | ||
'fieldName' => 'id', | ||
'primary' => true, | ||
'autoincrement' => true, | ||
'type' => 'int', | ||
]) | ||
->addField([ | ||
'columnName' => 'nom_compte', | ||
'fieldName' => 'name', | ||
'type' => 'string', | ||
]) | ||
->addField([ | ||
'columnName' => 'archived_at', | ||
'fieldName' => 'archivedAt', | ||
'type' => 'datetime', | ||
]) | ||
; | ||
|
||
return $metadata; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AppBundle\Controller\Admin\Accounting\Configuration; | ||
|
||
use Afup\Site\Logger\DbLoggerTrait; | ||
use AppBundle\Accounting\Form\AccountType; | ||
use AppBundle\Accounting\Model\Account; | ||
use AppBundle\Accounting\Model\Repository\AccountRepository; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
final class AddAccountAction extends AbstractController | ||
{ | ||
use DbLoggerTrait; | ||
|
||
public function __construct( | ||
private readonly AccountRepository $accountRepository, | ||
) {} | ||
|
||
public function __invoke(Request $request): Response | ||
{ | ||
$account = new Account(); | ||
$form = $this->createForm(AccountType::class, $account); | ||
$form->handleRequest($request); | ||
if ($form->isSubmitted() && $form->isValid()) { | ||
$this->accountRepository->save($account); | ||
$this->log('Ajout du compte ' . $account->getName()); | ||
$this->addFlash('notice', 'Le compte ' . $account->getName() . ' a été créé'); | ||
return $this->redirect('/pages/administration/index.php?page=compta_conf_compte&action=lister&filtre=' . $account->getName()); | ||
} | ||
|
||
return $this->render('admin/accounting/configuration/account_add.html.twig', [ | ||
'form' => $form->createView(), | ||
'account' => $account, | ||
'formTitle' => 'Ajouter un compte', | ||
'submitLabel' => 'Ajouter', | ||
]); | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.