diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index d3faa909ac2..92ff891cca9 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -266,36 +266,46 @@ else if ($action == 'setmode' && $user->rights->facture->creer)
else if ($action == 'setinvoicedate' && $user->rights->facture->creer)
{
$object->fetch($id);
+ $old_date_lim_reglement=$object->date_lim_reglement;
$object->date=dol_mktime(12,0,0,$_POST['invoicedatemonth'],$_POST['invoicedateday'],$_POST['invoicedateyear']);
+ $new_date_lim_reglement=$object->calculate_date_lim_reglement();
+ if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement=$new_date_lim_reglement;
if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement=$object->date;
$result=$object->update($user);
if ($result < 0) dol_print_error($db,$object->error);
}
+else if ($action == 'setconditions' && $user->rights->facture->creer)
+{
+ $object->fetch($id);
+ $object->cond_reglement_code=0; // To clean property
+ $object->cond_reglement_id=0; // To clean property
+ $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
+ if ($result < 0) dol_print_error($db,$object->error);
+
+ $old_date_lim_reglement=$object->date_lim_reglement;
+ $new_date_lim_reglement=$object->calculate_date_lim_reglement();
+ if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement=$new_date_lim_reglement;
+ if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement=$object->date;
+ $result=$object->update($user);
+ if ($result < 0) dol_print_error($db,$object->error);
+}
else if ($action == 'setpaymentterm' && $user->rights->facture->creer)
{
$object->fetch($id);
$object->date_lim_reglement=dol_mktime(12,0,0,$_POST['paymenttermmonth'],$_POST['paymenttermday'],$_POST['paymenttermyear']);
if ($object->date_lim_reglement < $object->date)
{
- $object->date_lim_reglement=$object->date;
+ $object->date_lim_reglement=$object->calculate_date_lim_reglement();
setEventMessage($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"),'warnings');
}
$result=$object->update($user);
if ($result < 0) dol_print_error($db,$object->error);
}
-else if ($action == 'setconditions' && $user->rights->facture->creer)
-{
- $object->fetch($id);
- $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
- if ($result < 0) dol_print_error($db,$object->error);
-}
-
else if ($action == 'setremisepercent' && $user->rights->facture->creer)
{
$object->fetch($id);
$result = $object->set_remise($user, $_POST['remise_percent']);
}
-
else if ($action == "setabsolutediscount" && $user->rights->facture->creer)
{
// POST[remise_id] ou POST[remise_id_for_payment]
@@ -764,7 +774,7 @@ else if ($action == 'add' && $user->rights->facture->creer)
if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; }
if ($element == 'contract') { $element = $subelement = 'contrat'; }
if ($element == 'inter') { $element = $subelement = 'ficheinter'; }
- if ($element == 'shipping') {$element = $subelement = 'expedition'; }
+ if ($element == 'shipping') { $element = $subelement = 'expedition'; }
$object->origin = $_POST['origin'];
$object->origin_id = $_POST['originid'];
@@ -2823,14 +2833,40 @@ else if ($id > 0 || ! empty($ref))
print '';
- // Margin Infos
- if (! empty($conf->margin->enabled)) {
- print '
';
- $object->displayMarginInfos($object->statut > 0);
- }
+ // Margin Infos
+ if (! empty($conf->margin->enabled))
+ {
+ print '
';
+ $object->displayMarginInfos($object->statut > 0);
+ }
print '';
+ // Conditions de reglement
+ print '
| ';
+ print '';
+ print ' | ';
+ if ($object->type != 2)
+ {
+ if ($action == 'editconditions')
+ {
+ $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
+ }
+ else
+ {
+ $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->cond_reglement_id,'none');
+ }
+ }
+ else
+ {
+ print ' ';
+ }
+ print ' |
';
+
// Date payment term
print '';
print '| ';
@@ -2857,32 +2893,7 @@ else if ($id > 0 || ! empty($ref))
}
print ' | ';
- // Conditions de reglement
- print '| ';
- print '';
- print ' | ';
- if ($object->type != 2)
- {
- if ($action == 'editconditions')
- {
- $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
- }
- else
- {
- $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->cond_reglement_id,'none');
- }
- }
- else
- {
- print ' ';
- }
- print ' | ';
-
- // Mode de reglement
+ // Payment mode
print '';
print '| ';
print $langs->trans('PaymentMode');
@@ -2907,23 +2918,20 @@ else if ($id > 0 || ! empty($ref))
print ' | | '.$langs->trans('AmountVAT').' | '.price($object->total_tva).' | ';
print ''.$langs->trans('Currency'.$conf->currency).' | ';
- print ' ';
+ print '';
// Amount Local Taxes
- if ($mysoc->pays_code=='ES')
+ if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
{
- if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
- {
- print '| '.$langs->transcountry("AmountLT1",$mysoc->pays_code).' | ';
- print ''.price($object->total_localtax1).' | ';
- print ''.$langs->trans("Currency".$conf->currency).' | ';
- }
- if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
- {
- print '| '.$langs->transcountry("AmountLT2",$mysoc->pays_code).' | ';
- print ''.price($object->total_localtax2).' | ';
- print ''.$langs->trans("Currency".$conf->currency).' | ';
- }
+ print '| '.$langs->transcountry("AmountLT1",$mysoc->pays_code).' | ';
+ print ''.price($object->total_localtax1).' | ';
+ print ''.$langs->trans("Currency".$conf->currency).' | ';
+ }
+ if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
+ {
+ print '| '.$langs->transcountry("AmountLT2",$mysoc->pays_code).' | ';
+ print ''.price($object->total_localtax2).' | ';
+ print ''.$langs->trans("Currency".$conf->currency).' | ';
}
print '| '.$langs->trans('AmountTTC').' | '.price($object->total_ttc).' | ';
|
|