diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 3fdfbc0c514..72cfa38e8c2 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -903,7 +903,8 @@ if ($resql)
print "\n";
$projectstatic=new Project($db);
-
+ $discount = new DiscountAbsolute($db);
+
if ($num > 0)
{
$i=0;
@@ -920,6 +921,9 @@ if ($resql)
$facturestatic->total_tva=$obj->total_vat;
$facturestatic->total_ttc=$obj->total_ttc;
$facturestatic->statut=$obj->fk_statut;
+ $facturestatic->total_ttc=$obj->total_ttc;
+ $facturestatic->paye=$obj->paye;
+ $facturestatic->fk_soc=$obj->fk_soc;
$facturestatic->date_lim_reglement=$db->jdate($obj->datelimite);
$facturestatic->note_public=$obj->note_public;
$facturestatic->note_private=$obj->note_private;
@@ -939,7 +943,12 @@ if ($resql)
$totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
$totaldeposits = $facturestatic->getSumDepositsUsed();
$totalpay = $paiement + $totalcreditnotes + $totaldeposits;
- $remaintopay = $obj->total_ttc - $totalpay;
+ $remaintopay = $facturestatic->total_ttc - $totalpay;
+ if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) {
+ $remaincreditnote = $discount->getAvailableDiscounts($obj->fk_soc, '', 'rc.fk_facture_source='.$facturestatic->id);
+ $remaintopay = -$remaincreditnote;
+ $totalpay = $facturestatic->total_ttc - $remaintopay;
+ }
print '
';
if (! empty($arrayfields['f.facnumber']['checked']))
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index e5fc015da93..4dc50a3d623 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -1069,9 +1069,9 @@ class Contact extends CommonObject
function getNbOfEMailings()
{
$sql = "SELECT count(mc.email) as nb";
- $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
- $sql.= " WHERE mc.email = '".$this->db->escape($this->email)."'";
- $sql.= " AND mc.statut NOT IN (-1,0)"; // -1 erreur, 0 non envoye, 1 envoye avec succes
+ $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."mailing as m";
+ $sql.= " WHERE mc.fk_mailing=m.rowid AND mc.email = '".$this->db->escape($this->email)."' ";
+ $sql.= " AND m.entity IN (".getEntity($this->element).") AND mc.statut NOT IN (-1,0)"; // -1 error, 0 not sent, 1 sent with success
$resql=$this->db->query($sql);
if ($resql)
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 30e9c054262..b15fb19dc23 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -5213,6 +5213,12 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer,
}
}
+ // Si (vendeur en France et acheteur hors Communaute europeenne et acheteur particulier) alors TVA par defaut=TVA du produit vendu. Fin de regle
+ if (! empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC) && empty($buyer_in_cee) && !$thirdparty_buyer->isACompany())
+ {
+ return get_product_vat_for_country($idprod,$thirdparty_seller,$idprodfournprice);
+ }
+
// Sinon la TVA proposee par defaut=0. Fin de regle.
// Rem: Cela signifie qu'au moins un des 2 est hors Communaute europeenne et que le pays differe
//print 'VATRULE 5';
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 12d0e777b19..90305eeab3b 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -1793,6 +1793,7 @@ MAIN_PDF_MARGIN_LEFT=Left margin on PDF
MAIN_PDF_MARGIN_RIGHT=Right margin on PDF
MAIN_PDF_MARGIN_TOP=Top margin on PDF
MAIN_PDF_MARGIN_BOTTOM=Bottom margin on PDF
+NothingToSetup=There is no specific setup to do for this module.
SetToYesIfGroupIsComputationOfOtherGroups=Set this to yes if this group is a computation of other groups
EnterCalculationRuleIfPreviousFieldIsYes=Enter calculation rule if previous field was set to Yes (For example 'CODEGRP1+CODEGRP2')
SeveralLangugeVariatFound=Several language variants found
diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php
index ba01619bd50..02a6260bad1 100644
--- a/htdocs/societe/card.php
+++ b/htdocs/societe/card.php
@@ -1396,16 +1396,13 @@ else
print '
';
}
- if ($user->rights->societe->client->voir)
- {
- // Assign a Name
- print '';
- print '| '.fieldLabel('AllocateCommercial','commercial_id').' | ';
- print '';
- $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 1);
- print $form->multiselectarray('commercial', $userlist, GETPOST('commercial', 'array'), null, null, null, null, "90%");
- print ' |
';
- }
+ // Assign a Name
+ print '';
+ print '| '.fieldLabel('AllocateCommercial','commercial_id').' | ';
+ print '';
+ $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 1);
+ print $form->multiselectarray('commercial', $userlist, (count(GETPOST('commercial', 'array')) > 0?GETPOST('commercial', 'array'):(empty($user->rights->societe->client->voir)?array($user->id):array())), null, null, null, null, "90%");
+ print ' |
';
// Incoterms
if (!empty($conf->incoterm->enabled))