refactor
parent
1263a625b8
commit
1d1633ab81
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
/**
|
||||
* @method static static BuyContractUnsigned()
|
||||
* @method static static BuyContractSigned()
|
||||
* @method static static SellContractUnSigned()
|
||||
* @method static static SellContractSigned()
|
||||
* @method static static Other()
|
||||
*/
|
||||
final class ContractType extends Enum
|
||||
{
|
||||
const BuyContract = 0;
|
||||
const SellContract = 1;
|
||||
}
|
||||
|
|
@ -13,9 +13,7 @@ use BenSampo\Enum\Enum;
|
|||
*/
|
||||
final class DocumentType extends Enum
|
||||
{
|
||||
const BuyContractUnsigned = 0;
|
||||
const BuyContractSigned = 1;
|
||||
const SellContractUnSigned = 2;
|
||||
const SellContractSigned = 3;
|
||||
const Other = 4;
|
||||
const ContractUnsigned = 0;
|
||||
const ContractSigned = 1;
|
||||
const Other = 3;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,10 @@ use BenSampo\Enum\Enum;
|
|||
*/
|
||||
final class InsuranceType extends Enum
|
||||
{
|
||||
const QBase = 0;
|
||||
const OneStar = 1;
|
||||
const ThreeStar = 2;
|
||||
const FiveStar = 3;
|
||||
const FiveStarPlus = 4;
|
||||
const None = 0;
|
||||
const QBase = 1;
|
||||
const OneStar = 2;
|
||||
const ThreeStar = 3;
|
||||
const FiveStar = 4;
|
||||
const FiveStarPlus = 5;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BuyContractController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||
use App\Models\Car;
|
||||
use Inertia\Inertia;
|
||||
use App\Models\Brand;
|
||||
use App\Models\Contract;
|
||||
use App\Enums\InsuranceType;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
|
@ -19,12 +20,12 @@ class CarController extends Controller
|
|||
|
||||
public function unsold(Request $request)
|
||||
{
|
||||
return $this->renderCarsList($request, Car::unsoldCars(), 'Cars/Unsold');
|
||||
return $this->renderCarsList($request, Car::unsoldOnly(), 'Cars/Unsold');
|
||||
}
|
||||
|
||||
public function sold(Request $request)
|
||||
{
|
||||
return $this->renderCarsList($request, Car::soldCars(), 'Cars/Sold');
|
||||
return $this->renderCarsList($request, Car::soldOnly(), 'Cars/Sold');
|
||||
}
|
||||
|
||||
private function renderCarsList(Request $request, $cars, string $renderPage) {
|
||||
|
|
@ -45,10 +46,8 @@ class CarController extends Controller
|
|||
'id' => $car->id,
|
||||
'stammnummer' => $car->stammnummer,
|
||||
'vin' => $car->vin,
|
||||
'buy_price' => $car->latestSellerContract() ? $car->latestSellerContract()->price : '',
|
||||
// 'buy_price' => $car->buy_price->format(),
|
||||
// 'seller' => $car->seller->only('name'),
|
||||
// 'buyer' => $car->buyer->only('name'),
|
||||
'buy_contract' => $this->getContractFields($car->latestBuyContract),
|
||||
'sell_contract' => $this->getContractFields($car->latestSellContract),
|
||||
'car_model' => $car->carModel->only('name'),
|
||||
'name' => $car->name,
|
||||
'initial_date' => $car->initial_date,
|
||||
|
|
@ -58,6 +57,35 @@ class CarController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
private function getContractFields(?Contract $contract) {
|
||||
if (!$contract) {
|
||||
return null;
|
||||
}
|
||||
$contact = $contract->contact;
|
||||
return [
|
||||
'id' => $contract->id,
|
||||
'date' => $contract->date,
|
||||
'price' => $contract->price,
|
||||
'type' => $contract->type,
|
||||
'insurance_type' => InsuranceType::fromValue((int)$contract->insurance_type)->key,
|
||||
'contact' => [
|
||||
'id' => $contact->id,
|
||||
'name' => $contact->name,
|
||||
'firstname' => $contact->firstname,
|
||||
'lastname' => $contact->lastname,
|
||||
'phone' => $contact->phone,
|
||||
'address' => $contact->address,
|
||||
'zip' => $contact->zip,
|
||||
'city' => $contact->city,
|
||||
'country' => $contact->country,
|
||||
'company' => $contact->company,
|
||||
'email' => $contact->email,
|
||||
'link' => route('contacts.edit', $contact),
|
||||
],
|
||||
'link' => route('contracts.show', $contract),
|
||||
];
|
||||
}
|
||||
|
||||
private function getWithCustomSort($cars, string $sortBy, string $direction)
|
||||
{
|
||||
switch($sortBy) {
|
||||
|
|
@ -80,17 +108,6 @@ class CarController extends Controller
|
|||
return 'name';
|
||||
}
|
||||
|
||||
private function getDirection(Request $request)
|
||||
{
|
||||
if ($request->has('direction')) {
|
||||
if (in_array($request->get('direction'), ['asc', 'desc'])) {
|
||||
return $request->get('direction');
|
||||
}
|
||||
}
|
||||
|
||||
return 'asc';
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
|
|
@ -165,30 +182,13 @@ class CarController extends Controller
|
|||
'notes' => $car->notes,
|
||||
'deleted_at' => $car->deleted_at,
|
||||
'buy_contracts' => $car->buyContracts()
|
||||
->with('contact')
|
||||
->orderBy('date', 'desc')
|
||||
->paginate(10)
|
||||
->through(fn ($contract) => [
|
||||
'id' => $contract->id,
|
||||
'date' => $contract->date,
|
||||
'price' => $contract->price,
|
||||
'contact' => $contract->contact,
|
||||
'type' => 'Ankaufsvertrag',
|
||||
'link' => route('contacts.edit', $contract->contact->id),
|
||||
]),
|
||||
->paginate(50)
|
||||
->through(fn ($contract) => $this->getContractFields($contract)),
|
||||
'sell_contracts' => $car->sellContracts()
|
||||
->with('contact')
|
||||
->orderBy('date', 'desc')
|
||||
->paginate(10)
|
||||
->through(fn ($contract) => [
|
||||
'id' => $contract->id,
|
||||
'date' => $contract->date,
|
||||
'price' => $contract->price,
|
||||
'contact' => $contract->contact,
|
||||
'type' => 'Verkaufsvertrag',
|
||||
'link' => route('contacts.edit', $contract->contact->id),
|
||||
'insurance_type' => InsuranceType::fromValue((int)$contract->insurance_type)->key,
|
||||
]),
|
||||
->paginate(50)
|
||||
->through(fn ($contract) => $this->getContractFields($contract)),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,17 +85,6 @@ class ContactController extends Controller
|
|||
return 'name';
|
||||
}
|
||||
|
||||
private function getDirection(Request $request)
|
||||
{
|
||||
if ($request->has('direction')) {
|
||||
if (in_array($request->get('direction'), ['asc', 'desc'])) {
|
||||
return $request->get('direction');
|
||||
}
|
||||
}
|
||||
|
||||
return 'asc';
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Inertia\Inertia;
|
||||
use App\Models\Contract;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ContractController extends Controller
|
||||
|
|
@ -14,7 +16,6 @@ class ContractController extends Controller
|
|||
public function index(Request $request)
|
||||
{
|
||||
return [];
|
||||
// return $this->renderContactsList($request, Contact::query(), 'Contacts/Index');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -36,4 +37,14 @@ class ContractController extends Controller
|
|||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function show(Contract $contract)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function print(Contract $contract)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,24 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
|
||||
protected function getDirection(Request $request)
|
||||
{
|
||||
if ($request->has('direction')) {
|
||||
if (in_array($request->get('direction'), ['asc', 'desc'])) {
|
||||
return $request->get('direction');
|
||||
}
|
||||
}
|
||||
|
||||
return 'asc';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Cknow\Money\Money;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class BuyContract extends Model
|
||||
{
|
||||
use HasFactory, softDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'date',
|
||||
'price',
|
||||
'contact_id',
|
||||
'car_id',
|
||||
];
|
||||
|
||||
public function getDateAttribute($date)
|
||||
{
|
||||
return Carbon::parse($date)->format('d.m.Y');
|
||||
}
|
||||
|
||||
public function getPriceAttribute($price)
|
||||
{
|
||||
return Money::CHF($price)->format();
|
||||
}
|
||||
|
||||
public function contact()
|
||||
{
|
||||
return $this->belongsTo(Contact::class);
|
||||
}
|
||||
|
||||
public function car()
|
||||
{
|
||||
return $this->belongsTo(Car::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ContractType;
|
||||
use Carbon\Carbon;
|
||||
use Cknow\Money\Money;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
|
@ -56,49 +57,34 @@ class Car extends Model
|
|||
return $this->belongsTo(CarModel::class);
|
||||
}
|
||||
|
||||
public function latestSellerContract()
|
||||
public function getLatestBuyContractAttribute()
|
||||
{
|
||||
return $this->buyContracts()->latest('date')->first();
|
||||
}
|
||||
|
||||
public function latestBuyerContracts()
|
||||
public function getLatestSellContractAttribute()
|
||||
{
|
||||
return $this->sellContracts()->latest('date')->first();
|
||||
}
|
||||
|
||||
public function isUnsold()
|
||||
{
|
||||
return $this->sellers()->count() > $this->buyers()->count();
|
||||
return $this->buyContracts()->count() > $this->sellContracts()->count();
|
||||
}
|
||||
|
||||
public function isSold()
|
||||
{
|
||||
return $this->sellers()->count() == $this->buyers()->count();
|
||||
return $this->buyContracts()->count() == $this->sellContracts()->count();
|
||||
}
|
||||
|
||||
public function sellers()
|
||||
public function documents()
|
||||
{
|
||||
return $this->hasManyThrough(BuyContract::class, Contact::class);
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
|
||||
public function buyers()
|
||||
public function contracts()
|
||||
{
|
||||
return $this->hasManyThrough(SellContract::class, Contact::class);
|
||||
}
|
||||
|
||||
public function buyContracts()
|
||||
{
|
||||
return $this->hasMany(BuyContract::class);
|
||||
}
|
||||
|
||||
public function sellContracts()
|
||||
{
|
||||
return $this->hasMany(SellContract::class);
|
||||
}
|
||||
|
||||
public function carPayment()
|
||||
{
|
||||
return $this->hasManyThrough(CarPayment::class, SellContract::class);
|
||||
return $this->hasMany(Contract::class);
|
||||
}
|
||||
|
||||
// public function scopeSoldThisYear($query)
|
||||
|
|
@ -111,14 +97,36 @@ class Car extends Model
|
|||
$query->orderBy('initial_date');
|
||||
}
|
||||
|
||||
public function scopeSoldCars($query)
|
||||
public function buyContracts()
|
||||
{
|
||||
$query->withCount(['buyContracts', 'sellContracts'])->having('buy_contracts_count', '=', 'sell_contracts_count');
|
||||
return $this->hasMany(Contract::class)->buyContracts();
|
||||
}
|
||||
|
||||
public function scopeUnsoldCars($query)
|
||||
public function sellContracts()
|
||||
{
|
||||
$query->withCount(['buyContracts', 'sellContracts'])->having('buy_contracts_count', '>', 'sell_contracts_count');
|
||||
return $this->hasMany(Contract::class)->sellContracts();
|
||||
}
|
||||
|
||||
public function scopeWithContractCount($query)
|
||||
{
|
||||
return $query->withCount([
|
||||
'contracts AS buy_contracts_count' => function ($query) {
|
||||
$query->where('type', (string)ContractType::BuyContract);
|
||||
},
|
||||
'contracts AS sell_contracts_count' => function ($query) {
|
||||
$query->where('type', (string)ContractType::SellContract);
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
public function scopeUnsoldOnly($query)
|
||||
{
|
||||
return $query->withContractCount()->havingRaw('buy_contracts_count > sell_contracts_count');
|
||||
}
|
||||
|
||||
public function scopeSoldOnly($query)
|
||||
{
|
||||
return $query->withContractCount()->having('sell_contracts_count', '>', 0)->havingRaw('buy_contracts_count <= sell_contracts_count');
|
||||
}
|
||||
|
||||
public function scopeFilter($query, array $filters)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use App\Enums\ContractType;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Contact extends Model
|
||||
{
|
||||
|
|
@ -47,24 +48,19 @@ class Contact extends Model
|
|||
$query->orderBy('lastname', $direction)->orderBy('firstname', $direction);
|
||||
}
|
||||
|
||||
public function sellContracts()
|
||||
public function contracts()
|
||||
{
|
||||
return $this->hasMany(SellContract::class);
|
||||
return $this->hasMany(Contract::class);
|
||||
}
|
||||
|
||||
public function buyContracts()
|
||||
{
|
||||
return $this->hasMany(BuyContract::class);
|
||||
return $this->contracts()->buyContracts();
|
||||
}
|
||||
|
||||
public function boughtCars()
|
||||
public function sellContracts()
|
||||
{
|
||||
return $this->hasManyThrough(Car::class, SellContract::class);
|
||||
}
|
||||
|
||||
public function soldCars()
|
||||
{
|
||||
return $this->hasManyThrough(Car::class, BuyContract::class);
|
||||
return $this->contracts()->sellContracts();
|
||||
}
|
||||
|
||||
public function scopeFilter($query, array $filters)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Cknow\Money\Money;
|
||||
use App\Enums\ContractType;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Contract extends Model
|
||||
{
|
||||
use HasFactory, softDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'date',
|
||||
'price',
|
||||
'contact_id',
|
||||
'car_id',
|
||||
'type',
|
||||
'insurance_type',
|
||||
];
|
||||
|
||||
public function getDateAttribute($date)
|
||||
{
|
||||
return Carbon::parse($date)->format('d.m.Y');
|
||||
}
|
||||
|
||||
public function getPriceAttribute($price)
|
||||
{
|
||||
return Money::CHF($price)->format();
|
||||
}
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
|
||||
public function contact()
|
||||
{
|
||||
return $this->belongsTo(Contact::class);
|
||||
}
|
||||
|
||||
public function car()
|
||||
{
|
||||
return $this->belongsTo(Car::class);
|
||||
}
|
||||
|
||||
public function scopeThisYear($query)
|
||||
{
|
||||
$query->where('date', '>', date('Y'));
|
||||
}
|
||||
|
||||
public function scopeSoldThisYear($query)
|
||||
{
|
||||
$query->buyContracts()->thisYear();
|
||||
}
|
||||
|
||||
public function scopeBoughtThisYear($query)
|
||||
{
|
||||
$query->sellContracts()->thisYear();
|
||||
}
|
||||
|
||||
public function scopeBuyContracts($query)
|
||||
{
|
||||
$query->where('type', (string)ContractType::BuyContract);
|
||||
}
|
||||
|
||||
public function scopeSellContracts($query)
|
||||
{
|
||||
$query->where('type', (string)ContractType::SellContract);
|
||||
}
|
||||
}
|
||||
|
|
@ -15,8 +15,8 @@ class Document extends Model
|
|||
'car_id',
|
||||
];
|
||||
|
||||
public function car()
|
||||
public function documentable()
|
||||
{
|
||||
return $this->belongsTo(Car::class);
|
||||
return $this->morphTo();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,7 +176,6 @@ return [
|
|||
App\Providers\RouteServiceProvider::class,
|
||||
App\Providers\FortifyServiceProvider::class,
|
||||
App\Providers\JetstreamServiceProvider::class,
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
@ -229,7 +228,6 @@ return [
|
|||
'URL' => Illuminate\Support\Facades\URL::class,
|
||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||
'View' => Illuminate\Support\Facades\View::class,
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\BuyContract;
|
||||
use App\Models\Car;
|
||||
use App\Models\Contact;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class BuyContractFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = BuyContract::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'date' => $this->faker->date(),
|
||||
'price' => $this->faker->numberBetween(150000, 3500000),
|
||||
'contact_id' => $this->faker->numberBetween(1, Contact::count()),
|
||||
'car_id' => $this->faker->unique()->numberBetween(1, Car::count()),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ namespace Database\Factories;
|
|||
use App\Models\CarPayment;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use App\Enums\PaymentType;
|
||||
use App\Models\SellContract;
|
||||
use App\Models\Contract;
|
||||
|
||||
class CarPaymentFactory extends Factory
|
||||
{
|
||||
|
|
@ -27,7 +27,7 @@ class CarPaymentFactory extends Factory
|
|||
'amount' => $this->faker->numberBetween(1000, 10000),
|
||||
'date' => $this->faker->date(),
|
||||
'type' => (string)PaymentType::getRandomValue(),
|
||||
'sell_contract_id' => $this->faker->numberBetween(1, SellContract::count()),
|
||||
'contract_id' => $this->faker->numberBetween(1, Contract::count()),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,20 +2,21 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\SellContract;
|
||||
use App\Models\Contract;
|
||||
use App\Models\Car;
|
||||
use App\Models\Contact;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use App\Enums\InsuranceType;
|
||||
use App\Enums\ContractType;
|
||||
|
||||
class SellContractFactory extends Factory
|
||||
class ContractFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = SellContract::class;
|
||||
protected $model = Contract::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
|
|
@ -30,6 +31,7 @@ class SellContractFactory extends Factory
|
|||
'contact_id' => $this->faker->numberBetween(1, Contact::count()),
|
||||
'car_id' => $this->faker->numberBetween(1, Car::count()),
|
||||
'insurance_type' => (string)InsuranceType::getRandomValue(),
|
||||
'type' => (string)ContractType::getRandomValue(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Document;
|
||||
use App\Models\Car;
|
||||
use App\Models\Contract;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use App\Enums\DocumentType;
|
||||
|
||||
|
|
@ -26,8 +26,9 @@ class DocumentFactory extends Factory
|
|||
{
|
||||
return [
|
||||
'name' => $this->faker->name(),
|
||||
'car_id' => $this->faker->numberBetween(1, Car::count()),
|
||||
'document_type' => (string)DocumentType::getRandomValue(),
|
||||
'documentable_id' => $this->faker->numberBetween(1, Contract::count()),
|
||||
'documentable_type' => 'App\Models\Contract',
|
||||
'type' => (string)DocumentType::getRandomValue(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use App\Enums\InsuranceType;
|
||||
use App\Enums\ContractType;
|
||||
|
||||
class CreateSellContractsTable extends Migration
|
||||
class CreateContractsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
|
|
@ -14,7 +15,7 @@ class CreateSellContractsTable extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('sell_contracts', function (Blueprint $table) {
|
||||
Schema::create('contracts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->date('date');
|
||||
$table->integer('price');
|
||||
|
|
@ -27,7 +28,9 @@ class CreateSellContractsTable extends Migration
|
|||
->onDelete('cascade')
|
||||
->constrained('cars');
|
||||
$table->enum('insurance_type', InsuranceType::getValues())
|
||||
->default(InsuranceType::QBase);
|
||||
->default(InsuranceType::None);
|
||||
$table->enum('type', ContractType::getValues())
|
||||
->default(ContractType::SellContract);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
|
@ -17,12 +17,10 @@ class CreateDocumentsTable extends Migration
|
|||
Schema::create('documents', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->enum('document_type', DocumentType::getValues())
|
||||
$table->enum('type', DocumentType::getValues())
|
||||
->default(DocumentType::Other);
|
||||
$table->foreignId('car_id')
|
||||
->onUpdate('cascade')
|
||||
->onDelete('cascade')
|
||||
->constrained('cars');
|
||||
$table->integer('documentable_id');
|
||||
$table->string('documentable_type');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ class CreateCarPaymentsTable extends Migration
|
|||
$table->date('date');
|
||||
$table->enum('type', PaymentType::getValues())
|
||||
->default(PaymentType::Transaction);
|
||||
$table->foreignId('sell_contract_id')
|
||||
$table->foreignId('contract_id')
|
||||
->onUpdate('cascade')
|
||||
->onDelete('cascade')
|
||||
->constrained('sell_contracts');
|
||||
->constrained('contracts');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBuyContractsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('buy_contracts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->date('date');
|
||||
$table->integer('price');
|
||||
$table->foreignId('contact_id')
|
||||
->onUpdate('cascade')
|
||||
->onDelete('cascade')
|
||||
->constrained('contacts');
|
||||
$table->foreignId('car_id')
|
||||
->onUpdate('cascade')
|
||||
->onDelete('cascade')
|
||||
->constrained('cars');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('buy_contracts');
|
||||
}
|
||||
}
|
||||
|
|
@ -9,8 +9,7 @@ use App\Models\Car;
|
|||
use App\Models\CarModel;
|
||||
use App\Models\Brand;
|
||||
use App\Models\CarPayment;
|
||||
use App\Models\BuyContract;
|
||||
use App\Models\SellContract;
|
||||
use App\Models\Contract;
|
||||
use App\Models\Contact;
|
||||
use App\Models\Document;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
|
@ -27,8 +26,7 @@ class DatabaseSeeder extends Seeder
|
|||
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
|
||||
User::truncate();
|
||||
CarPayment::truncate();
|
||||
BuyContract::truncate();
|
||||
SellContract::truncate();
|
||||
Contract::truncate();
|
||||
Document::truncate();
|
||||
Car::truncate();
|
||||
Contact::truncate();
|
||||
|
|
@ -65,12 +63,8 @@ class DatabaseSeeder extends Seeder
|
|||
->count($nOfCars)
|
||||
->create();
|
||||
|
||||
$buyContracts = BuyContract::factory()
|
||||
->count($nOfCars)
|
||||
->create();
|
||||
|
||||
$sellContracts = SellContract::factory()
|
||||
->count(40)
|
||||
$contracts = Contract::factory()
|
||||
->count($nOfCars * 2)
|
||||
->create();
|
||||
|
||||
$carPayments = CarPayment::factory()
|
||||
|
|
|
|||
|
|
@ -16912,6 +16912,11 @@ __webpack_require__.r(__webpack_exports__);
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
resolve: function resolve(path, obj) {
|
||||
return path.split('.').reduce(function (prev, curr) {
|
||||
return prev ? prev[curr] : null;
|
||||
}, obj || self);
|
||||
},
|
||||
sortTable: function sortTable(col) {
|
||||
event.preventDefault();
|
||||
|
||||
|
|
@ -18565,8 +18570,20 @@ __webpack_require__.r(__webpack_exports__);
|
|||
value: 'Stammummer',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'buy_price',
|
||||
value: 'Kaufpreis',
|
||||
key: 'buy_contract.date',
|
||||
value: 'Einkaufsdatum',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'buy_contract.price',
|
||||
value: 'Einkaufspreis',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'sell_contract.date',
|
||||
value: 'Verkaufssdatum',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'sell_contract.price',
|
||||
value: 'Verkaufspreis',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'initial_date',
|
||||
|
|
@ -18687,8 +18704,20 @@ __webpack_require__.r(__webpack_exports__);
|
|||
value: 'Stammummer',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'buy_price',
|
||||
value: 'Kaufpreis',
|
||||
key: 'buy_contract.date',
|
||||
value: 'Einkaufsdatum',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'buy_contract.price',
|
||||
value: 'Einkaufspreis',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'sell_contract.date',
|
||||
value: 'Verkaufssdatum',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'sell_contract.price',
|
||||
value: 'Verkaufspreis',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'initial_date',
|
||||
|
|
@ -18741,8 +18770,20 @@ __webpack_require__.r(__webpack_exports__);
|
|||
value: 'Stammummer',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'buy_price',
|
||||
value: 'Kaufpreis',
|
||||
key: 'buy_contract.date',
|
||||
value: 'Einkaufsdatum',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'buy_contract.price',
|
||||
value: 'Einkaufspreis',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'sell_contract.date',
|
||||
value: 'Verkaufssdatum',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'sell_contract.price',
|
||||
value: 'Verkaufspreis',
|
||||
sortable: true
|
||||
}, {
|
||||
key: 'initial_date',
|
||||
|
|
@ -20287,38 +20328,35 @@ var _hoisted_7 = {
|
|||
key: 2
|
||||
};
|
||||
var _hoisted_8 = {
|
||||
key: 3,
|
||||
"class": "pt-3 mt-3 border-t"
|
||||
};
|
||||
|
||||
var _hoisted_9 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" Zum Vertrag ");
|
||||
|
||||
var _hoisted_10 = {
|
||||
key: 1,
|
||||
"class": "col-span-4 xs:col-span-12"
|
||||
};
|
||||
var _hoisted_9 = {
|
||||
var _hoisted_11 = {
|
||||
"class": "col-span-2 xs:col-span-12 py-9"
|
||||
};
|
||||
var _hoisted_10 = {
|
||||
var _hoisted_12 = {
|
||||
"class": "w-full flex flex-col"
|
||||
};
|
||||
|
||||
var _hoisted_11 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" ausdrucken ");
|
||||
|
||||
var _hoisted_12 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", {
|
||||
"class": "py-12"
|
||||
}, [/*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", {
|
||||
"class": "max-w-7xl sm:px-6 lg:px-8"
|
||||
}, [/*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)(" <simple-table title=\"Ankaufverträge\" :data=\"car.buy_contracts\" :columns=\"buyContractsColumns\" /> ")]), /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", {
|
||||
"class": "max-w-7xl pt-6 sm:px-6 lg:px-8"
|
||||
}, [/*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)(" <simple-table title=\"Verkaufverträge\" :data=\"car.sell_contracts\" :columns=\"sellContractsColumns\" /> ")])], -1
|
||||
/* HOISTED */
|
||||
);
|
||||
var _hoisted_13 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" drucken ");
|
||||
|
||||
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
var _component_contact_card = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("contact-card");
|
||||
|
||||
var _component_car_card = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("car-card");
|
||||
|
||||
var _component_unicon = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("unicon");
|
||||
|
||||
var _component_inertia_link = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("inertia-link");
|
||||
|
||||
return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)(vue__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_1, [$props.contract.contact ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_2, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("h3", null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.meta.contact), 1
|
||||
var _component_car_card = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("car-card");
|
||||
|
||||
return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_1, [$props.contract.contact ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_2, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("h3", null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.meta.contact), 1
|
||||
/* TEXT */
|
||||
), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_contact_card, {
|
||||
contact: $props.contract.contact
|
||||
|
|
@ -20326,39 +20364,47 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|||
/* PROPS */
|
||||
, ["contact"])])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_3, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("h3", null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.meta.title), 1
|
||||
/* TEXT */
|
||||
), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_4, [$props.contract.date ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_5, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(' vom ' + $props.contract.date), 1
|
||||
), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_4, [$props.contract.date ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_5, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contract.date), 1
|
||||
/* TEXT */
|
||||
)) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), $props.contract.price ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_6, " Preis: " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contract.price), 1
|
||||
)) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), $props.contract.price ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_6, " Betrag: " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contract.price), 1
|
||||
/* TEXT */
|
||||
)) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), $props.contract.insurance_type ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_7, " Versicherungstyp: " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contract.insurance_type), 1
|
||||
/* TEXT */
|
||||
)) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true)])]), $props.contract.car ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_8, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("h3", null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.meta.car), 1
|
||||
/* TEXT */
|
||||
), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_car_card, {
|
||||
car: $props.contract.car
|
||||
}, null, 8
|
||||
/* PROPS */
|
||||
, ["car"])])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_9, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_10, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_inertia_link, {
|
||||
href: _ctx.route('contracts.print', $props.contract.id),
|
||||
"class": "mb-5 inline-flex items-center px-4 py-2 bg-gray-800 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:ring focus:ring-gray-300 disabled:opacity-25 transition"
|
||||
)) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), $props.contract.link ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_8, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_inertia_link, {
|
||||
href: $props.contract.link,
|
||||
"class": "pt-1 pb-1 flex items-center"
|
||||
}, {
|
||||
"default": (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
|
||||
return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_unicon, {
|
||||
fill: "white",
|
||||
"class": "mr-1",
|
||||
height: "22",
|
||||
width: "22",
|
||||
name: "file-download"
|
||||
}), _hoisted_11];
|
||||
name: "arrow-right"
|
||||
}), _hoisted_9];
|
||||
}),
|
||||
_: 1
|
||||
/* STABLE */
|
||||
|
||||
}, 8
|
||||
/* PROPS */
|
||||
, ["href"])])])]), _hoisted_12], 64
|
||||
/* STABLE_FRAGMENT */
|
||||
);
|
||||
, ["href"])])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true)])]), $props.contract.car ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_10, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("h3", null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.meta.car), 1
|
||||
/* TEXT */
|
||||
), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_car_card, {
|
||||
car: $props.contract.car
|
||||
}, null, 8
|
||||
/* PROPS */
|
||||
, ["car"])])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_11, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_12, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("a", {
|
||||
href: _ctx.route('contracts.print', $props.contract.id),
|
||||
"class": "mb-5 inline-flex items-center px-4 py-2 bg-gray-800 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:ring focus:ring-gray-300 disabled:opacity-25 transition"
|
||||
}, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_unicon, {
|
||||
fill: "white",
|
||||
"class": "mr-1",
|
||||
height: "22",
|
||||
width: "22",
|
||||
name: "file-download"
|
||||
}), _hoisted_13], 8
|
||||
/* PROPS */
|
||||
, ["href"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)(" <inertia-link :href=\"route('contracts.print', contract.id)\" class=\"mb-5 inline-flex items-center px-4 py-2 bg-gray-800 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:ring focus:ring-gray-300 disabled:opacity-25 transition\" >\n <unicon fill=\"white\" class=\"mr-1\" height=\"22\" width=\"22\" name=\"file-download\"></unicon>\n ausdrucken\n </inertia-link> ")])])]);
|
||||
}
|
||||
|
||||
/***/ }),
|
||||
|
|
@ -21028,7 +21074,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|||
href: row.link
|
||||
}, {
|
||||
"default": (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
|
||||
return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)((0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(row[col.key]), 1
|
||||
return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)((0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($options.resolve(col.key, row)), 1
|
||||
/* TEXT */
|
||||
)];
|
||||
}),
|
||||
|
|
@ -21037,7 +21083,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|||
|
||||
}, 1032
|
||||
/* PROPS, DYNAMIC_SLOTS */
|
||||
, ["href"])) : ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("span", _hoisted_11, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(row[col.key]), 1
|
||||
, ["href"])) : ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("span", _hoisted_11, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($options.resolve(col.key, row)), 1
|
||||
/* TEXT */
|
||||
))]);
|
||||
}), 128
|
||||
|
|
|
|||
|
|
@ -8,14 +8,20 @@
|
|||
<h3>{{ meta.title }}</h3>
|
||||
<div class="mt-3 p-5 bg-white shadow rounded-md font-medium">
|
||||
<div v-if="contract.date" class="font-bold">
|
||||
{{' vom ' + contract.date }}
|
||||
{{ contract.date }}
|
||||
</div>
|
||||
<div v-if="contract.price">
|
||||
Preis: {{ contract.price }}
|
||||
Betrag: {{ contract.price }}
|
||||
</div>
|
||||
<div v-if="contract.insurance_type">
|
||||
Versicherungstyp: {{ contract.insurance_type }}
|
||||
</div>
|
||||
<div v-if="contract.link" class="pt-3 mt-3 border-t">
|
||||
<inertia-link :href="contract.link" class="pt-1 pb-1 flex items-center">
|
||||
<unicon class="mr-1" height="22" width="22" name="arrow-right"></unicon>
|
||||
Zum Vertrag
|
||||
</inertia-link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="contract.car" class="col-span-4 xs:col-span-12">
|
||||
|
|
@ -24,21 +30,17 @@
|
|||
</div>
|
||||
<div class="col-span-2 xs:col-span-12 py-9">
|
||||
<div class="w-full flex flex-col">
|
||||
<inertia-link :href="route('contracts.print', contract.id)" class="mb-5 inline-flex items-center px-4 py-2 bg-gray-800 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:ring focus:ring-gray-300 disabled:opacity-25 transition" >
|
||||
<a :href="route('contracts.print', contract.id)" class="mb-5 inline-flex items-center px-4 py-2 bg-gray-800 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:ring focus:ring-gray-300 disabled:opacity-25 transition" >
|
||||
<unicon fill="white" class="mr-1" height="22" width="22" name="file-download"></unicon>
|
||||
drucken
|
||||
</a>
|
||||
<!-- <inertia-link :href="route('contracts.print', contract.id)" class="mb-5 inline-flex items-center px-4 py-2 bg-gray-800 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:ring focus:ring-gray-300 disabled:opacity-25 transition" >
|
||||
<unicon fill="white" class="mr-1" height="22" width="22" name="file-download"></unicon>
|
||||
ausdrucken
|
||||
</inertia-link>
|
||||
</inertia-link> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="py-12">
|
||||
<div class="max-w-7xl sm:px-6 lg:px-8">
|
||||
<!-- <simple-table title="Ankaufverträge" :data="car.buy_contracts" :columns="buyContractsColumns" /> -->
|
||||
</div>
|
||||
<div class="max-w-7xl pt-6 sm:px-6 lg:px-8">
|
||||
<!-- <simple-table title="Verkaufverträge" :data="car.sell_contracts" :columns="sellContractsColumns" /> -->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@
|
|||
<tr v-for="row in data.data" :key="row.link" class="hover:bg-gray-100 focus-within:bg-gray-100">
|
||||
<td v-for="col in columns" :key="col.key" class="border-t">
|
||||
<inertia-link v-if="row.link" class="px-6 py-4 flex items-center focus:text-blue-200" :href="row.link">
|
||||
{{ row[col.key] }}
|
||||
{{ resolve(col.key, row) }}
|
||||
</inertia-link>
|
||||
<span v-else class="px-6 py-4 flex items-center focus:text-blue-200">
|
||||
{{ row[col.key] }}
|
||||
{{ resolve(col.key, row) }}
|
||||
</span>
|
||||
</td>
|
||||
<td v-if="row.link" class="border-t w-px">
|
||||
|
|
@ -89,6 +89,11 @@ export default {
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
resolve(path, obj) {
|
||||
return path.split('.').reduce(function(prev, curr) {
|
||||
return prev ? prev[curr] : null
|
||||
}, obj || self)
|
||||
},
|
||||
sortTable(col) {
|
||||
event.preventDefault();
|
||||
if (this.sort.by == col) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,10 @@ export default {
|
|||
columns: [
|
||||
{key: 'name', value: 'Name', sortable: true},
|
||||
{key: 'stammnummer', value: 'Stammummer', sortable: true},
|
||||
{key: 'buy_price', value: 'Kaufpreis', sortable: true},
|
||||
{key: 'buy_contract.date', value: 'Einkaufsdatum', sortable: true},
|
||||
{key: 'buy_contract.price', value: 'Einkaufspreis', sortable: true},
|
||||
{key: 'sell_contract.date', value: 'Verkaufssdatum', sortable: true},
|
||||
{key: 'sell_contract.price', value: 'Verkaufspreis', sortable: true},
|
||||
{key: 'initial_date', value: 'Inverkehrssetzung', sortable: true},
|
||||
],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,10 @@ export default {
|
|||
columns: [
|
||||
{key: 'name', value: 'Name', sortable: true},
|
||||
{key: 'stammnummer', value: 'Stammummer', sortable: true},
|
||||
{key: 'buy_price', value: 'Kaufpreis', sortable: true},
|
||||
{key: 'buy_contract.date', value: 'Einkaufsdatum', sortable: true},
|
||||
{key: 'buy_contract.price', value: 'Einkaufspreis', sortable: true},
|
||||
{key: 'sell_contract.date', value: 'Verkaufssdatum', sortable: true},
|
||||
{key: 'sell_contract.price', value: 'Verkaufspreis', sortable: true},
|
||||
{key: 'initial_date', value: 'Inverkehrssetzung', sortable: true},
|
||||
],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,10 @@ export default {
|
|||
columns: [
|
||||
{key: 'name', value: 'Name', sortable: true},
|
||||
{key: 'stammnummer', value: 'Stammummer', sortable: true},
|
||||
{key: 'buy_price', value: 'Kaufpreis', sortable: true},
|
||||
{key: 'buy_contract.date', value: 'Einkaufsdatum', sortable: true},
|
||||
{key: 'buy_contract.price', value: 'Einkaufspreis', sortable: true},
|
||||
{key: 'sell_contract.date', value: 'Verkaufssdatum', sortable: true},
|
||||
{key: 'sell_contract.price', value: 'Verkaufspreis', sortable: true},
|
||||
{key: 'initial_date', value: 'Inverkehrssetzung', sortable: true},
|
||||
],
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue