diff --git a/card.php b/card.php index ee287cc..573235c 100755 --- a/card.php +++ b/card.php @@ -765,8 +765,21 @@ if ($object->id > 0) { $isPaid = ($obj->fk_statut == 2); - // Show if unpaid OR if showing paid invoices - if ($remainToPay > 0 || $isPaid) { + // For paid invoices, check if payment is already linked to a bank entry + $hasLinkedBankEntry = false; + if ($isPaid) { + $sqlPay = "SELECT pf.fk_bank FROM ".MAIN_DB_PREFIX."paiementfourn pf"; + $sqlPay .= " JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn pff ON pf.rowid = pff.fk_paiementfourn"; + $sqlPay .= " WHERE pff.fk_facturefourn = ".((int) $obj->rowid); + $sqlPay .= " AND pf.fk_bank IS NOT NULL AND pf.fk_bank > 0"; + $resqlPay = $db->query($sqlPay); + if ($resqlPay && $db->num_rows($resqlPay) > 0) { + $hasLinkedBankEntry = true; + } + } + + // Show if unpaid OR if paid but not yet linked to bank + if ($remainToPay > 0 || ($isPaid && !$hasLinkedBankEntry)) { $invoiceList[] = array( 'id' => $obj->rowid, 'ref' => $obj->ref, @@ -818,8 +831,21 @@ if ($object->id > 0) { $isPaid = ($obj->fk_statut == 2); - // Show if unpaid OR if showing paid invoices - if ($remainToPay > 0 || $isPaid) { + // For paid invoices, check if payment is already linked to a bank entry + $hasLinkedBankEntry = false; + if ($isPaid) { + $sqlPay = "SELECT p.fk_bank FROM ".MAIN_DB_PREFIX."paiement p"; + $sqlPay .= " JOIN ".MAIN_DB_PREFIX."paiement_facture pf ON p.rowid = pf.fk_paiement"; + $sqlPay .= " WHERE pf.fk_facture = ".((int) $obj->rowid); + $sqlPay .= " AND p.fk_bank IS NOT NULL AND p.fk_bank > 0"; + $resqlPay = $db->query($sqlPay); + if ($resqlPay && $db->num_rows($resqlPay) > 0) { + $hasLinkedBankEntry = true; + } + } + + // Show if unpaid OR if paid but not yet linked to bank + if ($remainToPay > 0 || ($isPaid && !$hasLinkedBankEntry)) { $invoiceList[] = array( 'id' => $obj->rowid, 'ref' => $obj->ref, diff --git a/core/modules/modBankImport.class.php b/core/modules/modBankImport.class.php index 35cdf68..993db47 100755 --- a/core/modules/modBankImport.class.php +++ b/core/modules/modBankImport.class.php @@ -76,7 +76,7 @@ class modBankImport extends DolibarrModules $this->editor_squarred_logo = ''; // Must be image filename into the module/img directory followed with @modulename. Example: 'myimage.png@bankimport' // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z' - $this->version = '1.9'; + $this->version = '2.0'; // Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt';