From 15af3d68fccdc3ce9f6e63df84961fdda72ff22e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 19 Jun 2020 14:50:33 +0200 Subject: [PATCH] FIX #13877 --- htdocs/compta/facture/card.php | 16 ++++++++++++---- htdocs/langs/en_US/errors.lang | 2 +- htdocs/langs/fr_FR/errors.lang | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 41e2fcd38b8..bf7644a345c 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -319,15 +319,23 @@ if (empty($reshook)) if (($tmp_total_ht < 0 || $tmp_total_ht_devise < 0) && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) { - $langs->load("errors"); if ($object->type == $object::TYPE_DEPOSIT) { + $langs->load("errors"); // Using negative lines on deposit lead to headach and blocking problems when you want to consume them. setEventMessages($langs->trans("ErrorLinesCantBeNegativeOnDeposits"), null, 'errors'); + $error++; + $action = ''; } else { - setEventMessages($langs->trans("ErrorLinesCantBeNegativeForOneVATRate"), null, 'errors'); + $tmpvatratetoshow = explode('_', $vatrate); + $tmpvatratetoshow[0] = round($tmpvatratetoshow[0], 2); + + if ($tmpvatratetoshow[0] != 0) { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorLinesCantBeNegativeForOneVATRate", $tmpvatratetoshow[0]), null, 'errors'); + $error++; + $action = ''; + } } - $error++; - $action = ''; } } } diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index aac47df0d81..2055e24f556 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -118,7 +118,7 @@ ErrorLoginHasNoEmail=This user has no email address. Process aborted. ErrorBadValueForCode=Bad value for security code. Try again with new value... ErrorBothFieldCantBeNegative=Fields %s and %s can't be both negative ErrorFieldCantBeNegativeOnInvoice=Field %s cannot be negative on this type of invoice. If you need to add a discount line, just create the discount first (from field '%s' in thirdparty card) and apply it to the invoice. -ErrorLinesCantBeNegativeForOneVATRate=Total of lines can't be negative for a given VAT rate. +ErrorLinesCantBeNegativeForOneVATRate=Total of lines (net of tax) can't be negative for a given not null VAT rate (Found a negative total for VAT rate %s%%). ErrorLinesCantBeNegativeOnDeposits=Lines can't be negative in a deposit. You will face problems when you will need to consume the deposit in final invoice if you do so. ErrorQtyForCustomerInvoiceCantBeNegative=Quantity for line into customer invoices can't be negative ErrorWebServerUserHasNotPermission=User account %s used to execute web server has no permission for that diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index 6fdaed0fe48..021f08c51c4 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -119,7 +119,7 @@ ErrorLoginHasNoEmail=Cet utilisateur n'a pas d'email. Impossible de continuer. ErrorBadValueForCode=Mauvaise valeur saisie pour le code. Réessayez avec une nouvelle valeur... ErrorBothFieldCantBeNegative=Les champs %s et %s ne peuvent être tous deux négatifs ErrorFieldCantBeNegativeOnInvoice=Le champ %s ne peut pas être négatif sur ce type de facture. Si vous devez ajouter une ligne de remise, créez d'abord la remise (à partir du champ '%s' dans la fiche du tiers) et appliquez-la à la facture. -ErrorLinesCantBeNegativeForOneVATRate=Le total des lignes ne peut pas être négatif pour un taux de TVA donné. +ErrorLinesCantBeNegativeForOneVATRate=Le total des lignes (HT) ne peut pas être négatif pour un taux de TVA donné (Montant total négatif trouvé pour le taux %s%%). ErrorLinesCantBeNegativeOnDeposits=Les lignes ne peuvent pas être négatives dans un acompte. Si vous le faites, vous rencontrerez des problèmes lorsque vous devrez consommer l'acompte dans la facture finale. ErrorQtyForCustomerInvoiceCantBeNegative=La quantité d'une ligne ne peut pas être négative dans les factures clients ErrorWebServerUserHasNotPermission=Le compte d'exécution du serveur web %s n'a pas les permissions pour cela