mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
Fix exchange rate parity across all document types
- Fix exchange-rate service types to match actual backend response shapes (exchangeRate array, activeProvider success/error, used currencies as strings) - Add ExchangeRateConverter to payments, expenses, and recurring invoices - Set currency_id from customer currency in invoice/estimate selectCustomer() - Load globalStore.currencies in ExchangeRateConverter on mount - Pass driver/key/driver_config params to getSupportedCurrencies in provider modal - Fix OpenExchangeRateDriver validateConnection to use base=USD (free plan compat) - Fix checkActiveCurrencies SQLite whereJsonContains with array values - Remove broken currency/companyCurrency props from ExpenseCreateView, use stores - Show base currency equivalent in document line items and totals when exchange rate is active
This commit is contained in:
@@ -25,17 +25,42 @@ class ExchangeRateProviderService
|
||||
|
||||
public function checkActiveCurrencies($request)
|
||||
{
|
||||
return ExchangeRateProvider::whereJsonContains('currencies', $request->currencies)
|
||||
->where('active', true)
|
||||
->get();
|
||||
$currencies = $request->currencies;
|
||||
|
||||
if (empty($currencies)) {
|
||||
return collect();
|
||||
}
|
||||
|
||||
$query = ExchangeRateProvider::where('active', true);
|
||||
|
||||
foreach ($currencies as $currency) {
|
||||
$query->orWhere(function ($q) use ($currency) {
|
||||
$q->where('active', true)
|
||||
->whereJsonContains('currencies', $currency);
|
||||
});
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function checkUpdateActiveCurrencies(ExchangeRateProvider $provider, $request)
|
||||
{
|
||||
return ExchangeRateProvider::where('active', $request->active)
|
||||
->where('id', '<>', $provider->id)
|
||||
->whereJsonContains('currencies', $request->currencies)
|
||||
->get();
|
||||
$currencies = $request->currencies;
|
||||
|
||||
if (empty($currencies)) {
|
||||
return collect();
|
||||
}
|
||||
|
||||
$query = ExchangeRateProvider::where('id', '<>', $provider->id)
|
||||
->where('active', true);
|
||||
|
||||
$query->where(function ($q) use ($currencies) {
|
||||
foreach ($currencies as $currency) {
|
||||
$q->orWhereJsonContains('currencies', $currency);
|
||||
}
|
||||
});
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
public function checkProviderStatus($request)
|
||||
|
||||
Reference in New Issue
Block a user