add new paymenttype 'cembra'

shift-build-2464
Nadim Salloum 2021-10-20 16:14:00 +02:00
parent 93877cd90c
commit 6cd67a5280
9 changed files with 75 additions and 20 deletions

View File

@ -18,4 +18,4 @@ Steps:
3. Run migrations and seed db: `sail php artisan migrate:fresh --seed`
4. `sail npm run watch`
5. Access the web application at `0.0.0.0`
6. The default credentials are `hello@salloum.ch` and `abc123`
6. The default credentials can be seen/set in the .env

View File

@ -12,4 +12,5 @@ final class PaymentType extends Enum
{
const Transaction = '0';
const Cash = '1';
const Cembra = '2';
}

View File

@ -63,6 +63,12 @@ class Contract extends Model
return Money::CHF($this->payments()->transactionOnly()->sum('amount'));
}
public function getPaidInCembraAttribute()
{
return Money::CHF($this->payments()->cembraOnly()->sum('amount'));
}
public function getLeftToPayAttribute()
{

View File

@ -42,12 +42,27 @@ class Payment extends Model
public function getTypeAttribute($type)
{
return $type == PaymentType::Transaction() ? 'Banküberweisung' : 'Barzahlung';
switch ($type) {
case PaymentType::Transaction():
return 'Banküberweisung';
case PaymentType::Cash():
return 'Barzahlung';
default:
return 'Überweisung via Cembra';
};
}
public function getTypeTextAttribute()
{
return $this->type == 'Banküberweisung' ? 'via Banküberweisung erhalten' : 'in bar erhalten';
switch ($this->type) {
case 'Banküberweisung':
return 'via Banküberweisung erhalten';
case 'Barzahlung':
return 'in bar erhalten';
default:
return 'via Cembra-Überweisung erhalten';
};
}
public function getDeleteLinkAttribute()
@ -64,4 +79,9 @@ class Payment extends Model
{
$query->where('type', PaymentType::Transaction());
}
public function scopeCembraOnly($query)
{
$query->where('type', PaymentType::Cembra());
}
}

26
public/js/app.js vendored
View File

@ -22324,7 +22324,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
colour: this.car.colour,
notes: this.car.notes,
car_model_id: this.car.car_model.id,
last_check_date: new Date(this.car.last_check_date).toJSON().slice(0, 10).split('-').reverse().join('.'),
last_check_date: this.car.last_check_date ? new Date(this.car.last_check_date).toJSON().slice(0, 10).split('-').reverse().join('.') : '',
kilometers: this.car.kilometers,
known_damage: this.car.known_damage
}, "notes", this.car.notes)
@ -25488,8 +25488,9 @@ var _hoisted_5 = {
};
var _hoisted_6 = ["selected"];
var _hoisted_7 = ["selected"];
var _hoisted_8 = ["selected"];
var _hoisted_8 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" Einzahlung speichern ");
var _hoisted_9 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" Einzahlung speichern ");
function render(_ctx, _cache, $props, $setup, $data, $options) {
var _component_jet_label = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("jet-label");
@ -25574,7 +25575,12 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
selected: $data.form.type == '1'
}, "Barzahlung", 8
/* PROPS */
, _hoisted_7)], 512
, _hoisted_7), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("option", {
value: "2",
selected: $data.form.type == '2'
}, "Cembra-Überweisung", 8
/* PROPS */
, _hoisted_8)], 512
/* NEED_PATCH */
), [[vue__WEBPACK_IMPORTED_MODULE_0__.vModelSelect, $data.form.type]]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_jet_input_error, {
message: $data.form.errors.type,
@ -25594,7 +25600,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
disabled: $data.form.processing
}, {
"default": (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
return [_hoisted_8];
return [_hoisted_9];
}),
_: 1
/* STABLE */
@ -31162,7 +31168,8 @@ var _hoisted_8 = {
};
var _hoisted_9 = ["selected"];
var _hoisted_10 = ["selected"];
var _hoisted_11 = {
var _hoisted_11 = ["selected"];
var _hoisted_12 = {
"class": "col-span-6"
};
function render(_ctx, _cache, $props, $setup, $data, $options) {
@ -31311,14 +31318,19 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
selected: $data.form.payment_type == '1'
}, "Barzahlung", 8
/* PROPS */
, _hoisted_10)], 512
, _hoisted_10), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("option", {
value: "2",
selected: $data.form.payment_type == '2'
}, "Cembra-Überweisung", 8
/* PROPS */
, _hoisted_11)], 512
/* NEED_PATCH */
), [[vue__WEBPACK_IMPORTED_MODULE_0__.vModelSelect, $data.form.payment_type]]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_jet_input_error, {
message: $data.form.errors.type,
"class": "mt-2"
}, null, 8
/* PROPS */
, ["message"])])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", _hoisted_11, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_jet_label, {
, ["message"])])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("div", _hoisted_12, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_jet_label, {
"for": "notes",
value: "Bemerkungen"
}), (0,vue__WEBPACK_IMPORTED_MODULE_0__.withDirectives)((0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementVNode)("textarea", {

View File

@ -23,6 +23,7 @@
<select v-model="form.type" class="mt-1 block w-full border-gray-300 rounded-md shadow-sm">
<option value="0" :selected="form.type == '0'">Banküberweisung</option>
<option value="1" :selected="form.type == '1'">Barzahlung</option>
<option value="2" :selected="form.type == '2'">Cembra-Überweisung</option>
</select>
<jet-input-error :message="form.errors.type" class="mt-2" />
</div>

View File

@ -65,7 +65,7 @@ export default {
colour: this.car.colour,
notes: this.car.notes,
car_model_id: this.car.car_model.id,
last_check_date: new Date(this.car.last_check_date).toJSON().slice(0,10).split('-').reverse().join('.'),
last_check_date: this.car.last_check_date ? new Date(this.car.last_check_date).toJSON().slice(0,10).split('-').reverse().join('.') : '',
kilometers: this.car.kilometers,
known_damage: this.car.known_damage,
notes: this.car.notes,

View File

@ -46,6 +46,7 @@
<select v-model="form.payment_type" class="mt-1 block w-full border-gray-300 rounded-md shadow-sm">
<option value="0" :selected="form.payment_type == '0'">Banküberweisung</option>
<option value="1" :selected="form.payment_type == '1'">Barzahlung</option>
<option value="2" :selected="form.payment_type == '2'">Cembra-Überweisung</option>
</select>
<jet-input-error :message="form.errors.type" class="mt-2" />
</div>

View File

@ -153,21 +153,35 @@ MwSt-Nr: CHE-226.272.050
<td>{{ $contract->insurance_type_formatted }}</td>
</tr>
<tr><td>&nbsp;</td></tr>
</table>
<table width="100%">
<tr>
<td>Kaufpreis</td>
<td><b>{{ $contract->price }}</b></td>
<td width="20%">Kaufpreis</td>
<td width="80%"><b>{{ $contract->price }}</b></td>
</tr>
<tr>
<td valign="top">Anzahlung</td>
@if ($contract->paid_in_cash->getAmount() && $contract->paid_in_transaction->getAmount())
<td>{{ $contract->paid_in_cash }} in bar<br>{{ $contract->paid_in_transaction }} via Überweisung</td>
@elseif ($contract->paid_in_cash->getAmount())
<td>{{ $contract->paid_in_cash }} in bar</td>
@elseif ($contract->paid_in_transaction->getAmount())
<td>{{ $contract->paid_in_transaction }} via Überweisung</td>
<td>
@if ($contract->paid_in_cash->getAmount() || $contract->paid_in_transaction->getAmount() || $contract->paid_in_cembra->getAmount())
@if ($contract->paid_in_cash->getAmount())
{{ $contract->paid_in_cash }} in bar
@if ($contract->paid_in_transaction->getAmount() || $contract->paid_in_cembra->getAmount())
<br>
@endif
@endif
@if ($contract->paid_in_transaction->getAmount())
{{ $contract->paid_in_transaction }} via Überweisung
@if ($contract->paid_in_cembra->getAmount())
<br>
@endif
@endif
@if ($contract->paid_in_cembra->getAmount())
{{ $contract->paid_in_cembra }} via Cembra-Überweisung
@endif
@else
<td>{{ $contract->paid }}</td>
{{ $contract->paid }}
@endif
</td>
</tr>
<tr>
<td>Restbetrag</td>