Amélioration contrôles saisie facture
This commit is contained in:
parent
6e2ee31670
commit
f63f3b6ecd
@ -94,10 +94,15 @@ $form->runIf(f('save') && !$form->hasErrors(),
|
|||||||
$data['type_facture'] = f('type');
|
$data['type_facture'] = f('type');
|
||||||
if (in_array(f('type'), [DEVIS, FACT]))
|
if (in_array(f('type'), [DEVIS, FACT]))
|
||||||
{
|
{
|
||||||
foreach(f('designation') as $k=>$value)
|
foreach(f('designation') as $k=>$value)
|
||||||
{
|
{
|
||||||
if ($value != '' && f('prix')[$k] == null) {
|
if (empty($value) && f('prix')[$k] != null) {
|
||||||
|
throw new UserException("Il manque la désignation de la ligne " . $k+1 . " !!");
|
||||||
|
}
|
||||||
|
elseif ($value != '' && f('prix')[$k] == null) {
|
||||||
throw new UserException('Il manque le prix sur la ligne '. $k+1 . ' !!');
|
throw new UserException('Il manque le prix sur la ligne '. $k+1 . ' !!');
|
||||||
|
} elseif (empty($value) && f('prix')[$k] == null) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['contenu'][$k]['designation'] = $value;
|
$data['contenu'][$k]['designation'] = $value;
|
||||||
@ -106,6 +111,9 @@ $form->runIf(f('save') && !$form->hasErrors(),
|
|||||||
}
|
}
|
||||||
$data['total'] = $data['toto'];
|
$data['total'] = $data['toto'];
|
||||||
unset($data['toto']);
|
unset($data['toto']);
|
||||||
|
if (! isset($data['contenu'])) {
|
||||||
|
throw new UserException("Aucune désignation ni aucun prix saisi !!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elseif ( f('type') == CERFA )
|
elseif ( f('type') == CERFA )
|
||||||
{
|
{
|
||||||
@ -142,45 +150,45 @@ $form->runIf(f('save') && !$form->hasErrors(),
|
|||||||
|
|
||||||
$form->runIf(f('select_cotis') && !$form->hasErrors(),
|
$form->runIf(f('select_cotis') && !$form->hasErrors(),
|
||||||
function () use ($step)
|
function () use ($step)
|
||||||
{
|
{
|
||||||
$step = true;
|
$step = true;
|
||||||
}, 'add_cotis_1');
|
}, 'add_cotis_1');
|
||||||
|
|
||||||
$form->runIf(f('add_cotis') && !$form->hasErrors(),
|
$form->runIf(f('add_cotis') && !$form->hasErrors(),
|
||||||
function () use ($radio, $fields, $facture, $form)
|
function () use ($radio, $fields, $facture, $form)
|
||||||
{
|
{
|
||||||
$radio['type'] = f('cotisation');
|
$radio['type'] = f('cotisation');
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$num = (int) str_replace('cotis_', '', $radio['type']);
|
$num = (int) str_replace('cotis_', '', $radio['type']);
|
||||||
foreach($fields as $field)
|
foreach($fields as $field)
|
||||||
{
|
{
|
||||||
$cotis[$field] = f($field.'_'.$num);
|
$cotis[$field] = f($field.'_'.$num);
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = $facture->getCotis(f('membre_cotis'), $cotis['id']);
|
$r = $facture->getCotis(f('membre_cotis'), $cotis['id']);
|
||||||
$r = $r[0];
|
$r = $r[0];
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'type_facture' => COTIS,
|
'type_facture' => COTIS,
|
||||||
'numero' => f('numero_facture'),
|
'numero' => f('numero_facture'),
|
||||||
'receveur_membre' => 1,
|
'receveur_membre' => 1,
|
||||||
'receveur_id' => f('membre_cotis'),
|
'receveur_id' => f('membre_cotis'),
|
||||||
'date_emission' => f('date_emission'),
|
'date_emission' => f('date_emission'),
|
||||||
'moyen_paiement' => 'AU',
|
'moyen_paiement' => 'AU',
|
||||||
'total' => $r->paid_amount ?? $r->amount,
|
'total' => $r->paid_amount ?? $r->amount,
|
||||||
'contenu' => ['id' => $cotis['id'],
|
'contenu' => ['id' => $cotis['id'],
|
||||||
'intitule' => $cotis['label'],
|
'intitule' => $cotis['label'],
|
||||||
'souscription' => $cotis['date'],
|
'souscription' => $cotis['date'],
|
||||||
'expiration' => $cotis['expiry'] ]
|
'expiration' => $cotis['expiry'] ]
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (UserException $e)
|
catch (UserException $e)
|
||||||
{
|
{
|
||||||
$form->addError($e->getMessage());
|
$form->addError($e->getMessage());
|
||||||
}
|
}
|
||||||
}, 'add_cotis_2');
|
}, 'add_cotis_2');
|
||||||
|
|
||||||
if (! $form->hasErrors())
|
if (! $form->hasErrors())
|
||||||
{
|
{
|
||||||
@ -314,8 +322,10 @@ if (in_array($radio['type'], [DEVIS, FACT]))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$designations = ['Exemple'];
|
/*
|
||||||
$prix = [250];
|
$designations = ['Exemple'];
|
||||||
|
$prix = [250];
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,10 +144,13 @@ class Facture
|
|||||||
unset($datas[$k]['prix']);
|
unset($datas[$k]['prix']);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
elseif (empty($r['prix']))
|
elseif (! is_numeric($r['prix']) && empty($r['prix']))
|
||||||
{
|
{
|
||||||
$datas[$k]['prix'] = 0;
|
$datas[$k]['prix'] = 0;
|
||||||
}
|
}
|
||||||
|
elseif (empty($r['designation'])) {
|
||||||
|
throw new UserException("Une au moins des désignations est absente.");
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_int($r['prix']))
|
if (!is_int($r['prix']))
|
||||||
{
|
{
|
||||||
@ -157,7 +160,7 @@ class Facture
|
|||||||
$total += $r['prix'];
|
$total += $r['prix'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($fac && !$total)
|
if ($fac && count($datas['contenu']) == 0)
|
||||||
{
|
{
|
||||||
throw new UserException("Toutes les désignations/prix sont vides.");
|
throw new UserException("Toutes les désignations/prix sont vides.");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user