mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado
This commit is contained in:
@ -234,6 +234,13 @@ class Facturas extends \App\Controllers\BaseResourceController
|
||||
$factura->showDeleteButton = model('App\Models\Facturas\FacturaPagoModel')
|
||||
->where('factura_id', $factura->id)->countAllResults() == 0;
|
||||
|
||||
if($factura->numero != null && $factura->numero != '' && strpos($factura->numero, "REC ") === 0) {
|
||||
$modelPagos = model('App\Models\Facturas\FacturaPagoModel');
|
||||
if($modelPagos->where('factura_id', $factura->id)->countAllResults() > 0) {
|
||||
$factura->facturaRectificativaPagada = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->viewData['facturaEntity'] = $factura;
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Facturas.factura') . ' ' . lang('Basic.global.edit3');
|
||||
@ -831,11 +838,6 @@ class Facturas extends \App\Controllers\BaseResourceController
|
||||
'user_updated_id' => auth()->user()->id,
|
||||
];
|
||||
|
||||
if ((strpos($numero, "REC ") === 0)) {
|
||||
$data['estado_pago'] = 'pagada';
|
||||
|
||||
}
|
||||
|
||||
$this->model->update($factura_id, $data);
|
||||
|
||||
if ((strpos($numero, "REC ") === 0)) {
|
||||
|
||||
@ -136,4 +136,36 @@ class FacturasPagos extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function addPagoRectificativa()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$data['factura_id'] = $this->request->getPost('factura_id');
|
||||
$data['fecha_vencimiento_at'] = $this->request->getPost('fecha');
|
||||
$data['total'] = $this->request->getPost('total');
|
||||
$data['user_updated_id'] = auth()->user()->id;
|
||||
$data['forma_pago_id'] = 6; // compensada
|
||||
|
||||
if($data['fecha_vencimiento_at'] != null && $data['fecha_vencimiento_at'] != '') {
|
||||
$data['fecha_vencimiento_at'] = date('Y-m-d H:i:s', strtotime($data['fecha_vencimiento_at']));
|
||||
}
|
||||
|
||||
$model = new FacturaPagoModel();
|
||||
$model->insert($data);
|
||||
|
||||
$modelFactura = model('App\Models\Facturas\FacturaModel');
|
||||
$modelFactura->update($data['factura_id'], [
|
||||
'estado_pago' => 'pagada',
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
'user_updated_id' => auth()->user()->id,
|
||||
]);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => true,
|
||||
'message' => lang('Facturas.facturaConformada'),
|
||||
]);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user