diff --git a/CHANGELOG.md b/CHANGELOG.md index b316b3c..e10de41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.4] - 2024-07-17 + +### Added +- Bolivia bank accounts and bank names + ## [1.1.3] - 2022-07-12 ### Fixed diff --git a/src/Bo/BankNamesRepository.php b/src/Bo/BankNamesRepository.php new file mode 100644 index 0000000..0ff73bb --- /dev/null +++ b/src/Bo/BankNamesRepository.php @@ -0,0 +1,86 @@ +. + * + * This file is part of Saldo.com.ar. Saldo.com.ar can not be copied and/or + * distributed without the express permission of Reyesoft + */ + +namespace BankAccounts\Bo; + +/** + * @internal + */ +final class BankNamesRepository +{ + public const NAMES = [ + 'BNB' => 'Banco Nacional de Bolivia S.A.', + 'BME' => 'Banco Mercantil Santa Cruz S.A.', + 'BIS' => 'Banco Bisa S.A.', + 'BCR' => 'Banco de Crédito de Bolivia S.A.', + 'BEC' => 'Banco Económico S.A.', + 'BGA' => 'Banco Ganadero S.A.', + 'BSO' => 'Banco Solidario S.A.', + 'BNA' => 'Banco de la Nación Argentina', + 'BIE' => 'Banco para el Fomento a Iniciativas Económicas S.A.', + 'BFO' => 'Banco Fortaleza S.A.', + 'BPR' => 'Banco Prodem S.A.', + 'BPY' => 'Bancos PYME', + 'PCO' => 'Banco PYME de la Comunidad S.A.', + 'PEF' => 'Banco PYME Ecofuturo S.A.', + 'BDR' => 'Banco de Desarrollo Productivo S.A.M.', + 'BUN' => 'Banco Unión S.A.', + 'VL1' => 'La Primera Entidad Financiera de Vivienda', + 'VPR' => 'La Promotora Entidad Financiera de Vivienda', + 'VPG' => 'El Progreso Entidad Financiera de Vivienda', + 'CJN' => 'Coop. “Jesús Nazareno” R.L.', + 'CFA' => 'Coop. “Fátima” R.L.', + 'CSM' => 'Coop. “San Martín de Porres” R.L.', + 'CSA' => 'Coop. “San Antonio” R.L.', + 'CIH' => 'Coop. “Inca Huasi” R.L.', + 'CQC' => 'Coop. “Quillacollo” R.L.', + 'CJP' => 'Coop. “San José de Punata” R.L.', + 'CMM' => 'Coop. “Madre y Maestra” R.L.', + 'CLY' => 'Coop. “Loyola” R.L.', + 'CPX' => 'Coop. “Pío” X R.L.', + 'CCR' => 'Coop. “El Chorolque” R.L.', + 'CSP' => 'Coop. “San Pedro” R.L.', + 'CCP' => 'Coop. “Catedral" R.L.', + 'CCM' => 'Coop. “Comarapa” R.L.', + 'CTR' => 'Coop. “Trinidad” R.L.', + 'CEC' => 'Coop. “Educadores Gran Chaco” R.L.', + 'CST' => 'Coop. “San Mateo” R.L.', + 'CMG' => 'Coop. “Monseñor Félix Gainza” R.L.', + 'CMR' => 'Coop. “Magisterio Rural” R.L.', + 'CJB' => 'Coop. “San José de Bermejo” R.L.', + 'CJO' => 'Coop. “San Joaquín” R.L.', + 'CSR' => 'Coop. “San Roque” R.L.', + 'CAS' => 'Coop. “Asunción” R.L.', + 'CCA' => 'Coop. “Catedral de Tarija” R.L.', + 'CME' => 'Coop. “La Merced” R.L.', + 'CCB' => 'Coop. “San Carlos Borromeo” R.L.', + 'CCF' => 'Coop. “CACEF” R.L.', + 'CPG' => 'Coop. “Progreso” R.L.', + 'CLS' => 'Coop. “La Sagrada Familia” R.L.', + 'CMD' => 'Coop. “Magisterio Rural de Chuquisaca” R.L.', + 'CSN' => 'Coop. “San Martín” R.L.', + 'CSQ' => 'Coop. “San Pedro de Aiquile” R.L.', + 'CVE' => 'Coop. “Virgen de los Remedios” R.L.', + 'CLO' => 'Coop. “San Francisco Solano” R.L.', + 'CLC' => 'Coop. “Solucredit San Silvestre” R.L.', + 'COO' => 'Coop. “COOPROLE” R.L.', + 'CEY' => 'Coop. “Cristo Rey Cochabamba” R.L.', + 'CPS' => 'Coop. “Paulo VI” R.L.', + 'CUM' => 'Coop. “Unión Santiago de Machaca USAMA” R.L.', + 'CAE' => 'Coop. “Cantera” R.L.', + 'CHO' => 'Coop. “Hospicio” R.L.', + 'ICI' => 'Institución Financiera de Desarrollo CIDRE IFD', + 'ICR' => 'Institución Financiera de Desarrollo CRECER IFD', + 'IDI' => 'Institución Financiera de Desarrollo DIACONÍA FRID - IFD', + 'IFO' => 'Institución Financiera de Desarrollo FONDECO IFD', + 'IFU' => 'Institución Financiera de Desarrollo FUBODE IFD', + 'IID' => 'Institución Financiera de Desarrollo IDEPRO IFD', + 'IIM' => 'Institución Financiera de Desarrollo IMPRO IFD', + 'IPM' => 'Institución Financiera de Desarrollo Fundación PRO MUJER IFD', + ]; +} diff --git a/src/Bo/BoBankAccount.php b/src/Bo/BoBankAccount.php new file mode 100644 index 0000000..30cc042 --- /dev/null +++ b/src/Bo/BoBankAccount.php @@ -0,0 +1,52 @@ +. + * + * This file is part of Saldo.com.ar. Saldo.com.ar can not be copied and/or + * distributed without the express permission of Reyesoft + */ + +namespace BankAccounts\Bo; + +use BankAccounts\BankAccount; +use BankAccounts\BankAccountInterface; + +class BoBankAccount extends BankAccount implements BankAccountInterface +{ + public function __construct(string $cci) + { + $this->bank_account_number = $cci; + } + + public function getAccountTile(): string + { + return 'CCI'; + } + + public function isValid(): bool + { + if (preg_match('/^([a-zA-Z]{3})\+([0-9]{22})$/', $this->bank_account_number) !== 1) { + return false; + } + + return true; + } + + public function getBankId(): ?string + { + return substr($this->bank_account_number, 0, 3); + } + + public function getBankName(): ?string + { + $id = self::getBankId(); + + return BankNamesRepository::NAMES[$id] ?? null; + } + + /** @codeCoverageIgnore */ + public function getInternalBankAccountNumber(): ?string + { + return null; + } +} diff --git a/tests/Bo/BoBankAccountTest.php b/tests/Bo/BoBankAccountTest.php new file mode 100644 index 0000000..e0ce65a --- /dev/null +++ b/tests/Bo/BoBankAccountTest.php @@ -0,0 +1,42 @@ +. + * + * This file is part of Saldo.com.ar. Saldo.com.ar can not be copied and/or + * distributed without the express permission of Reyesoft + */ + +namespace Tests\Bo; + +use BankAccounts\Bo\BoBankAccount; +use PHPUnit\Framework\TestCase; + +/** + * @covers \BankAccounts\Bo\BoBankAccount + * + * @internal + */ +final class BoBankAccountTest extends TestCase +{ + public function testIsValid(): void + { + static::assertFalse((new BoBankAccount(''))->isValid()); + static::assertFalse((new BoBankAccount('111111111'))->isValid()); + static::assertFalse((new BoBankAccount('AAAAA0000'))->isValid()); + static::assertFalse((new BoBankAccount('01340946340001361695'))->isValid()); + static::assertFalse((new BoBankAccount('AAAAA0000'))->isValid()); + static::assertFalse((new BoBankAccount('01050194651194-079423'))->isValid()); + static::assertFalse((new BoBankAccount('01050194651194079423 More text?'))->isValid()); + static::assertTrue((new BoBankAccount('ASD+1234567891234567891234'))->isValid()); + } + + public function testBankName(): void + { + static::assertNull((new BoBankAccount('00050194697194012294'))->getBankName()); + } + + public function testAccountTile(): void + { + static::assertSame('CCI', (new BoBankAccount('01050194697194012294'))->getAccountTile()); + } +}