Skip to content

Commit

Permalink
Fixed document transaction create missing document totals issue solved..
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Feb 15, 2024
1 parent 2d825b2 commit ab2325d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 24 deletions.
8 changes: 4 additions & 4 deletions app/Http/Controllers/Modals/DocumentTransactions.php
Expand Up @@ -55,12 +55,12 @@ public function create(Document $document)
$document->{$document_total->code} = $document_total->amount;
}

$total = money($document->total, $currency->code)->format();
$total = money($document?->total ?? 0, $currency->code)->format();

$document->grand_total = money($total, $currency->code, false)->getAmount();

if (! empty($paid)) {
$document->grand_total = round($document->total - $paid, $currency->precision);
$document->grand_total = round($document?->total ?? 0 - $paid, $currency->precision);
}

$amount = $document->grand_total;
Expand Down Expand Up @@ -163,12 +163,12 @@ public function edit(Document $document, Transaction $transaction)
$document->{$document_total->code} = $document_total->amount;
}

$total = money($document->total, $currency->code)->format();
$total = money($document?->total ?? 0, $currency->code)->format();

$document->grand_total = money($total, $currency->code, false)->getAmount();

if (! empty($paid)) {
$document->grand_total = round($document->total - $paid, $currency->precision);
$document->grand_total = round($document?->total ?? 0 - $paid, $currency->precision);
}

$document->paid_at = $transaction->paid_at;
Expand Down
30 changes: 20 additions & 10 deletions resources/views/components/documents/show/get-paid.blade.php
Expand Up @@ -94,16 +94,26 @@ class="py-1.5 mb-3 sm:mb-0 text-xs bg-transparent hover:bg-transparent font-medi

<span class="mt-1 mr-2 ml-2"> - </span>

<x-button
@click="onEditPayment('{{ route('modals.documents.document.transactions.edit', ['document' => $document->id, 'transaction' => $transaction->id]) }}')"
id="show-slider-actions-transaction-edit-{{ $document->type }}-{{ $transaction->id }}"
class="text-purple mt-1"
override="class"
>
<x-button.hover color="to-purple">
{{ trans('general.title.edit', ['type' => trans_choice('general.payments', 1)]) }}
</x-button.hover>
</x-button>
@if ($document->totals->count())
<x-button
@click="onEditPayment('{{ route('modals.documents.document.transactions.edit', ['document' => $document->id, 'transaction' => $transaction->id]) }}')"
id="show-slider-actions-transaction-edit-{{ $document->type }}-{{ $transaction->id }}"
class="text-purple mt-1"
override="class"
>
<x-button.hover color="to-purple">
{{ trans('general.title.edit', ['type' => trans_choice('general.payments', 1)]) }}
</x-button.hover>
</x-button>
@else
<x-tooltip message="{{ trans('invoices.messages.totals_required', ['type' => $type]) }}" placement="top">
<x-button disabled="disabled" id="show-slider-actions-transaction-edit-{{ $document->type }}-{{ $transaction->id }}" class="text-purple mt-1" override="class">
<x-button.hover color="to-purple">
{{ trans('general.title.edit', ['type' => trans_choice('general.payments', 1)]) }}
</x-button.hover>
</x-button>
</x-tooltip>
@endif

<span class="mt-1 mr-2 ml-2"> - </span>

Expand Down
30 changes: 20 additions & 10 deletions resources/views/components/documents/show/make-payment.blade.php
Expand Up @@ -77,16 +77,26 @@ class="px-3 py-1.5 mb-3 sm:mb-0 rounded-lg text-xs font-medium leading-6 bg-gree

<span class="mt-1 mr-2 ml-2"> - </span>

<x-button
@click="onEditPayment('{{ route('modals.documents.document.transactions.edit', ['document' => $document->id, 'transaction' => $transaction->id]) }}')"
id="show-slider-actions-transaction-edit-{{ $document->type }}-{{ $transaction->id }}"
class="text-purple mt-1"
override="class"
>
<x-button.hover color="to-purple">
{{ trans('general.title.edit', ['type' => trans_choice('general.payments', 1)]) }}
</x-button.hover>
</x-button>
@if ($document->totals->count())
<x-button
@click="onEditPayment('{{ route('modals.documents.document.transactions.edit', ['document' => $document->id, 'transaction' => $transaction->id]) }}')"
id="show-slider-actions-transaction-edit-{{ $document->type }}-{{ $transaction->id }}"
class="text-purple mt-1"
override="class"
>
<x-button.hover color="to-purple">
{{ trans('general.title.edit', ['type' => trans_choice('general.payments', 1)]) }}
</x-button.hover>
</x-button>
@else
<x-tooltip message="{{ trans('invoices.messages.totals_required', ['type' => $type]) }}" placement="top">
<x-button disabled="disabled" id="show-slider-actions-transaction-edit-{{ $document->type }}-{{ $transaction->id }}" class="text-purple mt-1" override="class">
<x-button.hover color="to-purple">
{{ trans('general.title.edit', ['type' => trans_choice('general.payments', 1)]) }}
</x-button.hover>
</x-button>
</x-tooltip>
@endif

<span class="mt-1 mr-2 ml-2"> - </span>

Expand Down

0 comments on commit ab2325d

Please sign in to comment.