Skip to content

Commit

Permalink
fix: partial offer calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
sWalbrun committed Feb 3, 2024
1 parent f833bf2 commit edc2c90
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
12 changes: 7 additions & 5 deletions app/Filament/Pages/OfferPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,15 @@ protected function getFormSchema(): array
$buildOffer = function (?Offer $offer, int $numberOfRound) use ($topic) {
$shareValue = $this->putShareCount($topic);
$amount = $offer?->amount;
if (isset($shareValue) && isset($amount)) {
$this->putTotalAmount($topic->id, $numberOfRound, $offer->amount * $shareValue->calculable());
$this->putPartialAmount($topic->id, $numberOfRound, $offer->amount);
if (isset($shareValue)) {
$this->putTotalAmount($topic->id, $numberOfRound, $amount ? $amount * $shareValue->calculable() : null);
if (isset($amount)) {
$this->putPartialAmount($topic->id, $numberOfRound, $amount);
}
}

return [TextInput::make("roundToTotalAmountMapping.$topic->id.$numberOfRound")
->label(trans('Total offer :numberOfRound', ['numberOfRound' => $numberOfRound]))
->label(trans('Total :numberOfRound offer', ['numberOfRound' => $numberOfRound]))
->numeric()
->reactive()
->afterStateUpdated(
Expand Down Expand Up @@ -210,7 +212,7 @@ protected function getFormSchema(): array
->suffix('€')
->required(),
TextInput::make("roundToPartialAmountMapping.$topic->id.$numberOfRound")
->label(trans('Partial offer :numberOfRound', ['numberOfRound' => $numberOfRound]))
->label(trans('Partial :numberOfRound offer', ['numberOfRound' => $numberOfRound]))
->disabled()
->suffix('€')];
};
Expand Down
3 changes: 1 addition & 2 deletions app/Jobs/SetTenantCookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace App\Jobs;

use App\Models\User;
use function cookie;
use Illuminate\Auth\Events\Authenticated;
use Illuminate\Support\Facades\Cookie;

use function cookie;

/**
* This middleware is setting the tenant id as a cookie. The current logic is allowing you only to be part of one
* and only one tenancy determined by the {@link User::email user's email address}.
Expand Down
4 changes: 2 additions & 2 deletions resources/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,8 @@
"User template": "Benutzervorlage herunter laden",
"Remind participants": "Teilnehmer erinnern",
"Currently no open round": "Derzeit gibt es keine offene Beitragsrunde",
"Total offer :numberOfRound": "Gebot Gesamt :numberOfRound",
"Partial offer :numberOfRound": "Gebot pro Anteil :numberOfRound",
"Total :numberOfRound offer": "Gebot :numberOfRound Gesamt",
"Partial :numberOfRound offer": "Gebot :numberOfRound pro Anteil",
"Offers": "Gebote",
"Payment interval": "Zahlungsintervall",
"Your offers": "Deine Gebote",
Expand Down
3 changes: 1 addition & 2 deletions tests/Feature/Filament/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
use App\Models\User;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Hash;
use SWalbrun\FilamentModelImport\Filament\Pages\ImportPage;

use function Pest\Livewire\livewire;
use SWalbrun\FilamentModelImport\Filament\Pages\ImportPage;

it('can create an user and roles by import', function () {
$fileToImport = getDefaultXlsx('UserImport.xlsx');
Expand Down
1 change: 0 additions & 1 deletion tests/Feature/Filament/OfferPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use App\Models\Topic;
use App\Models\User;
use Carbon\Carbon;

use function Pest\Livewire\livewire;

it('saves the given offers', function () {
Expand Down
3 changes: 1 addition & 2 deletions tests/Feature/Filament/UserResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
use App\Filament\Resources\UserResource\Pages\ListUsers;
use App\Models\User;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Spatie\Permission\Models\Permission;

use function Pest\Livewire\livewire;
use Spatie\Permission\Models\Permission;

it('shows all existing users', function () {

Expand Down

0 comments on commit edc2c90

Please sign in to comment.