various fixes

shift-build-2464
Nadim Salloum 2021-07-12 21:45:46 +03:00
parent 79750d1f13
commit 0220acfb0c
10 changed files with 19 additions and 17 deletions

View File

@ -13,7 +13,7 @@ use BenSampo\Enum\Enum;
*/ */
final class InsuranceType extends Enum final class InsuranceType extends Enum
{ {
const None = '0'; const Keine = '0';
const QBase = '1'; const QBase = '1';
const OneStar = '2'; const OneStar = '2';
const ThreeStar = '3'; const ThreeStar = '3';

View File

@ -33,7 +33,6 @@ class ContractController extends Controller
->map(function ($contract) { ->map(function ($contract) {
return [ return [
'date' => $contract->date_formatted, 'date' => $contract->date_formatted,
'price' => $contract->price->format(),
'car' => $contract->car->name_with_year, 'car' => $contract->car->name_with_year,
'contact' => $contract->contact->title, 'contact' => $contract->contact->title,
'link' => route('contracts.show', $contract), 'link' => route('contracts.show', $contract),
@ -46,7 +45,6 @@ class ContractController extends Controller
->map(function ($contract) { ->map(function ($contract) {
return [ return [
'date' => $contract->date_formatted, 'date' => $contract->date_formatted,
'price' => $contract->price->format(),
'car' => $contract->car->name_with_year, 'car' => $contract->car->name_with_year,
'contact' => $contract->contact->title, 'contact' => $contract->contact->title,
'link' => route('contracts.show', $contract), 'link' => route('contracts.show', $contract),

View File

@ -101,7 +101,7 @@ class Car extends Model
public function isSold() public function isSold()
{ {
return $this->buyContracts()->count() <= $this->sellContracts()->count(); return $this->buyContracts()->count() <= $this->sellContracts()->count() && $this->sellContracts()->count() > 0;
} }
public function contracts() public function contracts()
@ -133,12 +133,12 @@ class Car extends Model
public function scopeUnsoldOnly($query) public function scopeUnsoldOnly($query)
{ {
return $query->withContractCount()->havingRaw('buy_contracts_count > sell_contracts_count'); return $query->withContractCount()->havingRaw('buy_contracts_count > sell_contracts_count OR sell_contracts_count = 0');
} }
public function scopeSoldOnly($query) public function scopeSoldOnly($query)
{ {
return $query->withContractCount()->having('sell_contracts_count', '>', 0)->havingRaw('buy_contracts_count = sell_contracts_count'); return $query->withContractCount()->having('sell_contracts_count', '>', 0)->havingRaw('buy_contracts_count <= sell_contracts_count');
} }
public function scopeFilter($query, array $filters) public function scopeFilter($query, array $filters)

View File

@ -56,7 +56,7 @@ class RouteServiceProvider extends ServiceProvider
}); });
Route::bind('contract', function ($value) { Route::bind('contract', function ($value) {
if (in_array(Route::currentRouteName(), ['contracts.show', 'contracts.restore'])) { if (in_array(Route::currentRouteName(), ['contracts.show', 'contracts.restore', 'payments.destroy'])) {
return Contract::withTrashed()->find($value); return Contract::withTrashed()->find($value);
} }
return Contract::find($value); return Contract::find($value);

View File

@ -30,7 +30,7 @@ class CreateContractsTable extends Migration
->onDelete('cascade') ->onDelete('cascade')
->constrained('cars'); ->constrained('cars');
$table->enum('insurance_type', InsuranceType::getValues()) $table->enum('insurance_type', InsuranceType::getValues())
->default(InsuranceType::None); ->default(InsuranceType::Keine);
$table->enum('type', ContractType::getValues()) $table->enum('type', ContractType::getValues())
->default(ContractType::SellContract); ->default(ContractType::SellContract);
$table->timestamps(); $table->timestamps();

8
public/js/app.js vendored
View File

@ -21550,7 +21550,7 @@ __webpack_require__.r(__webpack_exports__);
price: null, price: null,
notes: null, notes: null,
type: this.type, type: this.type,
insurance_type: '1', insurance_type: '0',
car_id: (_this$car$id = (_this$car = this.car) === null || _this$car === void 0 ? void 0 : _this$car.id) !== null && _this$car$id !== void 0 ? _this$car$id : null, car_id: (_this$car$id = (_this$car = this.car) === null || _this$car === void 0 ? void 0 : _this$car.id) !== null && _this$car$id !== void 0 ? _this$car$id : null,
contact_id: (_this$contact$id = (_this$contact = this.contact) === null || _this$contact === void 0 ? void 0 : _this$contact.id) !== null && _this$contact$id !== void 0 ? _this$contact$id : null, contact_id: (_this$contact$id = (_this$contact = this.contact) === null || _this$contact === void 0 ? void 0 : _this$contact.id) !== null && _this$contact$id !== void 0 ? _this$contact$id : null,
amount: null, amount: null,
@ -23327,7 +23327,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
"onUpdate:modelValue": _cache[1] || (_cache[1] = function ($event) { "onUpdate:modelValue": _cache[1] || (_cache[1] = function ($event) {
return $data.contact = $event; return $data.contact = $event;
}), }),
label: "name", label: "title",
"track-by": "id", "track-by": "id",
options: $data.contactsChoice, options: $data.contactsChoice,
"class": "2xl:col-span-4 sm:col-span-6 col-span-12", "class": "2xl:col-span-4 sm:col-span-6 col-span-12",
@ -24254,7 +24254,7 @@ var _hoisted_11 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNo
var _hoisted_12 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" Alle Autos "); var _hoisted_12 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" Alle Autos ");
var _hoisted_13 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" Meine Autos "); var _hoisted_13 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" Autos im Lager ");
var _hoisted_14 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" Verkaufte Autos "); var _hoisted_14 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" Verkaufte Autos ");
@ -24335,6 +24335,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
}, 8 }, 8
/* PROPS */ /* PROPS */
, ["href", "active"])]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_5, [_hoisted_6, (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_jet_nav_link, { , ["href", "active"])]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_5, [_hoisted_6, (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_jet_nav_link, {
"class": "text-xl",
href: _ctx.route('contracts.create', { href: _ctx.route('contracts.create', {
type: 0 type: 0
}), }),
@ -24355,6 +24356,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
}, 8 }, 8
/* PROPS */ /* PROPS */
, ["href", "active"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_jet_nav_link, { , ["href", "active"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_jet_nav_link, {
"class": "text-xl",
href: _ctx.route('contracts.create', { href: _ctx.route('contracts.create', {
type: 1 type: 1
}), }),

View File

@ -13,7 +13,7 @@
<div class="col-span-6"> <div class="col-span-6">
<jet-label for="contact" :value="contactType + ' auswählen'" /> <jet-label for="contact" :value="contactType + ' auswählen'" />
<div class="grid grid-cols-12 gap-3 gap-y-6 mt-1"> <div class="grid grid-cols-12 gap-3 gap-y-6 mt-1">
<multiselect :allow-empty="false" @select="onContactChange" :disabled="createContact" v-model="contact" label="name" track-by="id" :options="contactsChoice" class="2xl:col-span-4 sm:col-span-6 col-span-12" :placeholder="contactType + 'wählen'" /> <multiselect :allow-empty="false" @select="onContactChange" :disabled="createContact" v-model="contact" label="title" track-by="id" :options="contactsChoice" class="2xl:col-span-4 sm:col-span-6 col-span-12" :placeholder="contactType + 'wählen'" />
<div v-if="!createContact" class="sm:col-span-6 col-span-12"> <div v-if="!createContact" class="sm:col-span-6 col-span-12">
<span class="mr-2">oder</span> <span class="mr-2">oder</span>
<button @click="openContactForm" class="bg-indigo-800 hover:bg-indigo-700 active:bg-indigo-900 focus:border-indigo-900 focus:ring-indigo-300 justify-center inline-flex items-center px-4 py-2 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest focus:outline-none focus:ring disabled:opacity-25 transition"> <button @click="openContactForm" class="bg-indigo-800 hover:bg-indigo-700 active:bg-indigo-900 focus:border-indigo-900 focus:ring-indigo-300 justify-center inline-flex items-center px-4 py-2 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest focus:outline-none focus:ring disabled:opacity-25 transition">

View File

@ -20,11 +20,11 @@
<p class="text-sm font-semibold mb-1 text-indigo-100 flex items-center"> <p class="text-sm font-semibold mb-1 text-indigo-100 flex items-center">
Verträge Verträge
</p> </p>
<jet-nav-link :href="route('contracts.create', {type: 0})" :active="onBasicContractCreate && type == '0'"> <jet-nav-link class="text-xl" :href="route('contracts.create', {type: 0})" :active="onBasicContractCreate && type == '0'">
<unicon fill="currentColor" class="mr-2" height="22" width="22" name="plus-circle"></unicon> <unicon fill="currentColor" class="mr-2" height="22" width="22" name="plus-circle"></unicon>
Neuer Einkauf Neuer Einkauf
</jet-nav-link> </jet-nav-link>
<jet-nav-link :href="route('contracts.create', {type: 1})" :active="onBasicContractCreate && type == '1'"> <jet-nav-link class="text-xl" :href="route('contracts.create', {type: 1})" :active="onBasicContractCreate && type == '1'">
<unicon fill="currentColor" class="mr-2" height="22" width="22" name="plus-circle"></unicon> <unicon fill="currentColor" class="mr-2" height="22" width="22" name="plus-circle"></unicon>
Neuer Verkauf Neuer Verkauf
</jet-nav-link> </jet-nav-link>
@ -44,7 +44,7 @@
</jet-nav-link> </jet-nav-link>
<jet-nav-link :href="route('cars.unsold')" :active="route().current('cars.unsold')"> <jet-nav-link :href="route('cars.unsold')" :active="route().current('cars.unsold')">
<unicon fill="currentColor" class="mr-2 ml-3" height="22" width="22" name="angle-right"></unicon> <unicon fill="currentColor" class="mr-2 ml-3" height="22" width="22" name="angle-right"></unicon>
Meine Autos Autos im Lager
</jet-nav-link> </jet-nav-link>
<jet-nav-link :href="route('cars.sold')" :active="route().current('cars.sold')"> <jet-nav-link :href="route('cars.sold')" :active="route().current('cars.sold')">
<unicon fill="currentColor" class="mr-2 ml-3" height="22" width="22" name="angle-right"></unicon> <unicon fill="currentColor" class="mr-2 ml-3" height="22" width="22" name="angle-right"></unicon>

View File

@ -63,7 +63,7 @@ export default {
price: null, price: null,
notes: null, notes: null,
type: this.type, type: this.type,
insurance_type: '1', insurance_type: '0',
car_id: this.car?.id ?? null, car_id: this.car?.id ?? null,
contact_id: this.contact?.id ?? null, contact_id: this.contact?.id ?? null,
amount: null, amount: null,

View File

@ -3,7 +3,9 @@
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>
{{ $contract->type_formatted }} - {{ $contract->car->name }} - {{ $contract->contact->full_title }}
</title>
<style type="text/css"> <style type="text/css">
* { * {
font-family: Verdana, Arial, sans-serif; font-family: Verdana, Arial, sans-serif;