applied new features of money package
This commit is contained in:
@@ -42,9 +42,9 @@ class Accounts extends Controller
|
||||
->orWhereHas('income_transaction', fn ($query) => $query->where('account_id', $account->id))
|
||||
->collect(['expense_transaction.paid_at' => 'desc']);
|
||||
|
||||
$incoming_amount = money($account->income_balance, $account->currency_code, true);
|
||||
$outgoing_amount = money($account->expense_balance, $account->currency_code, true);
|
||||
$current_amount = money($account->balance, $account->currency_code, true);
|
||||
$incoming_amount = money($account->income_balance, $account->currency_code);
|
||||
$outgoing_amount = money($account->expense_balance, $account->currency_code);
|
||||
$current_amount = money($account->balance, $account->currency_code);
|
||||
|
||||
$summary_amounts = [
|
||||
'incoming_exact' => $incoming_amount->format(),
|
||||
|
||||
@@ -24,8 +24,8 @@ class Reconciliations extends Controller
|
||||
{
|
||||
$reconciliations = Reconciliation::with('account')->collect();
|
||||
|
||||
$reconciled_amount = money($reconciliations->where('reconciled', 1)->sum('closing_balance'), default_currency(), true);
|
||||
$in_progress_amount = money($reconciliations->where('reconciled', 0)->sum('closing_balance'), default_currency(), true);
|
||||
$reconciled_amount = money($reconciliations->where('reconciled', 1)->sum('closing_balance'));
|
||||
$in_progress_amount = money($reconciliations->where('reconciled', 0)->sum('closing_balance'));
|
||||
|
||||
$summary_amounts = [
|
||||
'amount_exact' => $reconciled_amount->format(),
|
||||
@@ -246,9 +246,9 @@ class Reconciliations extends Controller
|
||||
|
||||
$difference = $closing_balance - $cleared_amount;
|
||||
|
||||
$json->closing_balance = money($closing_balance, $currency_code, true)->format();
|
||||
$json->cleared_amount = money($cleared_amount, $currency_code, true)->format();
|
||||
$json->difference = money($difference, $currency_code, true)->format();
|
||||
$json->closing_balance = money($closing_balance, $currency_code)->format();
|
||||
$json->cleared_amount = money($cleared_amount, $currency_code)->format();
|
||||
$json->difference = money($difference, $currency_code)->format();
|
||||
$json->difference_raw = (int) $difference;
|
||||
|
||||
return response()->json($json);
|
||||
|
||||
@@ -56,9 +56,9 @@ class Transactions extends Controller
|
||||
|
||||
$totals['profit'] = $totals['income'] - $totals['expense'];
|
||||
|
||||
$incoming_amount = money($totals['income'], default_currency(), true);
|
||||
$expense_amount = money($totals['expense'], default_currency(), true);
|
||||
$profit_amount = money($totals['profit'], default_currency(), true);
|
||||
$incoming_amount = money($totals['income']);
|
||||
$expense_amount = money($totals['expense']);
|
||||
$profit_amount = money($totals['profit']);
|
||||
|
||||
$summary_amounts = [
|
||||
'incoming_exact' => $incoming_amount->format(),
|
||||
|
||||
@@ -51,9 +51,9 @@ class DocumentTransactions extends Controller
|
||||
$document->{$document_total->code} = $document_total->amount;
|
||||
}
|
||||
|
||||
$total = money($document->total, $currency->code, true)->format();
|
||||
$total = money($document->total, $currency->code)->format();
|
||||
|
||||
$document->grand_total = money($total, $currency->code)->getAmount();
|
||||
$document->grand_total = money($total, $currency->code, false)->getAmount();
|
||||
|
||||
if (! empty($paid)) {
|
||||
$document->grand_total = round($document->total - $paid, $currency->precision);
|
||||
@@ -140,7 +140,7 @@ class DocumentTransactions extends Controller
|
||||
|
||||
$number = $transaction->number;
|
||||
|
||||
$document->grand_total = money($transaction->amount, $currency->code)->getAmount();
|
||||
$document->grand_total = money($transaction->amount, $currency->code, false)->getAmount();
|
||||
|
||||
$document->paid_at = $transaction->paid_at;
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ class Money
|
||||
$money_format = Str::replaceFirst('.', config('money.currencies.' . $currency_code . '.decimal_mark'), $money_format);
|
||||
}
|
||||
|
||||
$amount = money($money_format, $currency_code)->getAmount();
|
||||
$amount = money($money_format, $currency_code, false)->getAmount();
|
||||
} catch (InvalidArgumentException | OutOfBoundsException | UnexpectedValueException $e) {
|
||||
report($e);
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ class Account extends JsonResource
|
||||
'number' => $this->number,
|
||||
'currency_code' => $this->currency_code,
|
||||
'opening_balance' => $this->opening_balance,
|
||||
'opening_balance_formatted' => money($this->opening_balance, $this->currency_code, true)->format(),
|
||||
'opening_balance_formatted' => money($this->opening_balance, $this->currency_code)->format(),
|
||||
'current_balance' => $this->balance,
|
||||
'current_balance_formatted' => money($this->balance, $this->currency_code, true)->format(),
|
||||
'current_balance_formatted' => money($this->balance, $this->currency_code)->format(),
|
||||
'bank_name' => $this->bank_name,
|
||||
'bank_phone' => $this->bank_phone,
|
||||
'bank_address' => $this->bank_address,
|
||||
|
||||
@@ -22,7 +22,7 @@ class Reconciliation extends JsonResource
|
||||
'started_at' => $this->started_at->toIso8601String(),
|
||||
'ended_at' => $this->ended_at->toIso8601String(),
|
||||
'closing_balance' => $this->closing_balance,
|
||||
'closing_balance_formatted' => money($this->closing_balance, default_currency(), true)->format(),
|
||||
'closing_balance_formatted' => money($this->closing_balance)->format(),
|
||||
'reconciled' => $this->reconciled,
|
||||
'created_from' => $this->created_from,
|
||||
'created_by' => $this->created_by,
|
||||
|
||||
@@ -25,7 +25,7 @@ class Transaction extends JsonResource
|
||||
'account_id' => $this->account_id,
|
||||
'paid_at' => $this->paid_at->toIso8601String(),
|
||||
'amount' => $this->amount,
|
||||
'amount_formatted' => money($this->amount, $this->currency_code, true)->format(),
|
||||
'amount_formatted' => money($this->amount, $this->currency_code)->format(),
|
||||
'currency_code' => $this->currency_code,
|
||||
'currency_rate' => $this->currency_rate,
|
||||
'document_id' => $this->document_id,
|
||||
|
||||
@@ -25,7 +25,7 @@ class Transfer extends JsonResource
|
||||
'to_account' => $income_transaction->account->name,
|
||||
'to_account_id' => $income_transaction->account->id,
|
||||
'amount' => $expense_transaction->amount,
|
||||
'amount_formatted' => money($expense_transaction->amount, $expense_transaction->currency_code, true)->format(),
|
||||
'amount_formatted' => money($expense_transaction->amount, $expense_transaction->currency_code)->format(),
|
||||
'currency_code' => $expense_transaction->currency_code,
|
||||
'paid_at' => $expense_transaction->paid_at ? $expense_transaction->paid_at->toIso8601String() : '',
|
||||
'created_from' => $this->created_from,
|
||||
|
||||
@@ -23,9 +23,9 @@ class Item extends JsonResource
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'sale_price' => $this->sale_price,
|
||||
'sale_price_formatted' => money((double) $this->sale_price, default_currency(), true)->format(),
|
||||
'sale_price_formatted' => money((double) $this->sale_price)->format(),
|
||||
'purchase_price' => $this->purchase_price,
|
||||
'purchase_price_formatted' => money((double) $this->purchase_price, default_currency(), true)->format(),
|
||||
'purchase_price_formatted' => money((double) $this->purchase_price)->format(),
|
||||
'category_id' => $this->category_id,
|
||||
'picture' => $this->picture,
|
||||
'enabled' => $this->enabled,
|
||||
|
||||
@@ -32,7 +32,7 @@ class Document extends JsonResource
|
||||
'issued_at' => $this->issued_at ? $this->issued_at->toIso8601String() : '',
|
||||
'due_at' => $this->due_at ? $this->due_at->toIso8601String() : '',
|
||||
'amount' => $this->amount,
|
||||
'amount_formatted' => money($this->amount, $this->currency_code, true)->format(),
|
||||
'amount_formatted' => money($this->amount, $this->currency_code)->format(),
|
||||
'category_id' => $this->category_id,
|
||||
'currency_code' => $this->currency_code,
|
||||
'currency_rate' => $this->currency_rate,
|
||||
|
||||
@@ -24,9 +24,9 @@ class DocumentItem extends JsonResource
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'price' => $this->price,
|
||||
'price_formatted' => money($this->price, $this->document->currency_code, true)->format(),
|
||||
'price_formatted' => money($this->price, $this->document->currency_code)->format(),
|
||||
'total' => $this->total,
|
||||
'total_formatted' => money($this->total, $this->document->currency_code, true)->format(),
|
||||
'total_formatted' => money($this->total, $this->document->currency_code)->format(),
|
||||
'created_from' => $this->created_from,
|
||||
'created_by' => $this->created_by,
|
||||
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
|
||||
|
||||
@@ -24,7 +24,7 @@ class DocumentItemTax extends JsonResource
|
||||
'tax_id' => $this->tax_id,
|
||||
'name' => $this->name,
|
||||
'amount' => $this->amount,
|
||||
'amount_formatted' => money($this->amount, $this->document->currency_code, true)->format(),
|
||||
'amount_formatted' => money($this->amount, $this->document->currency_code)->format(),
|
||||
'created_from' => $this->created_from,
|
||||
'created_by' => $this->created_by,
|
||||
'created_at' => $this->created_at ? $this->created_at->toIso8601String() : '',
|
||||
|
||||
@@ -22,7 +22,7 @@ class DocumentTotal extends JsonResource
|
||||
'code' => $this->code,
|
||||
'name' => $this->name,
|
||||
'amount' => $this->amount,
|
||||
'amount_formatted' => money($this->amount, $this->document->currency_code, true)->format(),
|
||||
'amount_formatted' => money($this->amount, $this->document->currency_code)->format(),
|
||||
'sort_order' => $this->sort_order,
|
||||
'created_from' => $this->created_from,
|
||||
'created_by' => $this->created_by,
|
||||
|
||||
Reference in New Issue
Block a user