FIX Can't modify vendor invoice if transfered into accountancy
This commit is contained in:
parent
6cd3d27885
commit
0b9d27423d
@ -4617,7 +4617,7 @@ elseif ($id > 0 || ! empty($ref))
|
|||||||
// Editer une facture deja validee, sans paiement effectue et pas exporte en compta
|
// Editer une facture deja validee, sans paiement effectue et pas exporte en compta
|
||||||
if ($object->statut == Facture::STATUS_VALIDATED)
|
if ($object->statut == Facture::STATUS_VALIDATED)
|
||||||
{
|
{
|
||||||
// On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees
|
// We check if lines of invoice are not already transfered into accountancy
|
||||||
$ventilExportCompta = $object->getVentilExportCompta();
|
$ventilExportCompta = $object->getVentilExportCompta();
|
||||||
|
|
||||||
if ($ventilExportCompta == 0)
|
if ($ventilExportCompta == 0)
|
||||||
@ -4652,7 +4652,7 @@ elseif ($id > 0 || ! empty($ref))
|
|||||||
if ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT)
|
if ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT)
|
||||||
|| ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id))
|
|| ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id))
|
||||||
|| ($object->type == Facture::TYPE_DEPOSIT && empty($discount->id)))
|
|| ($object->type == Facture::TYPE_DEPOSIT && empty($discount->id)))
|
||||||
&& ($object->statut == 2 || $object->statut == 3 || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data
|
&& ($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data
|
||||||
&& ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) // A paid invoice (partially or completely)
|
&& ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) // A paid invoice (partially or completely)
|
||||||
{
|
{
|
||||||
if ($object->close_code != 'replaced' || (! $objectidnext)) // Not replaced by another invoice or replaced but the replacement invoice has been deleted
|
if ($object->close_code != 'replaced' || (! $objectidnext)) // Not replaced by another invoice or replaced but the replacement invoice has been deleted
|
||||||
@ -4834,7 +4834,7 @@ elseif ($id > 0 || ! empty($ref))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove situation from cycle
|
// Remove situation from cycle
|
||||||
if ($object->statut > Facture::STATUS_DRAFT
|
if ($object->statut > Facture::STATUS_DRAFT
|
||||||
&& $object->type == Facture::TYPE_SITUATION
|
&& $object->type == Facture::TYPE_SITUATION
|
||||||
&& $usercancreate
|
&& $usercancreate
|
||||||
|
|||||||
@ -639,7 +639,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
|||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
|
|
||||||
print '<td>';
|
print '<td class="nowraponall">';
|
||||||
print $invoice->getNomUrl(1, '');
|
print $invoice->getNomUrl(1, '');
|
||||||
if ($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' ';
|
if ($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' ';
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
@ -650,7 +650,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
|||||||
// Due date
|
// Due date
|
||||||
if ($objp->dlr > 0 )
|
if ($objp->dlr > 0 )
|
||||||
{
|
{
|
||||||
print '<td align="center">';
|
print '<td class="nowraponall center">';
|
||||||
print dol_print_date($db->jdate($objp->dlr), 'day');
|
print dol_print_date($db->jdate($objp->dlr), 'day');
|
||||||
|
|
||||||
if ($invoice->hasDelay())
|
if ($invoice->hasDelay())
|
||||||
|
|||||||
@ -1416,10 +1416,12 @@ if (empty($reshook))
|
|||||||
$resteapayer = $object->total_ttc - $totalpaye;
|
$resteapayer = $object->total_ttc - $totalpaye;
|
||||||
|
|
||||||
// On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees
|
// On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees
|
||||||
//$ventilExportCompta = $object->getVentilExportCompta();
|
$ventilExportCompta = $object->getVentilExportCompta();
|
||||||
|
|
||||||
|
if (! $ventilExportCompta)
|
||||||
|
{
|
||||||
// On verifie si aucun paiement n'a ete effectue
|
// On verifie si aucun paiement n'a ete effectue
|
||||||
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0)
|
if ($resteapayer == price2num($object->total_ttc, 'MT', 1) && $object->statut == FactureFournisseur::STATUS_VALIDATED)
|
||||||
{
|
{
|
||||||
$idwarehouse = GETPOST('idwarehouse');
|
$idwarehouse = GETPOST('idwarehouse');
|
||||||
|
|
||||||
@ -1470,6 +1472,7 @@ if (empty($reshook))
|
|||||||
$action='';
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set invoice to validated/unpaid status
|
// Set invoice to validated/unpaid status
|
||||||
elseif ($action == 'reopen' && $user->rights->fournisseur->facture->creer)
|
elseif ($action == 'reopen' && $user->rights->fournisseur->facture->creer)
|
||||||
@ -3032,12 +3035,21 @@ else
|
|||||||
// modified by hook
|
// modified by hook
|
||||||
if (empty($reshook))
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
|
|
||||||
// Modify a validated invoice with no payments
|
// Modify a validated invoice with no payments
|
||||||
if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'confirm_edit' && $object->getSommePaiement() == 0 && $user->rights->fournisseur->facture->creer)
|
if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $action != 'confirm_edit' && $object->getSommePaiement() == 0 && $user->rights->fournisseur->facture->creer)
|
||||||
|
{
|
||||||
|
// We check if lines of invoice are not already transfered into accountancy
|
||||||
|
$ventilExportCompta = $object->getVentilExportCompta(); // Should be 0 since the sum of payments are zero. But we keep the protection.
|
||||||
|
|
||||||
|
if ($ventilExportCompta == 0)
|
||||||
{
|
{
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit">'.$langs->trans('Modify').'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit">'.$langs->trans('Modify').'</a></div>';
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="' . $langs->trans("DisabledBecauseDispatchedInBookkeeping") . '">' . $langs->trans('Modify') . '</span></div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$discount = new DiscountAbsolute($db);
|
$discount = new DiscountAbsolute($db);
|
||||||
$result = $discount->fetch(0, 0, $object->id);
|
$result = $discount->fetch(0, 0, $object->id);
|
||||||
@ -3045,7 +3057,7 @@ else
|
|||||||
// Reopen a standard paid invoice
|
// Reopen a standard paid invoice
|
||||||
if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_REPLACEMENT
|
if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_REPLACEMENT
|
||||||
|| ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && empty($discount->id)))
|
|| ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && empty($discount->id)))
|
||||||
&& ($object->statut == 2 || $object->statut == 3)) // A paid invoice (partially or completely)
|
&& ($object->statut == FactureFournisseur::STATUS_CLOSED || $object->statut == FactureFournisseur::STATUS_ABANDONED)) // A paid invoice (partially or completely)
|
||||||
{
|
{
|
||||||
if (! $facidnext && $object->close_code != 'replaced' && $user->rights->fournisseur->facture->creer) // Not replaced by another invoice
|
if (! $facidnext && $object->close_code != 'replaced' && $user->rights->fournisseur->facture->creer) // Not replaced by another invoice
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user