Skip to content

Commit 94e821d

Browse files
committed
fix
1 parent 6021b5c commit 94e821d

File tree

7 files changed

+94
-26
lines changed

7 files changed

+94
-26
lines changed

compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ services:
3636
HOST_PWD: ${PWD}
3737
SYMFONY_IDE: "%env(IDE_USED)%://open?url=file://%%f&line=%%l&/var/www/html/>%env(HOST_PWD)%/"
3838
PANTHER_NO_SANDBOX: 1
39-
PANTHER_CHROME_ARGUMENTS: '--disable-dev-shm-usage --disable-features=IsolateOrigins,site-per-process,TrackingProtection3pcd'
39+
PANTHER_CHROME_ARGUMENTS: '--disable-dev-shm-usage --disable-features=IsolateOrigins,site-per-process,TrackingProtection3pcd --window-size=1920,1080'
4040
env_file:
4141
.env
4242
volumes:

htdocs/pages/administration/compta_facture.php

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -174,30 +174,46 @@
174174

175175

176176

177-
$formulaire->addElement('header' , '', 'Contenu');
178-
$formulaire->addElement('text' , 'ref' , 'Référence' , ['size' => 50, 'maxlength' => 100]);
179-
$formulaire->addElement('textarea', 'designation' , 'Désignation', ['cols' => 42, 'rows' => 5]);
180-
$formulaire->addElement('text' , 'quantite' , 'Quantite' , ['size' => 50, 'maxlength' => 100]);
181-
$formulaire->addElement('text' , 'pu' , 'Prix Unitaire' , ['size' => 50, 'maxlength' => 100]);
182-
183-
184-
185-
for ($i = 1;$i < 6;$i++) {
177+
$nbRow = count($champsRecup);
178+
if ($nbRow === 5) {
186179
$formulaire->addElement('header' , '', 'Contenu');
187-
$formulaire->addElement('static' , 'note' , '' , 'Ligne ' . $i . '<br /><br />');
188-
$formulaire->addElement('hidden' , 'id' . $i , 'id');
189-
$formulaire->addElement('text' , 'ref' . $i , 'Référence' , ['size' => 50, 'maxlength' => 100]);
190-
$formulaire->addElement('static' , 'note' , '' , 'Rappel : sponsoring 20%, place supplémentaire 10%.<br />');
191-
$formulaire->addElement('select' , 'tva' . $i , 'Taux de TVA' , ['0' => 'Non soumis', '5.50' => '5.5%', '10.00' => '10%', '20.00' => '20%']);
192-
$formulaire->addElement('textarea', 'designation' . $i , 'Désignation', ['cols' => 42, 'rows' => 5]);
193-
$formulaire->addElement('text' , 'quantite' . $i , 'Quantite' , ['size' => 50, 'maxlength' => 100]);
194-
$formulaire->addElement('text' , 'pu' . $i , 'Prix Unitaire HT' , ['size' => 50, 'maxlength' => 100]);
180+
$formulaire->addElement('text' , 'ref' , 'Référence' , ['size' => 50, 'maxlength' => 100]);
181+
$formulaire->addElement('textarea', 'designation' , 'Désignation', ['cols' => 42, 'rows' => 5]);
182+
$formulaire->addElement('text' , 'quantite' , 'Quantite' , ['size' => 50, 'maxlength' => 100]);
183+
$formulaire->addElement('text' , 'pu' , 'Prix Unitaire' , ['size' => 50, 'maxlength' => 100]);
184+
185+
186+
187+
for ($i = 1;$i < 6;$i++) {
188+
$formulaire->addElement('header' , '', 'Contenu');
189+
$formulaire->addElement('static' , 'note' , '' , 'Ligne ' . $i . '<br /><br />');
190+
$formulaire->addElement('hidden' , 'id' . $i , 'id');
191+
$formulaire->addElement('text' , 'ref' . $i , 'Référence' , ['size' => 50, 'maxlength' => 100]);
192+
$formulaire->addElement('static' , 'note' , '' , 'Rappel : sponsoring 20%, place supplémentaire 10%.<br />');
193+
$formulaire->addElement('select' , 'tva' . $i , 'Taux de TVA' , ['0' => 'Non soumis', '5.50' => '5.5%', '10.00' => '10%', '20.00' => '20%']);
194+
$formulaire->addElement('textarea', 'designation' . $i , 'Désignation', ['cols' => 42, 'rows' => 5]);
195+
$formulaire->addElement('text' , 'quantite' . $i , 'Quantite' , ['size' => 50, 'maxlength' => 100]);
196+
$formulaire->addElement('text' , 'pu' . $i , 'Prix Unitaire HT' , ['size' => 50, 'maxlength' => 100]);
197+
}
198+
} else {
199+
for ($i = 1;$i <= $nbRow;$i++) {
200+
$formulaire->addElement('header' , '', 'Contenu');
201+
$formulaire->addElement('static' , 'note' , '' , 'Ligne ' . $i . '<br /><br />');
202+
$formulaire->addElement('hidden' , 'id' . $i , 'id');
203+
$formulaire->addElement('text' , 'ref' . $i , 'Référence' , ['size' => 50, 'maxlength' => 100]);
204+
$formulaire->addElement('static' , 'note' , '' , 'Rappel : sponsoring 20%, place supplémentaire 10%.<br />');
205+
$formulaire->addElement('select' , 'tva' . $i , 'Taux de TVA' , ['0' => 'Non soumis', '5.50' => '5.5%', '10.00' => '10%', '20.00' => '20%']);
206+
$formulaire->addElement('textarea', 'designation' . $i , 'Désignation', ['cols' => 42, 'rows' => 5]);
207+
$formulaire->addElement('text' , 'quantite' . $i , 'Quantite' , ['size' => 50, 'maxlength' => 100]);
208+
$formulaire->addElement('text' , 'pu' . $i , 'Prix Unitaire HT' , ['size' => 50, 'maxlength' => 100]);
209+
}
195210
}
196211

197212

198213

199214

200215

216+
201217
// boutons
202218
$formulaire->addElement('header' , 'boutons' , '');
203219
$formulaire->addElement('submit' , 'soumettre' , ucfirst($action));

sources/AppBundle/Controller/Admin/Accounting/Quotation/AddQuotationAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __invoke(Request $request): Response
5252
]);
5353
}
5454

55-
private function init(int $quotationId)
55+
private function init(int $quotationId): Invoicing
5656
{
5757
$baseQuotation = $this->invoicingRepository->get($quotationId);
5858
if (!$baseQuotation instanceof Invoicing) {

sources/AppBundle/Controller/Admin/Accounting/Quotation/EditQuotationAction.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
namespace AppBundle\Controller\Admin\Accounting\Quotation;
66

77
use AppBundle\Accounting\Form\QuotationType;
8+
use AppBundle\Accounting\Model\Invoicing;
89
use AppBundle\Accounting\Model\Repository\InvoicingDetailRepository;
910
use AppBundle\Accounting\Model\Repository\InvoicingRepository;
10-
use InvalidArgumentException;
1111
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1212
use Symfony\Component\HttpFoundation\Request;
1313
use Symfony\Component\HttpFoundation\Response;
@@ -24,9 +24,11 @@ public function __invoke(Request $request): Response
2424
$quotationId = $request->query->getInt('quotationId');
2525
$quotation = $this->invoicingRepository->getQuotationById($quotationId);
2626
if ($quotation === null) {
27-
throw new InvalidArgumentException("Ce devis n'existe pas");
27+
throw $this->createNotFoundException("Ce devis n'existe pas");
2828
}
2929

30+
$this->cleanLegacyData($quotation);
31+
3032
$form = $this->createForm(QuotationType::class, $quotation, ['actionType' => 'edit']);
3133
$form->handleRequest($request);
3234
if ($form->isSubmitted() && $form->isValid()) {
@@ -43,7 +45,6 @@ public function __invoke(Request $request): Response
4345
$this->invoicingDetailRepository->save($detail);
4446
}
4547

46-
//dump($existingIds, $idsToRemove);
4748
$idsToRemove = array_diff($idsToRemove, $existingIds);
4849
if ($idsToRemove) {
4950
$this->invoicingDetailRepository->removeRowsPerIds($idsToRemove);
@@ -53,7 +54,6 @@ public function __invoke(Request $request): Response
5354
$this->addFlash('success', 'L\'écriture a été modifiée');
5455
return $this->redirectToRoute('admin_accounting_quotations_list');
5556
} catch (\Exception $e) {
56-
// dump($e->getMessage());
5757
$this->invoicingRepository->rollback();
5858
$this->addFlash('error', 'L\'écriture n\'a pas pu être enregistrée');
5959
}
@@ -65,4 +65,21 @@ public function __invoke(Request $request): Response
6565
'submitLabel' => 'Modifier',
6666
]);
6767
}
68+
69+
/**
70+
* Pour simplifier la modification d'un devis créé avant ma refonte sous symfony, on supprime les lignes vides
71+
*/
72+
private function cleanLegacyData(Invoicing $quotation): void
73+
{
74+
$cleanedDetails = [];
75+
foreach ($quotation->getDetails() as $detail) {
76+
if (empty($detail->getDesignation()) && empty($detail->getQuantity()) && empty($detail->getUnitPrice()) && empty($detail->getReference())) {
77+
$this->invoicingDetailRepository->delete($detail);
78+
} else {
79+
$cleanedDetails[] = $detail;
80+
}
81+
}
82+
$quotation->setDetails($cleanedDetails);
83+
84+
}
6885
}

tests/behat/bootstrap/FeatureContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function clickOnLink(string $type, string $text): void
227227
);
228228
}
229229

230-
$this->minkContext->getSession()->executeScript('document.querySelector("' . $selector . '").click();');
230+
$node->click();
231231
}
232232

233233
#[Then('/^(?:|I )open menu "(?P<text>(?:[^"]|\\")*)"$/')]

tests/behat/bootstrap/WaitContext.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,42 @@ public function pressButtonAndWaitToSee(string $button, string $text, ?string $t
6969
$this->waitToSeeText($text, $timeout);
7070
}
7171

72+
#[When('/^I follow the button of tooltip "(?P<tooltip>[^"]*)" and wait until I see "(?P<text>[^"]*)"(?:| within (?P<timeout>\d+)ms)$/')]
73+
public function clickLinkOfTooltipAndWaitToSee(string $tooltip, string $text, ?string $timeout = null): void
74+
{
75+
$link = $this->minkContext->getSession()->getPage()->find('css', sprintf('a[data-tooltip="%s"]', $tooltip));
76+
77+
if (null === $link) {
78+
throw new ExpectationException(
79+
sprintf('Link of tooltip "%s" not found', $tooltip),
80+
$this->minkContext->getSession()->getDriver(),
81+
);
82+
}
83+
84+
$session = $this->minkContext->getSession();
85+
86+
if ($session->getDriver() instanceof \Behat\Mink\Driver\PantherDriver) {
87+
$href = $link->getAttribute('href');
88+
$session->executeScript(sprintf('window.location.href = %s;', json_encode($href)));
89+
90+
$timeoutMs = $timeout !== null ? (int) $timeout : self::DEFAULT_TIMEOUT_MS;
91+
$this->waitForCondition(
92+
fn() => str_contains($session->getPage()->getContent(), $text),
93+
sprintf(
94+
'Text "%s" did not appear within %dms. Current URL: %s. Page excerpt: %s',
95+
$text,
96+
$timeoutMs,
97+
$session->getCurrentUrl(),
98+
substr(strip_tags($session->getPage()->getContent()), 0, 500),
99+
),
100+
$timeoutMs,
101+
);
102+
} else {
103+
$link->click();
104+
$this->waitToSeeText($text, $timeout);
105+
}
106+
}
107+
72108
/**
73109
* Generic wait-for-condition method that polls until timeout.
74110
*

tests/behat/features/Admin/Tresorerie/DevisFactures.feature

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ Feature: Administration - Trésorerie - Devis/Facture
9292
And I should see "Paris Cedex 1"
9393
And I should see a yellow label "En attente"
9494
# Modification de la facture
95-
Then I follow the button of tooltip "Modifier la ligne ESN dev en folie"
96-
And I should see "Modifier une facture"
95+
When I follow the button of tooltip "Modifier la ligne ESN dev en folie" and wait until I see "Modifier une facture"
9796
Then I fill in "ville" with "Paris Cedex 7"
9897
Then I select "1" from "etat_paiement"
9998
When I press "Modifier" and wait until I see "L'écriture a été modifiée"

0 commit comments

Comments
 (0)