@@ -24,7 +24,7 @@ |
||
| 24 | 24 | ]); |
| 25 | 25 | $metadata->addPropertyConstraints('serie', [ |
| 26 | 26 | new Assert\NotBlank(), |
| 27 | - new Assert\Length([ 'max' => 4]), |
|
| 27 | + new Assert\Length(['max' => 4]), |
|
| 28 | 28 | ]); |
| 29 | 29 | $metadata->addPropertyConstraints('correlativo', [ |
| 30 | 30 | new Assert\NotBlank(), |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | ]); |
| 29 | 29 | $metadata->addPropertyConstraints('serie', [ |
| 30 | 30 | new Assert\NotBlank(), |
| 31 | - new Assert\Length([ 'max' => 4]), |
|
| 31 | + new Assert\Length(['max' => 4]), |
|
| 32 | 32 | ]); |
| 33 | 33 | $metadata->addPropertyConstraints('correlativo', [ |
| 34 | 34 | new Assert\NotBlank(), |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | ]); |
| 68 | 68 | $metadata->addPropertyConstraints('desMotivo', [ |
| 69 | 69 | new Assert\NotBlank(), |
| 70 | - new Assert\Length([ 'max' => 250]), |
|
| 70 | + new Assert\Length(['max' => 250]), |
|
| 71 | 71 | ]); |
| 72 | 72 | $metadata->addPropertyConstraints('tipDocAfectado', [ |
| 73 | 73 | new Assert\NotBlank(), |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | ]); |
| 79 | 79 | $metadata->addPropertyConstraints('numDocfectado', [ |
| 80 | 80 | new Assert\NotBlank(), |
| 81 | - new Assert\Length([ 'max' => 13]), |
|
| 81 | + new Assert\Length(['max' => 13]), |
|
| 82 | 82 | ]); |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | \ No newline at end of file |
@@ -24,6 +24,10 @@ discard block |
||
| 24 | 24 | const PRODUCCION = 'https://e-factura.sunat.gob.pe/ol-ti-itcpfegem/billService'; |
| 25 | 25 | const WSDL_ENDPOINT = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl'; |
| 26 | 26 | |
| 27 | + /** |
|
| 28 | + * @param string $user |
|
| 29 | + * @param string $password |
|
| 30 | + */ |
|
| 27 | 31 | public function __construct($user, $password) |
| 28 | 32 | { |
| 29 | 33 | parent::__construct($user, $password); |
@@ -32,7 +36,7 @@ discard block |
||
| 32 | 36 | |
| 33 | 37 | /** |
| 34 | 38 | * @param $filename |
| 35 | - * @param $content |
|
| 39 | + * @param string $content |
|
| 36 | 40 | * @return BillResult |
| 37 | 41 | */ |
| 38 | 42 | public function send($filename, $content) |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | 'fileName' => $filename, |
| 48 | 48 | 'contentFile' => $content, |
| 49 | 49 | ]; |
| 50 | - $response = $client->__soapCall('sendBill', [ 'parameters' => $params ]); |
|
| 50 | + $response = $client->__soapCall('sendBill', ['parameters' => $params]); |
|
| 51 | 51 | |
| 52 | 52 | $cdrZip = $response->applicationResponse; |
| 53 | 53 | $result |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 'fileName' => $filename, |
| 78 | 78 | 'contentFile' => $content, |
| 79 | 79 | ]; |
| 80 | - $response = $client->__soapCall('sendSummary', [ 'parameters' => $params ]); |
|
| 80 | + $response = $client->__soapCall('sendSummary', ['parameters' => $params]); |
|
| 81 | 81 | $result |
| 82 | 82 | ->setTicket($response->ticket) |
| 83 | 83 | ->setSuccess(true); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $params = [ |
| 102 | 102 | 'ticket' => $ticket, |
| 103 | 103 | ]; |
| 104 | - $response = $client->__soapCall('getStatus', [ 'parameters' => $params ]); |
|
| 104 | + $response = $client->__soapCall('getStatus', ['parameters' => $params]); |
|
| 105 | 105 | $status = $response->statusResponse; |
| 106 | 106 | $cdrZip = $status->content; |
| 107 | 107 | |
@@ -54,8 +54,7 @@ discard block |
||
| 54 | 54 | ->setCdrResponse($this->extractResponse($cdrZip)) |
| 55 | 55 | ->setCdrZip($cdrZip) |
| 56 | 56 | ->setSuccess(true); |
| 57 | - } |
|
| 58 | - catch (\SoapFault $e) { |
|
| 57 | + } catch (\SoapFault $e) { |
|
| 59 | 58 | $result->setError($this->getErrorFromFault($e)); |
| 60 | 59 | } |
| 61 | 60 | |
@@ -81,8 +80,7 @@ discard block |
||
| 81 | 80 | $result |
| 82 | 81 | ->setTicket($response->ticket) |
| 83 | 82 | ->setSuccess(true); |
| 84 | - } |
|
| 85 | - catch (\SoapFault $e) { |
|
| 83 | + } catch (\SoapFault $e) { |
|
| 86 | 84 | $result->setError($this->getErrorFromFault($e)); |
| 87 | 85 | } |
| 88 | 86 | return $result; |
@@ -110,8 +108,7 @@ discard block |
||
| 110 | 108 | ->setCdrResponse($this->extractResponse($cdrZip)) |
| 111 | 109 | ->setCdrZip($cdrZip) |
| 112 | 110 | ->setSuccess(true); |
| 113 | - } |
|
| 114 | - catch (\SoapFault $e) { |
|
| 111 | + } catch (\SoapFault $e) { |
|
| 115 | 112 | $result->setError($this->getErrorFromFault($e)); |
| 116 | 113 | } |
| 117 | 114 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function decompress($zipContent, $fileToExtract) |
| 42 | 42 | { |
| 43 | - $temp = tempnam(sys_get_temp_dir(),time() . '.zip'); |
|
| 43 | + $temp = tempnam(sys_get_temp_dir(), time() . '.zip'); |
|
| 44 | 44 | file_put_contents($temp, $zipContent); |
| 45 | 45 | $zip = new ZipArchive; |
| 46 | 46 | $output = ""; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function decompressLastFile($zipContent) |
| 63 | 63 | { |
| 64 | - $temp = tempnam(sys_get_temp_dir(),time() . '.zip'); |
|
| 64 | + $temp = tempnam(sys_get_temp_dir(), time() . '.zip'); |
|
| 65 | 65 | file_put_contents($temp, $zipContent); |
| 66 | 66 | $zip = new ZipArchive; |
| 67 | 67 | $output = ""; |
@@ -101,21 +101,21 @@ discard block |
||
| 101 | 101 | $name = str_replace('\\', '/', $name); |
| 102 | 102 | $hexdtime = pack('V', $this->unix2DosTime($time)); |
| 103 | 103 | $frd = "\x50\x4b\x03\x04"; |
| 104 | - $frd .= "\x14\x00"; // ver needed to extract |
|
| 105 | - $frd .= "\x00\x00"; // gen purpose bit flag |
|
| 106 | - $frd .= "\x08\x00"; // compression method |
|
| 107 | - $frd .= $hexdtime; // last mod time and date |
|
| 104 | + $frd .= "\x14\x00"; // ver needed to extract |
|
| 105 | + $frd .= "\x00\x00"; // gen purpose bit flag |
|
| 106 | + $frd .= "\x08\x00"; // compression method |
|
| 107 | + $frd .= $hexdtime; // last mod time and date |
|
| 108 | 108 | // "local file header" segment |
| 109 | 109 | $unc_len = strlen($data); |
| 110 | 110 | $crc = crc32($data); |
| 111 | 111 | $zdata = gzcompress($data); |
| 112 | 112 | $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug |
| 113 | 113 | $c_len = strlen($zdata); |
| 114 | - $frd .= pack('V', $crc); // crc32 |
|
| 115 | - $frd .= pack('V', $c_len); // compressed filesize |
|
| 116 | - $frd .= pack('V', $unc_len); // uncompressed filesize |
|
| 117 | - $frd .= pack('v', strlen($name)); // length of filename |
|
| 118 | - $frd .= pack('v', 0); // extra field length |
|
| 114 | + $frd .= pack('V', $crc); // crc32 |
|
| 115 | + $frd .= pack('V', $c_len); // compressed filesize |
|
| 116 | + $frd .= pack('V', $unc_len); // uncompressed filesize |
|
| 117 | + $frd .= pack('v', strlen($name)); // length of filename |
|
| 118 | + $frd .= pack('v', 0); // extra field length |
|
| 119 | 119 | $frd .= $name; |
| 120 | 120 | // "file data" segment |
| 121 | 121 | $frd .= $zdata; |
@@ -125,20 +125,20 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | // now add to central directory record |
| 127 | 127 | $cdrec = "\x50\x4b\x01\x02"; |
| 128 | - $cdrec .= "\x00\x00"; // version made by |
|
| 129 | - $cdrec .= "\x14\x00"; // version needed to extract |
|
| 130 | - $cdrec .= "\x00\x00"; // gen purpose bit flag |
|
| 131 | - $cdrec .= "\x08\x00"; // compression method |
|
| 132 | - $cdrec .= $hexdtime; // last mod time & date |
|
| 133 | - $cdrec .= pack('V', $crc); // crc32 |
|
| 134 | - $cdrec .= pack('V', $c_len); // compressed filesize |
|
| 135 | - $cdrec .= pack('V', $unc_len); // uncompressed filesize |
|
| 128 | + $cdrec .= "\x00\x00"; // version made by |
|
| 129 | + $cdrec .= "\x14\x00"; // version needed to extract |
|
| 130 | + $cdrec .= "\x00\x00"; // gen purpose bit flag |
|
| 131 | + $cdrec .= "\x08\x00"; // compression method |
|
| 132 | + $cdrec .= $hexdtime; // last mod time & date |
|
| 133 | + $cdrec .= pack('V', $crc); // crc32 |
|
| 134 | + $cdrec .= pack('V', $c_len); // compressed filesize |
|
| 135 | + $cdrec .= pack('V', $unc_len); // uncompressed filesize |
|
| 136 | 136 | $cdrec .= pack('v', strlen($name)); // length of filename |
| 137 | - $cdrec .= pack('v', 0); // extra field length |
|
| 138 | - $cdrec .= pack('v', 0); // file comment length |
|
| 139 | - $cdrec .= pack('v', 0); // disk number start |
|
| 140 | - $cdrec .= pack('v', 0); // internal file attributes |
|
| 141 | - $cdrec .= pack('V', 32); // external file attributes |
|
| 137 | + $cdrec .= pack('v', 0); // extra field length |
|
| 138 | + $cdrec .= pack('v', 0); // file comment length |
|
| 139 | + $cdrec .= pack('v', 0); // disk number start |
|
| 140 | + $cdrec .= pack('v', 0); // internal file attributes |
|
| 141 | + $cdrec .= pack('V', 32); // external file attributes |
|
| 142 | 142 | // - 'archive' bit set |
| 143 | 143 | $cdrec .= pack('V', $this->old_offset); // relative offset of local header |
| 144 | 144 | $this->old_offset += strlen($frd); |
@@ -158,21 +158,21 @@ discard block |
||
| 158 | 158 | public function file() |
| 159 | 159 | { |
| 160 | 160 | $ctrldir = implode('', $this->ctrl_dir); |
| 161 | - $header = $ctrldir. |
|
| 162 | - $this->eof_ctrl_dir. |
|
| 163 | - pack('v', sizeof($this->ctrl_dir)). //total #of entries "on this disk" |
|
| 164 | - pack('v', sizeof($this->ctrl_dir)). //total #of entries overall |
|
| 165 | - pack('V', strlen($ctrldir)). //size of central dir |
|
| 166 | - pack('V', $this->old_offset). //offset to start of central dir |
|
| 167 | - "\x00\x00"; //.zip file comment length |
|
| 161 | + $header = $ctrldir . |
|
| 162 | + $this->eof_ctrl_dir . |
|
| 163 | + pack('v', sizeof($this->ctrl_dir)) . //total #of entries "on this disk" |
|
| 164 | + pack('v', sizeof($this->ctrl_dir)) . //total #of entries overall |
|
| 165 | + pack('V', strlen($ctrldir)) . //size of central dir |
|
| 166 | + pack('V', $this->old_offset) . //offset to start of central dir |
|
| 167 | + "\x00\x00"; //.zip file comment length |
|
| 168 | 168 | if ($this->doWrite) { // Send central directory & end ctrl dir to STDOUT |
| 169 | - return ''; // Return empty string |
|
| 169 | + return ''; // Return empty string |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | // Return entire ZIP archive as string |
| 173 | 173 | $data = implode('', $this->datasec); |
| 174 | 174 | |
| 175 | - return $data.$header; |
|
| 175 | + return $data . $header; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // end of the 'file()' method |
@@ -69,9 +69,9 @@ |
||
| 69 | 69 | $obj = $resp[0]; |
| 70 | 70 | |
| 71 | 71 | $cdr = new CdrResponse(); |
| 72 | - $cdr->setId($this->getValueByName($obj,'ReferenceID')) |
|
| 73 | - ->setCode($this->getValueByName($obj,'ResponseCode')) |
|
| 74 | - ->setDescription($this->getValueByName($obj,'Description')); |
|
| 72 | + $cdr->setId($this->getValueByName($obj, 'ReferenceID')) |
|
| 73 | + ->setCode($this->getValueByName($obj, 'ResponseCode')) |
|
| 74 | + ->setDescription($this->getValueByName($obj, 'Description')); |
|
| 75 | 75 | |
| 76 | 76 | return $cdr; |
| 77 | 77 | } |