|
@@ -18,6 +18,12 @@ class RecordIN extends Component
|
|
|
public $typeIN = "IN";
|
|
public $typeIN = "IN";
|
|
|
|
|
|
|
|
public $isDuplicate = false;
|
|
public $isDuplicate = false;
|
|
|
|
|
+ public $multiP = false;
|
|
|
|
|
+
|
|
|
|
|
+ public $multiMonthTo = 0;
|
|
|
|
|
+ public $multiYearTo = 0;
|
|
|
|
|
+ public $multiMonthFrom = 0;
|
|
|
|
|
+ public $multiYearFrom = 0;
|
|
|
|
|
|
|
|
public function sortBy($field)
|
|
public function sortBy($field)
|
|
|
{
|
|
{
|
|
@@ -39,6 +45,7 @@ class RecordIN extends Component
|
|
|
$year,
|
|
$year,
|
|
|
$type,
|
|
$type,
|
|
|
$amount,
|
|
$amount,
|
|
|
|
|
+ $vat,
|
|
|
$virtual,
|
|
$virtual,
|
|
|
$note,
|
|
$note,
|
|
|
$commercial, $update = false, $add = false;
|
|
$commercial, $update = false, $add = false;
|
|
@@ -71,6 +78,7 @@ class RecordIN extends Component
|
|
|
public $causals = array();
|
|
public $causals = array();
|
|
|
public $payments = array();
|
|
public $payments = array();
|
|
|
public $members = array();
|
|
public $members = array();
|
|
|
|
|
+ public $vats = array();
|
|
|
|
|
|
|
|
public $rows = array();
|
|
public $rows = array();
|
|
|
|
|
|
|
@@ -154,7 +162,7 @@ class RecordIN extends Component
|
|
|
$this->newMemberFiscalCodeExist = false;
|
|
$this->newMemberFiscalCodeExist = false;
|
|
|
$this->currentReceip = null;
|
|
$this->currentReceip = null;
|
|
|
$this->rows = array();
|
|
$this->rows = array();
|
|
|
- $this->rows[] = array('causal_id' => isset($_GET["causalId"]) ? $_GET["causalId"] : null, 'when' => array(array('month' => date("n"), 'year' => date("Y"), 'period' => '')), 'amount' => null, 'note' => '', 'commercial' => 0);
|
|
|
|
|
|
|
+ $this->rows[] = array('causal_id' => isset($_GET["causalId"]) ? $_GET["causalId"] : null, 'when' => array(array('month' => date("n"), 'year' => date("Y"), 'period' => '')), 'amount' => null, 'vat_id' => null, 'note' => '', 'commercial' => 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function getMemberProperty()
|
|
public function getMemberProperty()
|
|
@@ -220,12 +228,18 @@ class RecordIN extends Component
|
|
|
|
|
|
|
|
$this->causals = array();
|
|
$this->causals = array();
|
|
|
|
|
|
|
|
|
|
+ $this->multiMonthFrom = date("n");
|
|
|
|
|
+ $this->multiYearFrom = date("Y");
|
|
|
|
|
+ $this->multiMonthTo = date("n");
|
|
|
|
|
+ $this->multiYearTo = date("Y");
|
|
|
|
|
+
|
|
|
$this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'IN')->get(), 0);
|
|
$this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'IN')->get(), 0);
|
|
|
|
|
|
|
|
//$this->buildTree(\App\Models\Causal::all(), null);
|
|
//$this->buildTree(\App\Models\Causal::all(), null);
|
|
|
|
|
|
|
|
$this->members = \App\Models\Member::select(['id', 'first_name', 'last_name', 'fiscal_code'])->orderBy('last_name')->orderBy('first_name')->get();
|
|
$this->members = \App\Models\Member::select(['id', 'first_name', 'last_name', 'fiscal_code'])->orderBy('last_name')->orderBy('first_name')->get();
|
|
|
$this->payments = \App\Models\PaymentMethod::select('id', 'name')->orderBy('name')->get();
|
|
$this->payments = \App\Models\PaymentMethod::select('id', 'name')->orderBy('name')->get();
|
|
|
|
|
+ $this->vats = \App\Models\Vat::select('id', 'name', 'value')->orderBy('value')->get();
|
|
|
|
|
|
|
|
if ($this->first)
|
|
if ($this->first)
|
|
|
{
|
|
{
|
|
@@ -317,6 +331,8 @@ class RecordIN extends Component
|
|
|
foreach($r->rows as $rr)
|
|
foreach($r->rows as $rr)
|
|
|
{
|
|
{
|
|
|
$this->total += $rr->amount;
|
|
$this->total += $rr->amount;
|
|
|
|
|
+ if ($rr->vat_id > 0)
|
|
|
|
|
+ $this->total += getVatValue($rr->amount, $rr->vat_id);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -431,7 +447,7 @@ class RecordIN extends Component
|
|
|
$f = false;
|
|
$f = false;
|
|
|
foreach($this->rows as $row)
|
|
foreach($this->rows as $row)
|
|
|
{
|
|
{
|
|
|
- if (!$row["commercial"]) $f = true;
|
|
|
|
|
|
|
+ if ($row["commercial"]) $f = true;
|
|
|
}
|
|
}
|
|
|
if ($f)
|
|
if ($f)
|
|
|
$rules["member_id"] = 'required';
|
|
$rules["member_id"] = 'required';
|
|
@@ -442,20 +458,15 @@ class RecordIN extends Component
|
|
|
$record = \App\Models\Record::create([
|
|
$record = \App\Models\Record::create([
|
|
|
'member_id' => $this->member_id,
|
|
'member_id' => $this->member_id,
|
|
|
'supplier_id' => $this->supplier_id,
|
|
'supplier_id' => $this->supplier_id,
|
|
|
- // 'causal_id' => $this->causal_id,
|
|
|
|
|
'payment_method_id' => $this->payment_method_id,
|
|
'payment_method_id' => $this->payment_method_id,
|
|
|
'date' => $this->date,
|
|
'date' => $this->date,
|
|
|
- // 'month' => $this->month,
|
|
|
|
|
- // 'year' => $this->year,
|
|
|
|
|
- // 'note' => $this->note,
|
|
|
|
|
'type' => $this->type,
|
|
'type' => $this->type,
|
|
|
- // 'amount' => $this->currencyToDouble($this->amount),
|
|
|
|
|
- // 'commercial' => $this->commercial,
|
|
|
|
|
]);
|
|
]);
|
|
|
$this->dataId = $record->id;
|
|
$this->dataId = $record->id;
|
|
|
|
|
|
|
|
// Inserisco le righe
|
|
// Inserisco le righe
|
|
|
$tot = 0;
|
|
$tot = 0;
|
|
|
|
|
+ $vat = 0;
|
|
|
foreach($this->rows as $row)
|
|
foreach($this->rows as $row)
|
|
|
{
|
|
{
|
|
|
foreach($row["when"] as $x => $y)
|
|
foreach($row["when"] as $x => $y)
|
|
@@ -467,10 +478,12 @@ class RecordIN extends Component
|
|
|
'causal_id' => $row["causal_id"],
|
|
'causal_id' => $row["causal_id"],
|
|
|
'note' => $row["note"],
|
|
'note' => $row["note"],
|
|
|
'amount' => $this->currencyToDouble($row["amount"]),
|
|
'amount' => $this->currencyToDouble($row["amount"]),
|
|
|
|
|
+ 'vat_id' => $row["vat_id"],
|
|
|
'commercial' => $row["commercial"],
|
|
'commercial' => $row["commercial"],
|
|
|
'when' => json_encode($row["when"])
|
|
'when' => json_encode($row["when"])
|
|
|
]);
|
|
]);
|
|
|
$tot += $this->currencyToDouble($row["amount"]);
|
|
$tot += $this->currencyToDouble($row["amount"]);
|
|
|
|
|
+ $vat += getVatValue($this->currencyToDouble($row["amount"]), $row["vat_id"]);
|
|
|
}
|
|
}
|
|
|
$record->amount = $tot;
|
|
$record->amount = $tot;
|
|
|
$record->save();
|
|
$record->save();
|
|
@@ -512,23 +525,18 @@ class RecordIN extends Component
|
|
|
} else {
|
|
} else {
|
|
|
$this->member_id = $record->member_id;
|
|
$this->member_id = $record->member_id;
|
|
|
$this->supplier_id = $record->supplier_id;
|
|
$this->supplier_id = $record->supplier_id;
|
|
|
- // $this->causal_id = $record->causal_id;
|
|
|
|
|
$this->payment_method_id = $record->payment_method_id;
|
|
$this->payment_method_id = $record->payment_method_id;
|
|
|
$this->date = date("Y-m-d", strtotime($record->date));
|
|
$this->date = date("Y-m-d", strtotime($record->date));
|
|
|
- // $this->month = $record->month;
|
|
|
|
|
- // $this->year = $record->year;
|
|
|
|
|
- // $this->note = $record->note;
|
|
|
|
|
$this->type = $record->type;
|
|
$this->type = $record->type;
|
|
|
- // $this->amount = formatPrice($record->amount);
|
|
|
|
|
- // $this->commercial = $record->commercial;
|
|
|
|
|
$this->dataId = $record->id;
|
|
$this->dataId = $record->id;
|
|
|
$this->update = true;
|
|
$this->update = true;
|
|
|
$this->add = false;
|
|
$this->add = false;
|
|
|
|
|
|
|
|
- $this->rows = \App\Models\RecordRow::where('record_id', $this->dataId)->select('causal_id', 'note', 'commercial', 'when', 'amount')->get()->toArray();
|
|
|
|
|
|
|
+ $this->rows = \App\Models\RecordRow::where('record_id', $this->dataId)->select('causal_id', 'note', 'commercial', 'when', 'amount', 'vat_id')->get()->toArray();
|
|
|
foreach($this->rows as $i => $r)
|
|
foreach($this->rows as $i => $r)
|
|
|
{
|
|
{
|
|
|
$this->rows[$i]['amount'] = formatPrice($this->rows[$i]['amount']);
|
|
$this->rows[$i]['amount'] = formatPrice($this->rows[$i]['amount']);
|
|
|
|
|
+ $this->rows[$i]['vat_id'] = $this->rows[$i]['vat_id'];
|
|
|
$this->rows[$i]['when'] = json_decode($this->rows[$i]['when']);
|
|
$this->rows[$i]['when'] = json_decode($this->rows[$i]['when']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -553,7 +561,7 @@ class RecordIN extends Component
|
|
|
$f = false;
|
|
$f = false;
|
|
|
foreach($this->rows as $row)
|
|
foreach($this->rows as $row)
|
|
|
{
|
|
{
|
|
|
- if (!$row["commercial"]) $f = true;
|
|
|
|
|
|
|
+ if ($row["commercial"]) $f = true;
|
|
|
}
|
|
}
|
|
|
if ($f)
|
|
if ($f)
|
|
|
$rules["member_id"] = 'required';
|
|
$rules["member_id"] = 'required';
|
|
@@ -565,18 +573,13 @@ class RecordIN extends Component
|
|
|
\App\Models\Record::whereId($this->dataId)->update([
|
|
\App\Models\Record::whereId($this->dataId)->update([
|
|
|
'member_id' => $this->member_id,
|
|
'member_id' => $this->member_id,
|
|
|
'supplier_id' => $this->supplier_id,
|
|
'supplier_id' => $this->supplier_id,
|
|
|
- // 'causal_id' => $this->causal_id,
|
|
|
|
|
'payment_method_id' => $this->payment_method_id,
|
|
'payment_method_id' => $this->payment_method_id,
|
|
|
'date' => date("Y-m-d", strtotime($this->date)),
|
|
'date' => date("Y-m-d", strtotime($this->date)),
|
|
|
- // 'month' => $this->month,
|
|
|
|
|
- // 'year' => $this->year,
|
|
|
|
|
- // 'note' => $this->note,
|
|
|
|
|
'type' => $this->type,
|
|
'type' => $this->type,
|
|
|
- // 'amount' => $this->currencyToDouble($this->amount),
|
|
|
|
|
- //'commercial' => $this->commercial,
|
|
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
$tot = 0;
|
|
$tot = 0;
|
|
|
|
|
+ $vat = 0;
|
|
|
// Elimino le righe
|
|
// Elimino le righe
|
|
|
\App\Models\RecordRow::where('record_id', $this->dataId)->delete();
|
|
\App\Models\RecordRow::where('record_id', $this->dataId)->delete();
|
|
|
// Inserisco le righe
|
|
// Inserisco le righe
|
|
@@ -590,11 +593,13 @@ class RecordIN extends Component
|
|
|
'record_id' => $this->dataId,
|
|
'record_id' => $this->dataId,
|
|
|
'causal_id' => $row["causal_id"],
|
|
'causal_id' => $row["causal_id"],
|
|
|
'note' => $row["note"],
|
|
'note' => $row["note"],
|
|
|
|
|
+ 'vat_id' => $row["vat_id"],
|
|
|
'amount' => $this->currencyToDouble($row["amount"]),
|
|
'amount' => $this->currencyToDouble($row["amount"]),
|
|
|
'commercial' => $row["commercial"],
|
|
'commercial' => $row["commercial"],
|
|
|
'when' => json_encode($row["when"])
|
|
'when' => json_encode($row["when"])
|
|
|
]);
|
|
]);
|
|
|
$tot += $this->currencyToDouble($row["amount"]);
|
|
$tot += $this->currencyToDouble($row["amount"]);
|
|
|
|
|
+ $vat += getVatValue($this->currencyToDouble($row["amount"]), $row["vat_id"]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$rec = \App\Models\Record::findOrFail($this->dataId);
|
|
$rec = \App\Models\Record::findOrFail($this->dataId);
|
|
@@ -727,15 +732,11 @@ class RecordIN extends Component
|
|
|
'record_id' => $this->dataId,
|
|
'record_id' => $this->dataId,
|
|
|
'member_id' => $this->member_id,
|
|
'member_id' => $this->member_id,
|
|
|
'supplier_id' => $this->supplier_id,
|
|
'supplier_id' => $this->supplier_id,
|
|
|
- //'causal_id' => $this->causal_id,
|
|
|
|
|
'payment_method_id' => $this->payment_method_id,
|
|
'payment_method_id' => $this->payment_method_id,
|
|
|
'number' => $number,
|
|
'number' => $number,
|
|
|
'date' => $this->date,
|
|
'date' => $this->date,
|
|
|
- //'month' => $this->month,
|
|
|
|
|
'year' => date("Y"),
|
|
'year' => date("Y"),
|
|
|
'type' => $this->type,
|
|
'type' => $this->type,
|
|
|
- //'amount' => $this->currencyToDouble($this->amount),
|
|
|
|
|
- //'commercial' => $this->commercial,
|
|
|
|
|
'status' => 1,
|
|
'status' => 1,
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
@@ -745,6 +746,7 @@ class RecordIN extends Component
|
|
|
'receip_id' => $receipt->id,
|
|
'receip_id' => $receipt->id,
|
|
|
'causal_id' => $row["causal_id"],
|
|
'causal_id' => $row["causal_id"],
|
|
|
'note' => $row["note"],
|
|
'note' => $row["note"],
|
|
|
|
|
+ 'vat_id' => $row["vat_id"],
|
|
|
'amount' => $this->currencyToDouble($row["amount"]),
|
|
'amount' => $this->currencyToDouble($row["amount"]),
|
|
|
'commercial' => $row["commercial"],
|
|
'commercial' => $row["commercial"],
|
|
|
'when' => json_encode($row["when"])
|
|
'when' => json_encode($row["when"])
|
|
@@ -777,7 +779,7 @@ class RecordIN extends Component
|
|
|
|
|
|
|
|
public function addRow()
|
|
public function addRow()
|
|
|
{
|
|
{
|
|
|
- $this->rows[] = array('causal_id' => null, 'when' => array(array('month' => date("n"), 'year' => date("Y"), 'period' => '')), 'amount' => null, 'note' => '', 'commercial' => 0);
|
|
|
|
|
|
|
+ $this->rows[] = array('causal_id' => null, 'when' => array(array('month' => date("n"), 'year' => date("Y"), 'period' => '')), 'amount' => null, 'vat_id' => null, 'note' => '', 'commercial' => 0);
|
|
|
$this->emit('load-select');
|
|
$this->emit('load-select');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -789,7 +791,9 @@ class RecordIN extends Component
|
|
|
|
|
|
|
|
public function addPeriod($idx)
|
|
public function addPeriod($idx)
|
|
|
{
|
|
{
|
|
|
- $this->rows[$idx]['when'][] = array('month' => date("n"), 'year' => date("Y"), 'period' => '');
|
|
|
|
|
|
|
+ $x = sizeof($this->rows[$idx]['when']) - 1;
|
|
|
|
|
+ $newDate = \Carbon\Carbon::create($this->rows[$idx]['when'][$x]["year"] . "-" . $this->rows[$idx]['when'][$x]["month"] . '-01')->addMonth();
|
|
|
|
|
+ $this->rows[$idx]['when'][] = array('month' => $newDate->format("n"), 'year' => $newDate->format("Y"), 'period' => '');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function delPeriod($idx, $xxx)
|
|
public function delPeriod($idx, $xxx)
|
|
@@ -799,6 +803,22 @@ class RecordIN extends Component
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function getTotal()
|
|
public function getTotal()
|
|
|
|
|
+ {
|
|
|
|
|
+ $total = 0.00;
|
|
|
|
|
+ foreach($this->rows as $r)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($r["amount"] != null && $r["amount"] != "")
|
|
|
|
|
+ {
|
|
|
|
|
+ $total += $this->currencyToDouble($r["amount"]);
|
|
|
|
|
+ if ($r["vat_id"] > 0)
|
|
|
|
|
+ $total += getVatValue($this->currencyToDouble($r["amount"]), $r["vat_id"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return formatPrice($total);
|
|
|
|
|
+ // $this->emit('load-select');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getPrice()
|
|
|
{
|
|
{
|
|
|
$total = 0.00;
|
|
$total = 0.00;
|
|
|
foreach($this->rows as $r)
|
|
foreach($this->rows as $r)
|
|
@@ -810,6 +830,18 @@ class RecordIN extends Component
|
|
|
// $this->emit('load-select');
|
|
// $this->emit('load-select');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function getVat()
|
|
|
|
|
+ {
|
|
|
|
|
+ $total = 0.00;
|
|
|
|
|
+ foreach($this->rows as $r)
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($r["amount"] != null && $r["amount"] != "" && $r["vat_id"] > 0)
|
|
|
|
|
+ $total += getVatValue($this->currencyToDouble($r["amount"]), $r["vat_id"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ return formatPrice($total);
|
|
|
|
|
+ // $this->emit('load-select');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function setCausal($id, $idx)
|
|
public function setCausal($id, $idx)
|
|
|
{
|
|
{
|
|
|
$this->rows[$idx]["causal_id"] = $id;
|
|
$this->rows[$idx]["causal_id"] = $id;
|
|
@@ -828,32 +860,23 @@ class RecordIN extends Component
|
|
|
}, 'test.pdf');*/
|
|
}, 'test.pdf');*/
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ public function multiPeriod()
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->multiP = true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
-/*
|
|
|
|
|
-<!--<table width="100%" cellpadding="7">
|
|
|
|
|
- <tr>
|
|
|
|
|
- <td><b>Cliente</b></td>
|
|
|
|
|
- <td><b>Data/ora ingresso</b></td>
|
|
|
|
|
- <td><b>Data/ora uscita</b></td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- @foreach ($datas as $data)
|
|
|
|
|
- <tr>
|
|
|
|
|
- <td>{{ $data["cliente"] }}</td>
|
|
|
|
|
- <td>
|
|
|
|
|
- @if($data["ingresso"] != '')
|
|
|
|
|
- <span style="color:green">{{ date("d/m/Y H:i:s", strtotime($data["ingresso"])) }}</span>
|
|
|
|
|
- @endif
|
|
|
|
|
- </td>
|
|
|
|
|
- <td>
|
|
|
|
|
- @if($data["uscita"] != '')
|
|
|
|
|
- <span style="color:red">{{ date("d/m/Y H:i:s", strtotime($data["uscita"])) }}</span>
|
|
|
|
|
- @endif
|
|
|
|
|
- </td>
|
|
|
|
|
- </tr>
|
|
|
|
|
- @endforeach
|
|
|
|
|
- </table>-->
|
|
|
|
|
- <footer>
|
|
|
|
|
- <small>{{date("d/m/Y H:i:s")}}</small>
|
|
|
|
|
- </footer>
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ public function multiPeriodCreate($idx)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ $period = \Carbon\CarbonPeriod::create($this->multiYearFrom . '-' . $this->multiMonthFrom . '-01', '1 month', $this->multiYearTo . '-' . $this->multiMonthTo . '-01');
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($period as $dt) {
|
|
|
|
|
+ if (!in_array(array('month' => $dt->format("n"), 'year' => $dt->format("Y"), 'period' => ''), $this->rows[$idx]['when']))
|
|
|
|
|
+ $this->rows[$idx]['when'][] = array('month' => $dt->format("n"), 'year' => $dt->format("Y"), 'period' => '');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $this->multiP = false;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|