From 90edd96646e7f6930273ae6a5c541ad4f65cdcdd Mon Sep 17 00:00:00 2001
From: Juanjo Menent <jmenent@2byte.es>
Date: Thu, 18 Sep 2014 09:57:13 +0200
Subject: [PATCH] Fix: Invoices payments may be older than invoices

---
 ChangeLog                         | 1 +
 htdocs/compta/paiement.php        | 4 ++--
 htdocs/fourn/facture/paiement.php | 4 ++--
 htdocs/langs/en_US/errors.lang    | 4 ++--
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 71b895b3645..49fb3fcfa68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -138,6 +138,7 @@ For users:
 - Fix: Must unaccent strings into SEPA file.
 - Fix: Extrafield feature select from table should try to translate multiple column when not needed 
 - Fix: cents for indian ruppes are calle paisa and paise.
+- Fix: Invoices payments may be older than invoices.
 
 ***** ChangeLog for 3.6 compared to 3.5.* *****
 For users:
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index e7d11fb1b99..58bc8734c72 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -109,8 +109,8 @@ if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='ye
 	            if ($datepaye && ($datepaye < $tmpinvoice->date))
 	            {
 	            	$langs->load("errors");
-	                $error++;
-	                setEventMessage($langs->transnoentities("ErrorPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'errors');
+	                //$error++;
+	                setEventMessage($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'warnings');
 	            }
             }
 
diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php
index c66a03382de..a93ac142e9a 100644
--- a/htdocs/fourn/facture/paiement.php
+++ b/htdocs/fourn/facture/paiement.php
@@ -106,8 +106,8 @@ if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='ye
 	            if ($datepaye && ($datepaye < $tmpinvoice->date))
 	            {
 	            	$langs->load("errors");
-	                $error++;
-	                setEventMessage($langs->transnoentities("ErrorPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'errors');
+	                //$error++;
+	                setEventMessage($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye,'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), 'warnings');
 	            }
             }
 
diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang
index 89404614db5..8e76eefaa8d 100644
--- a/htdocs/langs/en_US/errors.lang
+++ b/htdocs/langs/en_US/errors.lang
@@ -133,7 +133,6 @@ ErrorPHPNeedModule=Error, your PHP must have module <b>%s</b> installed to use t
 ErrorOpenIDSetupNotComplete=You setup Dolibarr config file to allow OpenID authentication, but URL of OpenID service is not defined into constant %s
 ErrorWarehouseMustDiffers=Source and target warehouses must differs
 ErrorBadFormat=Bad format!
-ErrorPaymentDateLowerThanInvoiceDate=Payment date (%s) cant' be before invoice date (%s) for invoice %s. 
 ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst=Error, this member is not yet linked to any thirdparty. Link member to an existing third party or create a new thirdparty before creating subscription with invoice.
 ErrorThereIsSomeDeliveries=Error, there is some deliveries linked to this shipment. Deletion refused.
 ErrorCantDeletePaymentReconciliated=Can't delete a payment that had generated a bank transaction that was conciliated
@@ -155,4 +154,5 @@ WarningCloseAlways=Warning, closing is done even if amount differs between sourc
 WarningUsingThisBoxSlowDown=Warning, using this box slow down seriously all pages showing the box.
 WarningClickToDialUserSetupNotComplete=Setup of ClickToDial information for your user are not complete (see tab ClickToDial onto your user card).
 WarningNotRelevant=Irrelevant operation for this dataset
-WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs=Feature disabled when display setup is optimized for blind person or text browsers.
\ No newline at end of file
+WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs=Feature disabled when display setup is optimized for blind person or text browsers.
+WarningPaymentDateLowerThanInvoiceDate=Payment date (%s) is earlier than invoice date (%s) for invoice %s. 
-- 
GitLab