3 Commits

Author SHA1 Message Date
ce9078328a FIX: Validacion de RUT 2025-01-08 14:53:49 -03:00
713fcc6ab8 FIX: Rut retornado al agregar nuevo propietario 2025-01-08 14:53:22 -03:00
dfbfbd2908 FIX: Depreciado 2025-01-07 22:13:41 -03:00
3 changed files with 13 additions and 18 deletions

View File

@ -186,7 +186,7 @@
}
clean() {
return {
rut: rut => rut.includes('-') ? rut.split('-').join('') : rut
rut: rut => rut.includes('-') || rut.includes('.') ? rut.replaceAll('-', '').replaceAll('.', '') : rut
}
}
get() {
@ -200,29 +200,23 @@
verifier: digits => {
let sum = 0
let mul = 2
let i = digits.length
while (i--) {
sum = sum + parseInt(digits.charAt(i)) * mul
if (mul % 7 === 0) {
mul = 2
} else {
mul++
sum = sum + parseInt(digits.charAt(i)) * mul;
(mul % 7 === 0) ? mul = 2 : mul++
}
}
const res = sum % 11
if (res === 0) {
return '0'
} else if (res === 1) {
return 'k'
}
switch (res) {
case 0:
case 1:
return res.toString()
default:
return `${11 - res}`
}
}
}
}
validate(rut, not_suspicious = true) {
if (!this.is().like(rut) || (not_suspicious && this.is().suspicious(rut))) {
return false
@ -230,6 +224,7 @@
return this.get().verifier(rut).toLowerCase() === this.calculate().verifier(this.get().digits(rut))
}
verify(event) {
this.alert().valid()
const input = $(event.currentTarget)
const val = input.val()
let new_val = this.clean().rut(val)
@ -242,7 +237,6 @@
this.alert().invalid()
return
}
this.alert().valid()
this.valid(new_val)
}
alert() {
@ -799,6 +793,7 @@
button.prop('disabled', true)
button.css('cursor', 'wait')
const body = new FormData(event.currentTarget)
if (body.get('unidad'))
const uri = '{{$urls->api}}/ventas/add'
return fetchAPI(uri, {method: 'post', body}).then(response => {
if (!response) {

View File

@ -64,7 +64,7 @@ class Propietario extends Ideal\Repository
public function save(Define\Model $model): Define\Model
{
$model->rut = $this->saveNew(
$this->saveNew(
['rut', 'dv', 'nombres', 'apellido_paterno', 'apellido_materno', 'direccion', 'otro', 'representante'],
[$model->rut, $model->dv, $model->nombres, $model->apellidos['paterno'], $model->apellidos['materno'], $model->datos->direccion->id, $model->otro->rut ?? 0, $model->contacto->rut ?? 0]
);

View File

@ -160,7 +160,7 @@ class Cartola extends Service
$movimientosFaltantes = $this->movimientoService->findMissing($cuenta, $addedMovimientos, $startDate, $endDate);
$movimientosObsoletos = [];
if (count($movimientosFaltantes) > 0) {
$movimientosObsoletos = array_map(function(&$movimiento) {
$movimientosObsoletos = array_map(function($movimiento) {
$arr = (array) $movimiento;
$arr['sociedad'] = $movimiento->cuenta->inmobiliaria;
$arr['obsoleto'] = true;