close #1551 Fixed: Reconciliation form checkbox missing values

This commit is contained in:
Cüneyt Şentürk 2020-08-10 14:15:15 +03:00
parent 115b55f688
commit 48a37246c5
5 changed files with 33 additions and 3 deletions

View File

@ -42,7 +42,7 @@ class CreateReconciliation extends Job
'reconciled' => $reconcile ? 1 : 0,
]);
if ($transactions) {
if ($reconcile && $transactions) {
foreach ($transactions as $key => $value) {
if (empty($value)) {
continue;

View File

@ -47,7 +47,7 @@ class UpdateReconciliation extends Job
$t = explode('_', $key);
$transaction = Transaction::find($t[1]);
$transaction->reconciled = 1;
$transaction->reconciled = $reconcile ? 1 : 0;
$transaction->save();
}
}

View File

@ -48,9 +48,35 @@ export default class Form {
this[form_element.getAttribute('data-field')] = field;
}
/*
if (!this[form_element.getAttribute('data-field')][name]) {
this[form_element.getAttribute('data-field')][name] = '';
}
*/
if (type == 'radio') {
if (!this[form_element.getAttribute('data-field')][name]) {
this[form_element.getAttribute('data-field')][name] = (form_element.getAttribute('value') ? 1 : 0) || 0;
}
} else if (type == 'checkbox') {
if (this[form_element.getAttribute('data-field')][name]) {
if (!this[form_element.getAttribute('data-field')][name].push) {
this[form_element.getAttribute('data-field')][name] = [this[form_element.getAttribute('data-field')][name]];
}
if (form_element.checked) {
this[form_element.getAttribute('data-field')][name].push(form_element.value);
}
} else {
if (form_element.checked) {
this[form_element.getAttribute('data-field')][name] = form_element.value;
} else {
this[form_element.getAttribute('data-field')][name] = [];
}
}
} else {
this[form_element.getAttribute('data-field')][name] = form_element.getAttribute('value') || '';
}
continue;
}

View File

@ -43,6 +43,10 @@ const app = new Vue({
if (document.getElementById('closing_balance') != null) {
this.totals.closing_balance = parseFloat(document.getElementById('closing_balance').value);
}
if (this.form._method == 'PATCH') {
this.onCalculate();
}
},
methods:{

View File

@ -55,7 +55,7 @@
@endif
<td class="col-md-1 text-right d-none d-md-block">
<div class="custom-control custom-checkbox">
{{ Form::checkbox($item->type . '_' . $item->id, $item->price, $item->reconciled, [
{{ Form::checkbox($item->type . '_' . $item->id, $item->amount_for_account, $item->reconciled, [
'data-field' => 'transactions',
'v-model' => 'form.transactions.' . $item->type . '_' . $item->id,
'id' => 'transaction-' . $item->id . '-'. $item->type,