Feat: Adds multi currency support to API (#90)
This commit is contained in:
@@ -18,6 +18,7 @@ class TransactionController extends ApiController
|
||||
|
||||
$filters->setQuery(Transaction::query());
|
||||
$filters->setScopes(['myTransactions']);
|
||||
$filters->setEagerRelations(['market_data']);
|
||||
$filters->setSearchableColumns(['symbol']);
|
||||
|
||||
return TransactionResource::collection($filters->paginated());
|
||||
|
||||
@@ -42,6 +42,7 @@ class TransactionRequest extends FormRequest
|
||||
$this->requestOrModelValue('date', 'transaction')
|
||||
),
|
||||
],
|
||||
'currency' => ['required', 'exists:currencies,currency'],
|
||||
'cost_basis' => ['exclude_if:transaction_type,SELL', 'min:0', 'numeric'],
|
||||
'sale_price' => ['exclude_if:transaction_type,BUY', 'min:0', 'numeric'],
|
||||
];
|
||||
@@ -50,6 +51,7 @@ class TransactionRequest extends FormRequest
|
||||
$rules['portfolio_id'][0] = 'sometimes';
|
||||
$rules['symbol'][0] = 'sometimes';
|
||||
$rules['transaction_type'][0] = 'sometimes';
|
||||
$rules['currency'][0] = 'sometimes';
|
||||
$rules['date'][0] = 'sometimes';
|
||||
$rules['quantity'][0] = 'sometimes';
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ class HoldingResource extends JsonResource
|
||||
'portfolio_id' => $this->portfolio_id,
|
||||
'symbol' => $this->symbol,
|
||||
'quantity' => $this->quantity,
|
||||
'currency' => $this->market_data->currency,
|
||||
'reinvest_dividends' => $this->reinvest_dividends,
|
||||
'average_cost_basis' => $this->average_cost_basis,
|
||||
'total_cost_basis' => $this->total_cost_basis,
|
||||
|
||||
@@ -22,6 +22,7 @@ class TransactionResource extends JsonResource
|
||||
'portfolio_id' => $this->portfolio_id,
|
||||
'transaction_type' => $this->transaction_type,
|
||||
'quantity' => $this->quantity,
|
||||
'currency' => $this->market_data->currency,
|
||||
'cost_basis' => $this->cost_basis,
|
||||
'sale_price' => $this->sale_price,
|
||||
'split' => $this->split,
|
||||
|
||||
@@ -22,6 +22,10 @@ class UserResource extends JsonResource
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'profile_photo_url' => $this->profile_photo_url,
|
||||
'options' => [
|
||||
'display_currency' => $this->getCurrency(),
|
||||
'locale' => $this->getLocale(),
|
||||
],
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user