From a35ed5d7564fd612ce26416fb5ebc9a6452bfe00 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Thu, 17 Jun 2010 21:43:46 +0000
Subject: [PATCH] New: IBAN value is called IFSC if country is India

---
 ChangeLog                                        |  1 +
 htdocs/compta/bank/bankid_fr.php                 |  6 +++++-
 htdocs/compta/bank/class/account.class.php       |  2 +-
 htdocs/install/mysql/migration/2.8.0-2.9.0.sql   |  1 +
 htdocs/install/mysql/tables/llx_bank_account.sql |  3 ++-
 htdocs/lib/pdf.lib.php                           | 13 +++++++++++--
 6 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4936ff363a5..03a86442e4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -36,6 +36,7 @@ For users:
 - New: Can now send supplier order by mail.
 - New: task #10076 : Show content of message in notification module.
 - New: Bank name available on invoice.
+- New: IBAN value is called IFSC if country is India
 - Fix: Debug experimental module widthrawal.
 - Fix: Format number was wrong for ar_AR language.
 - Fix: Can change password if has only permission change password.
diff --git a/htdocs/compta/bank/bankid_fr.php b/htdocs/compta/bank/bankid_fr.php
index 80209738d20..d20a901620b 100644
--- a/htdocs/compta/bank/bankid_fr.php
+++ b/htdocs/compta/bank/bankid_fr.php
@@ -199,6 +199,10 @@ if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit')
 		print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="3">';
 		print nl2br($account->adresse_proprio);
 		print "</td></tr>\n";
+
+		print '<tr><td valign="top">'.$langs->trans("CountryCode").'</td><td colspan="3">';
+		print $account->getCountryCode();
+		print "</td></tr>\n";
 	}
 
 	print '</table>';
@@ -232,7 +236,7 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure
 	$account = new Account($db, $_GET["id"]);
 	$account->fetch($_GET["id"]);
 
-	print_titre($langs->trans("EditFinancialAccount"));
+	print_fiche_titre($langs->trans("EditFinancialAccount"));
 	print "<br>";
 
 	if ($message) { print "$message<br>\n"; }
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index 8e10da2c452..e11d278e045 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -824,7 +824,7 @@ class Account extends CommonObject
 	/**
 	 * 	\brief		Return account country code
 	 *	\return		String		country code
-	 * 	TODO	Add a field in bank_account table to store country
+	 * 	TODO	Manage field with country in bank_account
 	 */
 	function getCountryCode()
 	{
diff --git a/htdocs/install/mysql/migration/2.8.0-2.9.0.sql b/htdocs/install/mysql/migration/2.8.0-2.9.0.sql
index 2bd1fb560ac..61850bbd2ca 100755
--- a/htdocs/install/mysql/migration/2.8.0-2.9.0.sql
+++ b/htdocs/install/mysql/migration/2.8.0-2.9.0.sql
@@ -11,6 +11,7 @@
 -- V4.1 UPDATE llx_projet_task set fk_user_creat=NULL WHERE fk_user_creat IS NOT NULL AND fk_user_creat NOT IN (SELECT rowid from llx_user);
 -- V4.1 UPDATE llx_projet_task set fk_user_valid=NULL WHERE fk_user_valid IS NOT NULL AND fk_user_valid NOT IN (SELECT rowid from llx_user);
 
+ALTER table llx_bank_account ADD COLUMN fk_pays        integer        DEFAULT 0 after domiciliation;
 
 ALTER TABLE llx_socpeople ADD COLUMN fk_departement integer        DEFAULT NULL after ville;
 ALTER TABLE llx_adherent  ADD COLUMN fk_departement integer        DEFAULT NULL after ville;
diff --git a/htdocs/install/mysql/tables/llx_bank_account.sql b/htdocs/install/mysql/tables/llx_bank_account.sql
index 5dca73fa633..41918c805dc 100644
--- a/htdocs/install/mysql/tables/llx_bank_account.sql
+++ b/htdocs/install/mysql/tables/llx_bank_account.sql
@@ -38,9 +38,10 @@ create table llx_bank_account
   cle_rib        varchar(5),
   bic            varchar(11),
   iban_prefix    varchar(34),                 -- 34 according to ISO 13616
-  country_iban   varchar(2),
+  country_iban   varchar(2),				-- deprecated
   cle_iban       varchar(2),
   domiciliation  varchar(255),
+  fk_pays        integer        DEFAULT 0,
   proprio        varchar(60),
   adresse_proprio varchar(255),
   courant        smallint DEFAULT 0 NOT NULL,
diff --git a/htdocs/lib/pdf.lib.php b/htdocs/lib/pdf.lib.php
index 7bf5ae89afb..6f2b2d9d0c8 100644
--- a/htdocs/lib/pdf.lib.php
+++ b/htdocs/lib/pdf.lib.php
@@ -122,6 +122,8 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height)
  */
 function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account)
 {
+	global $mysoc;
+
 	$pdf->SetXY ($curx, $cury);
 	$pdf->SetFont('Arial','B',8);
 	$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0);
@@ -129,6 +131,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account)
 
 	$outputlangs->load("banks");
 
+	// Get format of bank id according to country of $account
 	$usedetailedbban=$account->useDetailedBBAN();
 
 	if ($usedetailedbban)
@@ -176,13 +179,19 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account)
 		$cury-=9;
 	}
 
+	// Use correct name of bank id according to country
+	$ibankey="IBANNumber";
+	$bickey="BICNumber";
+	if ($account->getCountryCode() == 'IN') $ibankey="IFSC";
+	if ($account->getCountryCode() == 'IN') $bickey="SWIFT";
+
 	$pdf->SetFont('Arial','',6);
 	$pdf->SetXY ($curx, $cury+12);
 	$pdf->MultiCell(90, 3, $outputlangs->transnoentities("Residence").': ' . $outputlangs->convToOutputCharset($account->domiciliation), 0, 'L', 0);
 	$pdf->SetXY ($curx, $cury+22);
-	$pdf->MultiCell(90, 3, $outputlangs->transnoentities("IBANNumber").': ' . $outputlangs->convToOutputCharset($account->iban), 0, 'L', 0);
+	$pdf->MultiCell(90, 3, $outputlangs->transnoentities($ibankey).': ' . $outputlangs->convToOutputCharset($account->iban), 0, 'L', 0);
 	$pdf->SetXY ($curx, $cury+25);
-	$pdf->MultiCell(90, 3, $outputlangs->transnoentities("BICNumber").': ' . $outputlangs->convToOutputCharset($account->bic), 0, 'L', 0);
+	$pdf->MultiCell(90, 3, $outputlangs->transnoentities($bickey).': ' . $outputlangs->convToOutputCharset($account->bic), 0, 'L', 0);
 
 	return $pdf->getY();
 }
-- 
GitLab