Add hidden option to allow negative invoices (for test purpose only,

negative invoices should be done using credit note).
This commit is contained in:
Laurent Destailleur 2012-03-15 22:38:55 +01:00
parent 5f8fc30121
commit 1f0cddc464

View File

@ -228,7 +228,7 @@ else if ($action == 'valid')
else else
{ {
// Si non avoir, le signe doit etre positif // Si non avoir, le signe doit etre positif
if ($object->total_ht < 0) if (empty($conf->global->FACTURE_ENABLE_NEGATIVE) && $object->total_ht < 0)
{ {
$mesg='<div class="error">'.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive").'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive").'</div>';
$action=''; $action='';
@ -2089,8 +2089,11 @@ else
//array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1))); array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1)));
} }
if ($object->type != 2 && $object->total_ttc < 0) // Can happen only if $conf->global->FACTURE_ENABLE_NEGATIVE is on
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ValidateBill'),$text,'confirm_valid',$formquestion,"yes",($conf->notification->enabled?0:2)); {
$text.='<br>'.img_warning().' '.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive");
}
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('ValidateBill'),$text,'confirm_valid',$formquestion,(($object->type != 2 && $object->total_ttc < 0)?"no":"yes"),($conf->notification->enabled?0:2));
} }
// Confirm back to draft status // Confirm back to draft status
@ -2822,14 +2825,13 @@ else
// Validate // Validate
if ($object->statut == 0 && count($object->lines) > 0 && if ($object->statut == 0 && count($object->lines) > 0 &&
( (
(($object->type == 0 || $object->type == 1 || $object->type == 3 || $object->type == 4) && $object->total_ttc >= 0) (($object->type == 0 || $object->type == 1 || $object->type == 3 || $object->type == 4) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0))
|| ($object->type == 2 && $object->total_ttc <= 0)) || ($object->type == 2 && $object->total_ttc <= 0))
) )
{ {
if ($user->rights->facture->valider) if ($user->rights->facture->valider)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=valid"'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=valid">'.$langs->trans('Validate').'</a>';
print '>'.$langs->trans('Validate').'</a>';
} }
} }