Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/brkcvn/akaunting into cod…
Browse files Browse the repository at this point in the history
…e-clean
  • Loading branch information
brkcvn committed Sep 5, 2022
2 parents d238817 + 6f69914 commit ccc566c
Show file tree
Hide file tree
Showing 40 changed files with 377 additions and 441 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Modals/DocumentTransactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function update(Document $document, Transaction $transaction, Request $re

$response['redirect'] = route($route . '.show', $document->id);

$message = trans('messages.success.added', ['type' => trans_choice('general.payments', 1)]);
$message = trans('messages.success.updated', ['type' => trans_choice('general.payments', 1)]);

flash($message)->success();
} else {
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Requests/Document/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public function rules()

if ($items) {
foreach ($items as $key => $item) {
$size = 5;
$size = 10;

if (Str::contains($item['quantity'], ['.', ','])) {
$size = 7;
$size = 12;
}

$rules['items.' . $key . '.quantity'] = 'required|max:' . $size;
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Requests/Document/DocumentItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class DocumentItem extends FormRequest
{
protected $quantity_size = 5;
protected $quantity_size = 10;

/**
* Get the validation rules that apply to the request.
Expand All @@ -17,7 +17,7 @@ class DocumentItem extends FormRequest
public function rules()
{
if (Str::contains($this->request->get('quantity'), ['.', ','])) {
$this->quantity_size = 7;
$this->quantity_size = 12;
}

return [
Expand Down
7 changes: 4 additions & 3 deletions app/Jobs/Banking/UpdateBankingDocumentTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ public function handle(): Transaction

protected function prepareRequest(): void
{
if (!isset($this->request['amount'])) {
if (! isset($this->request['amount'])) {
$this->model->paid_amount = $this->model->paid;
event(new PaidAmountCalculated($this->model));

$this->request['amount'] = $this->model->amount - $this->model->paid_amount;
}

$currency_code = !empty($this->request['currency_code']) ? $this->request['currency_code'] : $this->model->currency_code;
$currency_code = ! empty($this->request['currency_code']) ? $this->request['currency_code'] : $this->model->currency_code;

$this->request['company_id'] = $this->model->company_id;
$this->request['currency_code'] = isset($this->request['currency_code']) ? $this->request['currency_code'] : $this->model->currency_code;
Expand Down Expand Up @@ -92,7 +92,8 @@ protected function checkAmount(): bool
$amount = round($converted_amount, $precision);
}

$this->model->paid_amount = $this->model->paid;
// if you edit transaction before remove transaction amount
$this->model->paid_amount = ($this->model->paid - $this->transaction->amount);
event(new PaidAmountCalculated($this->model));

$total_amount = round($this->model->amount - $this->model->paid_amount, $precision);
Expand Down
13 changes: 10 additions & 3 deletions app/Widgets/CashFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,17 @@ public function show()
->setDataset(trans('general.outgoing'), 'column', $expense)
->setDataset(trans_choice('general.profits', 1), 'line', $profit);

$incoming_amount = money(array_sum($income), setting('default.currency'), true);
$outgoing_amount = money(abs(array_sum($expense)), setting('default.currency'), true);
$profit_amount = money(array_sum($profit), setting('default.currency'), true);

$totals = [
'incoming' => money(array_sum($income), setting('default.currency'), true),
'outgoing' => money(abs(array_sum($expense)), setting('default.currency'), true),
'profit' => money(array_sum($profit), setting('default.currency'), true),
'incoming_exact' => $incoming_amount->format(),
'incoming_for_humans' => $incoming_amount->formatForHumans(),
'outgoing_exact' => $outgoing_amount->format(),
'outgoing_for_humans' => $outgoing_amount->formatForHumans(),
'profit_exact' => $profit_amount->format(),
'profit_for_humans' => $profit_amount->formatForHumans(),
];

return $this->view('widgets.cash_flow', [
Expand Down
Loading

0 comments on commit ccc566c

Please sign in to comment.