public function validate_cuit() { if (!empty($this->data['Proveedor']['cuit'])) { return validate_cuit_cuil($this->data['Proveedor']['cuit']); } return true; }
private function getProveedorFromFieldData() { if (!empty($this->data['Gasto']['proveedor_list'])) { $cuit = null; $name = trim($this->data['Gasto']['proveedor_list']); if (preg_match_all('/(?:\\s|^)(\\d{11}|\\d{2}-\\d{8}-\\d{1})(?:\\s|$)/', $this->data['Gasto']['proveedor_list'], $m)) { // sacar guion del cuit $cuit = trim(str_replace("-", "", $m[1][0])); // sacar el cuit al string $name = trim(str_replace($cuit, '', $this->data['Gasto']['proveedor_list'])); if (!empty($cuit) && !validate_cuit_cuil($cuit)) { $cuit = null; $name .= ' [CUIT ERROR: ' . $cuit . '?, por favor resolver editando a mano]'; } elseif (empty($cuit)) { $cuit = null; } } $data = array('Proveedor' => array('cuit' => $cuit, 'name' => $name)); return $data; } return false; }