Files
firefly-iii/database/seeders/TransactionCurrencySeeder.php

84 lines
4.3 KiB
PHP
Raw Normal View History

2015-02-06 04:41:00 +01:00
<?php
2022-12-29 19:43:43 +01:00
2017-12-10 09:02:26 +01:00
/**
* TransactionCurrencySeeder.php
2020-03-17 16:06:30 +00:00
* Copyright (c) 2019 james@firefly-iii.org.
2017-12-10 09:02:26 +01:00
*
* This file is part of Firefly III (https://github.com/firefly-iii).
2017-12-10 09:02:26 +01:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
2017-12-10 09:02:26 +01:00
*
* This program is distributed in the hope that it will be useful,
2017-12-10 09:02:26 +01:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
2017-12-10 09:02:26 +01:00
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2017-12-10 09:02:26 +01:00
*/
2017-03-25 13:41:17 +01:00
declare(strict_types=1);
2015-02-06 04:41:00 +01:00
2020-11-02 06:20:49 +01:00
namespace Database\Seeders;
2015-02-06 05:01:24 +01:00
use FireflyIII\Models\TransactionCurrency;
2015-02-11 07:35:10 +01:00
use Illuminate\Database\Seeder;
2015-02-06 04:41:00 +01:00
/**
2020-03-17 16:06:30 +00:00
* Class TransactionCurrencySeeder.
2015-02-06 04:41:00 +01:00
*/
class TransactionCurrencySeeder extends Seeder
{
2023-11-04 11:31:14 +01:00
public function run(): void
2015-02-06 04:41:00 +01:00
{
$currencies = [];
2017-11-18 21:03:28 +01:00
// european currencies
2019-08-17 10:47:51 +02:00
$currencies[] = ['code' => 'EUR', 'name' => 'Euro', 'symbol' => '€', 'decimal_places' => 2, 'enabled' => 1];
2018-01-15 17:13:23 +01:00
$currencies[] = ['code' => 'HUF', 'name' => 'Hungarian forint', 'symbol' => 'Ft', 'decimal_places' => 2];
$currencies[] = ['code' => 'GBP', 'name' => 'British Pound', 'symbol' => '£', 'decimal_places' => 2];
$currencies[] = ['code' => 'UAH', 'name' => 'Ukrainian hryvnia', 'symbol' => '₴', 'decimal_places' => 2];
$currencies[] = ['code' => 'PLN', 'name' => 'Polish złoty', 'symbol' => 'zł', 'decimal_places' => 2];
$currencies[] = ['code' => 'TRY', 'name' => 'Turkish lira', 'symbol' => '₺', 'decimal_places' => 2];
$currencies[] = ['code' => 'DKK', 'name' => 'Dansk krone', 'symbol' => 'kr.', 'decimal_places' => 2];
2017-11-18 21:03:28 +01:00
// american currencies
2018-01-15 17:13:23 +01:00
$currencies[] = ['code' => 'USD', 'name' => 'US Dollar', 'symbol' => '$', 'decimal_places' => 2];
$currencies[] = ['code' => 'BRL', 'name' => 'Brazilian real', 'symbol' => 'R$', 'decimal_places' => 2];
$currencies[] = ['code' => 'CAD', 'name' => 'Canadian dollar', 'symbol' => 'C$', 'decimal_places' => 2];
2022-01-07 07:23:10 +01:00
$currencies[] = ['code' => 'MXN', 'name' => 'Mexican peso', 'symbol' => 'MX$', 'decimal_places' => 2];
2017-11-18 21:03:28 +01:00
// oceanian currencies
2018-01-15 17:13:23 +01:00
$currencies[] = ['code' => 'IDR', 'name' => 'Indonesian rupiah', 'symbol' => 'Rp', 'decimal_places' => 2];
$currencies[] = ['code' => 'AUD', 'name' => 'Australian dollar', 'symbol' => 'A$', 'decimal_places' => 2];
$currencies[] = ['code' => 'NZD', 'name' => 'New Zealand dollar', 'symbol' => 'NZ$', 'decimal_places' => 2];
2017-11-18 21:03:28 +01:00
// african currencies
2018-01-15 17:13:23 +01:00
$currencies[] = ['code' => 'EGP', 'name' => 'Egyptian pound', 'symbol' => 'E£', 'decimal_places' => 2];
$currencies[] = ['code' => 'MAD', 'name' => 'Moroccan dirham', 'symbol' => 'DH', 'decimal_places' => 2];
$currencies[] = ['code' => 'ZAR', 'name' => 'South African rand', 'symbol' => 'R', 'decimal_places' => 2];
2017-11-18 21:03:28 +01:00
// asian currencies
$currencies[] = ['code' => 'JPY', 'name' => 'Japanese yen', 'symbol' => '¥', 'decimal_places' => 0];
$currencies[] = ['code' => 'CNY', 'name' => 'Chinese yuan', 'symbol' => '¥', 'decimal_places' => 2];
2020-10-06 21:24:48 +03:00
$currencies[] = ['code' => 'RUB', 'name' => 'Russian ruble', 'symbol' => '₽', 'decimal_places' => 2];
$currencies[] = ['code' => 'INR', 'name' => 'Indian rupee', 'symbol' => '₹', 'decimal_places' => 2];
2017-11-18 21:03:28 +01:00
// PLEASE ADD NEW CURRENCIES BELOW THIS LINE
$currencies[] = ['code' => 'ILS', 'name' => 'Israeli new shekel', 'symbol' => '₪', 'decimal_places' => 2];
2018-11-01 15:15:49 +01:00
$currencies[] = ['code' => 'CHF', 'name' => 'Swiss franc', 'symbol' => 'CHF', 'decimal_places' => 2];
$currencies[] = ['code' => 'HRK', 'name' => 'Croatian kuna', 'symbol' => 'kn', 'decimal_places' => 2];
2018-01-15 17:13:23 +01:00
foreach ($currencies as $currency) {
if (null === TransactionCurrency::where('code', $currency['code'])->first()) {
2024-05-26 15:36:30 +02:00
try {
TransactionCurrency::create($currency);
} catch (\PDOException $e) {
// @ignoreException
}
2018-01-15 17:13:23 +01:00
}
}
2015-02-06 04:41:00 +01:00
}
2017-11-15 10:53:17 +01:00
}