From 0745dfaa3d17b01760b6c91e7513fb966e717e45 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 19 Oct 2024 09:32:06 +1100 Subject: [PATCH] Add amount filters for expense --- app/Filters/ExpenseFilters.php | 9 +++ app/Transformers/ExpenseTransformer.php | 13 +++++ .../2024_10_18_211558_updated_currencies.php | 56 +++++++++++++++++++ database/seeders/CurrenciesSeeder.php | 19 +++++++ lang/en/texts.php | 20 ++++++- lang/fr_CA/texts.php | 3 +- lang/nl/texts.php | 7 ++- lang/vi/texts.php | 3 +- 8 files changed, 124 insertions(+), 6 deletions(-) create mode 100644 database/migrations/2024_10_18_211558_updated_currencies.php diff --git a/app/Filters/ExpenseFilters.php b/app/Filters/ExpenseFilters.php index fa7f71ff7f..d181cc9e91 100644 --- a/app/Filters/ExpenseFilters.php +++ b/app/Filters/ExpenseFilters.php @@ -177,6 +177,15 @@ class ExpenseFilters extends QueryFilters return $this->builder->whereIn('category_id', $categories_keys); } + public function amount(string $amount = ''): Builder + { + if (strlen($amount) == 0) { + return $this->builder; + } + + return $this->builder->where('amount', $amount); + } + public function number(string $number = ''): Builder { if (strlen($number) == 0) { diff --git a/app/Transformers/ExpenseTransformer.php b/app/Transformers/ExpenseTransformer.php index e8e130e2ec..8dae337f1d 100644 --- a/app/Transformers/ExpenseTransformer.php +++ b/app/Transformers/ExpenseTransformer.php @@ -16,6 +16,7 @@ use App\Models\Document; use App\Models\Expense; use App\Models\ExpenseCategory; use App\Models\Invoice; +use App\Models\Project; use App\Models\Vendor; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\SoftDeletes; @@ -41,6 +42,7 @@ class ExpenseTransformer extends EntityTransformer 'vendor', 'category', 'invoice', + 'project', ]; public function includeDocuments(Expense $expense) @@ -50,6 +52,17 @@ class ExpenseTransformer extends EntityTransformer return $this->includeCollection($expense->documents, $transformer, Document::class); } + public function includeProject(Expense $expense): ?Item + { + $transformer = new ProjectTransformer($this->serializer); + + if (!$expense->project) { + return null; + } + + return $this->includeItem($expense->project, $transformer, Project::class); + } + public function includeClient(Expense $expense): ?Item { $transformer = new ClientTransformer($this->serializer); diff --git a/database/migrations/2024_10_18_211558_updated_currencies.php b/database/migrations/2024_10_18_211558_updated_currencies.php new file mode 100644 index 0000000000..5c1c5b2aff --- /dev/null +++ b/database/migrations/2024_10_18_211558_updated_currencies.php @@ -0,0 +1,56 @@ + 124, 'name' => 'Bermudian Dollar', 'code' => 'BMD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 125, 'name' => 'Central African CFA Franc', 'code' => 'XAF', 'symbol' => 'Fr', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 126, 'name' => 'Congolese Franc', 'code' => 'CDF', 'symbol' => 'Fr', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 127, 'name' => 'Djiboutian Franc', 'code' => 'DJF', 'symbol' => 'Fr', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 128, 'name' => 'Eritrean Nakfa', 'code' => 'ERN', 'symbol' => 'Nfk', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 129, 'name' => 'Falkland Islands Pound', 'code' => 'FKP', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 130, 'name' => 'Guinean Franc', 'code' => 'GNF', 'symbol' => 'Fr', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => ''], + ['id' => 131, 'name' => 'Iraqi Dinar', 'code' => 'IQD', 'symbol' => 'ع.د', 'precision' => '3', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 132, 'name' => 'Lesotho Loti', 'code' => 'LSL', 'symbol' => 'L', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 133, 'name' => 'Mongolian Tugrik', 'code' => 'MNT', 'symbol' => '₮', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 134, 'name' => 'Seychellois Rupee', 'code' => 'SCR', 'symbol' => '₨', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 135, 'name' => 'Solomon Islands Dollar', 'code' => 'SBD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 136, 'name' => 'Somali Shilling', 'code' => 'SOS', 'symbol' => 'Sh', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 137, 'name' => 'South Sudanese Pound', 'code' => 'SSP', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 138, 'name' => 'Sudanese Pound', 'code' => 'SDG', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 139, 'name' => 'Tajikistani Somoni', 'code' => 'TJS', 'symbol' => 'ЅM', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 140, 'name' => 'Turkmenistani Manat', 'code' => 'TMT', 'symbol' => 'T', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 141, 'name' => 'Uzbekistani Som', 'code' => 'UZS', 'symbol' => 'so\'m', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ]; + + foreach ($currencies as $currency) { + $record = Currency::where('code', $currency['code'])->first(); + if (!$record) { + Currency::create($currency); + } + } + + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // + } +}; diff --git a/database/seeders/CurrenciesSeeder.php b/database/seeders/CurrenciesSeeder.php index 34000a4c18..0edf1d2fd5 100644 --- a/database/seeders/CurrenciesSeeder.php +++ b/database/seeders/CurrenciesSeeder.php @@ -146,6 +146,25 @@ class CurrenciesSeeder extends Seeder ['id' => 121, 'name' => "Lao kip", 'code' => 'LAK', 'symbol' => '₭', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['id' => 122, 'name' => "Bhutan Ngultrum", 'code' => 'BTN', 'symbol' => 'Nu', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['id' => 123, 'name' => "Mauritanian Ouguiya", 'code' => 'MRU', 'symbol' => 'UM', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 124, 'name' => 'Bermudian Dollar', 'code' => 'BMD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 125, 'name' => 'Central African CFA Franc', 'code' => 'XAF', 'symbol' => 'Fr', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 126, 'name' => 'Congolese Franc', 'code' => 'CDF', 'symbol' => 'Fr', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 127, 'name' => 'Djiboutian Franc', 'code' => 'DJF', 'symbol' => 'Fr', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 128, 'name' => 'Eritrean Nakfa', 'code' => 'ERN', 'symbol' => 'Nfk', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 129, 'name' => 'Falkland Islands Pound', 'code' => 'FKP', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 130, 'name' => 'Guinean Franc', 'code' => 'GNF', 'symbol' => 'Fr', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => ''], + ['id' => 131, 'name' => 'Iraqi Dinar', 'code' => 'IQD', 'symbol' => 'ع.د', 'precision' => '3', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 132, 'name' => 'Lesotho Loti', 'code' => 'LSL', 'symbol' => 'L', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 133, 'name' => 'Mongolian Tugrik', 'code' => 'MNT', 'symbol' => '₮', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 134, 'name' => 'Seychellois Rupee', 'code' => 'SCR', 'symbol' => '₨', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 135, 'name' => 'Solomon Islands Dollar', 'code' => 'SBD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 136, 'name' => 'Somali Shilling', 'code' => 'SOS', 'symbol' => 'Sh', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 137, 'name' => 'South Sudanese Pound', 'code' => 'SSP', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 138, 'name' => 'Sudanese Pound', 'code' => 'SDG', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 139, 'name' => 'Tajikistani Somoni', 'code' => 'TJS', 'symbol' => 'ЅM', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 140, 'name' => 'Turkmenistani Manat', 'code' => 'TMT', 'symbol' => 'T', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 141, 'name' => 'Uzbekistani Som', 'code' => 'UZS', 'symbol' => 'so\'m', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ]; foreach ($currencies as $currency) { diff --git a/lang/en/texts.php b/lang/en/texts.php index c0c9d26e70..c2bda30257 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -5364,7 +5364,25 @@ $lang = array( 'merged_vendors' => 'Successfully merged vendors', 'hidden_taxes_warning' => 'Somes taxes are hidden due to current tax settings. :link', 'tax3' => 'Third Tax', - 'negative_payment_warning' => 'Are you sure you want to create a negative payment? This cannot be used as a credit or payment.' + 'negative_payment_warning' => 'Are you sure you want to create a negative payment? This cannot be used as a credit or payment.', + 'currency_Bermudian_Dollar' => 'Bermudian Dollar', + 'currency_Central_African_CFA_Franc' => 'Central African CFA Franc', + 'currency_Congolese_Franc' => 'Congolese Franc', + 'currency_Djiboutian_Franc' => 'Djiboutian Franc', + 'currency_Eritrean_Nakfa' => 'Eritrean Nakfa', + 'currency_Falkland_Islands_Pound' => 'Falklan IslandsPound', + 'currency_Guinean_Franc' => 'Guinean Franc', + 'currency_Iraqi_Dinar' => 'Iraqi Dinar', + 'currency_Lesotho_Loti' => 'Lesotho Loti', + 'currency_Mongolian_Tugrik' => 'Mongolian Tugrik', + 'currency_Seychellois_Rupee' => 'Seychellois Rupee', + 'currency_Solomon_Islands_Dollar' => 'Solomon Islands Dollar', + 'currency_Somali_Shilling' => 'Somali Shilling', + 'currency_South_Sudanese_Pound' => 'South Sudanese Pound', + 'currency_Sudanese_Pound' => 'Sudanese Pound', + 'currency_Tajikistani_Somoni' => 'Tajikistani Somoni', + 'currency_Turkmenistani_Manat' => 'Turkmenistani Manat', + 'currency_Uzbekistani_Som' => 'Uzbekistani Som', ); return $lang; diff --git a/lang/fr_CA/texts.php b/lang/fr_CA/texts.php index 0729cb34b3..945247dc70 100644 --- a/lang/fr_CA/texts.php +++ b/lang/fr_CA/texts.php @@ -5357,7 +5357,8 @@ Développe automatiquement la section des notes dans le tableau de produits pour 'updated_records' => 'Enregistrements mis à jour', 'vat_not_registered' => 'Vendeur non enregistré aux taxes', 'small_company_info' => 'Aucune déclaration de taxe de vente conformément à l\'article 19 UStG', - 'log_duration_words' => 'Durée du journal en mots' + 'log_duration_words' => 'Durée du journal de temps exprimée en mots', + 'log_duration' => 'Durée du journal de temps' ); return $lang; diff --git a/lang/nl/texts.php b/lang/nl/texts.php index d6ed5a8a4a..5f490ab68a 100644 --- a/lang/nl/texts.php +++ b/lang/nl/texts.php @@ -5357,9 +5357,10 @@ E-mail: :email
', 'quick_actions' => 'Snelle acties', 'end_all_sessions_help' => 'Logt alle gebruikers uit en vereist dat alle actieve gebruikers opnieuw inloggen.', 'updated_records' => 'Items bijgewerkt', - 'vat_not_registered' => 'Seller not VAT registered', - 'small_company_info' => 'No disclosure of sales tax in accordance with § 19 UStG', - 'log_duration_words' => 'Log duration in words' + 'vat_not_registered' => 'Verkoper is niet btw-plichtig', + 'small_company_info' => 'Geen openbaarmaking van omzetbelasting in overeenstemming met § 19 UStG', + 'log_duration_words' => 'Maximale lengte logboek in woorden', + 'log_duration' => 'Maximale lengte logboek' ); return $lang; diff --git a/lang/vi/texts.php b/lang/vi/texts.php index 88220cd7be..e82274fa8f 100644 --- a/lang/vi/texts.php +++ b/lang/vi/texts.php @@ -5359,7 +5359,8 @@ $lang = array( 'updated_records' => 'Hồ sơ đã cập nhật', 'vat_not_registered' => 'Người bán không đăng ký VAT', 'small_company_info' => 'Không tiết lộ thuế bán hàng theo § 19 UStG', - 'log_duration_words' => 'Thời lượng ghi nhật ký bằng từ' + 'log_duration_words' => 'Thời gian ghi nhật ký bằng từ', + 'log_duration' => 'Thời gian ghi nhật ký' ); return $lang;