Skip to content

Commit

Permalink
send files through xsender
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosthe19916 committed Dec 21, 2023
1 parent 7e3a4b7 commit 11a34a6
Show file tree
Hide file tree
Showing 26 changed files with 2,866 additions and 388 deletions.
1,012 changes: 1,001 additions & 11 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion xsender/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ description = "Sends XML files through SOAP - SUNAT"
[dependencies]
xml = "0.8.10"
log = "0.4.20"
zip = { version = "0.6.6", default-features = false }
zip = { version = "0.6.6" }
tera = "1.19.1"
lazy_static = "1.4.0"
serde = { version = "1.0.193", features = ["derive"] }
reqwest = "0.11.22"
regex = "1.10.2"
base64 = "0.21.5"

[dev-dependencies]
tokio = { version = "1.35.1", features = ["macros"] }
15 changes: 15 additions & 0 deletions xsender/resources/test/R-12345678901-01-F001-00000587.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<ar:ApplicationResponse xmlns:ar="urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><ext:UBLExtensions><ext:UBLExtension><ext:ExtensionContent><Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments"/>
<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"/>
<Reference URI="">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/>
<DigestValue>VKY1IcYW+H/VLoYyShq8xvzea6YGCg6VOR7X4ZeA+hz/z9PZdkDPzN4e83PUOnRoBKnj3DDqZ0N9d6OSWAfaag==</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>*Private key 'BetaPublicCert' not up*</SignatureValue><KeyInfo><X509Data><X509Certificate>*Named certificate 'BetaPrivateKey' not up*</X509Certificate><X509IssuerSerial><X509IssuerName>*Named certificate 'BetaPrivateKey' not up*</X509IssuerName><X509SerialNumber>*Named certificate 'BetaPrivateKey' not up*</X509SerialNumber></X509IssuerSerial></X509Data></KeyInfo></Signature></ext:ExtensionContent></ext:UBLExtension></ext:UBLExtensions><cbc:ID>1537453143191</cbc:ID><cbc:IssueDate>2018-09-20T09:16:25</cbc:IssueDate><cbc:IssueTime>00:00:00</cbc:IssueTime><cbc:ResponseDate>2018-09-20</cbc:ResponseDate><cbc:ResponseTime>10:19:03</cbc:ResponseTime><cac:Signature><cbc:ID>SignSUNAT</cbc:ID><cac:SignatoryParty><cac:PartyIdentification><cbc:ID>20131312955</cbc:ID></cac:PartyIdentification><cac:PartyName><cbc:Name>SUNAT</cbc:Name></cac:PartyName></cac:SignatoryParty><cac:DigitalSignatureAttachment><cac:ExternalReference><cbc:URI>#SignSUNAT</cbc:URI></cac:ExternalReference></cac:DigitalSignatureAttachment></cac:Signature><cac:SenderParty><cac:PartyIdentification><cbc:ID>20131312955</cbc:ID></cac:PartyIdentification></cac:SenderParty><cac:ReceiverParty><cac:PartyIdentification><cbc:ID>12345678901</cbc:ID></cac:PartyIdentification></cac:ReceiverParty><cac:DocumentResponse><cac:Response><cbc:ReferenceID>F001-00000587</cbc:ReferenceID><cbc:ResponseCode>0</cbc:ResponseCode><cbc:Description>La Factura numero F001-00000587, ha sido aceptada</cbc:Description></cac:Response><cac:DocumentReference><cbc:ID>F001-00000587</cbc:ID></cac:DocumentReference><cac:RecipientParty><cac:PartyIdentification><cbc:ID>6-10414774453</cbc:ID></cac:PartyIdentification></cac:RecipientParty></cac:DocumentResponse></ar:ApplicationResponse>
15 changes: 15 additions & 0 deletions xsender/resources/test/R-20220557805-01-F001-22Openubl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<ar:ApplicationResponse xmlns:ar="urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><ext:UBLExtensions><ext:UBLExtension><ext:ExtensionContent><Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments"/>
<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"/>
<Reference URI="">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/>
<DigestValue>S67rWjkW4fu/JwOm8yKOO6A/vc+is7qOkh0SOrOXIvqaPid5hSr09GAV11VDkZn+fd9e3z5RDiJQKu1+8NyhpA==</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>*Private key 'BetaPublicCert' not up*</SignatureValue><KeyInfo><X509Data><X509Certificate>*Named certificate 'BetaPrivateKey' not up*</X509Certificate><X509IssuerSerial><X509IssuerName>*Named certificate 'BetaPrivateKey' not up*</X509IssuerName><X509SerialNumber>*Named certificate 'BetaPrivateKey' not up*</X509SerialNumber></X509IssuerSerial></X509Data></KeyInfo></Signature></ext:ExtensionContent></ext:UBLExtension></ext:UBLExtensions><cbc:ID>1609739749091</cbc:ID><cbc:IssueDate>2021-01-03T23:54:17</cbc:IssueDate><cbc:IssueTime>00:00:00</cbc:IssueTime><cbc:ResponseDate>2021-01-03</cbc:ResponseDate><cbc:ResponseTime>23:55:49</cbc:ResponseTime><cac:Signature><cbc:ID>SignSUNAT</cbc:ID><cac:SignatoryParty><cac:PartyIdentification><cbc:ID>20131312955</cbc:ID></cac:PartyIdentification><cac:PartyName><cbc:Name>SUNAT</cbc:Name></cac:PartyName></cac:SignatoryParty><cac:DigitalSignatureAttachment><cac:ExternalReference><cbc:URI>#SignSUNAT</cbc:URI></cac:ExternalReference></cac:DigitalSignatureAttachment></cac:Signature><cbc:Note>4252 - El dato ingresado como atributo @listName es incorrecto. - INFO: 4252 (nodo: "cbc:InvoiceTypeCode/listName" valor: "SUNAT:Identificador de Tipo de Documento")</cbc:Note><cbc:Note>4255 - El dato ingresado como atributo @schemeName es incorrecto. - INFO: 4255 (nodo: "cbc:ID/schemeName" valor: "SUNAT:Identificador de Documento de Identidad")</cbc:Note><cbc:Note>3030 - El XML no contiene el tag o no existe informaci&#243;n del c&#243;digo de local anexo del emisor - INFO: 3030 (nodo: "/" valor: "")</cbc:Note><cbc:Note>4255 - El dato ingresado como atributo @schemeName es incorrecto. - INFO: 4255 (nodo: "cbc:ID/schemeName" valor: "SUNAT:Identificador de Documento de Identidad")</cbc:Note><cbc:Note>4252 - El dato ingresado como atributo @listName es incorrecto. - Error en la linea: 1: 4252 (nodo: "cbc:PriceTypeCode/listName" valor: "SUNAT:Indicador de Tipo de Precio")</cbc:Note><cbc:Note>4252 - El dato ingresado como atributo @listName es incorrecto. - Error en la linea: 1 Tributo: 1000: 4252 (nodo: "cbc:TaxExemptionReasonCode/listName" valor: "SUNAT:Codigo de Tipo de Afectacion del IGV")</cbc:Note><cbc:Note>4252 - El dato ingresado como atributo @listName es incorrecto. - Error en la linea: 2: 4252 (nodo: "cbc:PriceTypeCode/listName" valor: "SUNAT:Indicador de Tipo de Precio")</cbc:Note><cbc:Note>4252 - El dato ingresado como atributo @listName es incorrecto. - Error en la linea: 2 Tributo: 1000: 4252 (nodo: "cbc:TaxExemptionReasonCode/listName" valor: "SUNAT:Codigo de Tipo de Afectacion del IGV")</cbc:Note><cac:SenderParty><cac:PartyIdentification><cbc:ID>20131312955</cbc:ID></cac:PartyIdentification></cac:SenderParty><cac:ReceiverParty><cac:PartyIdentification><cbc:ID>20220557805</cbc:ID></cac:PartyIdentification></cac:ReceiverParty><cac:DocumentResponse><cac:Response><cbc:ReferenceID>F001-22</cbc:ReferenceID><cbc:ResponseCode>0</cbc:ResponseCode><cbc:Description>La Factura numero F001-22, ha sido aceptada</cbc:Description></cac:Response><cac:DocumentReference><cbc:ID>F001-22</cbc:ID></cac:DocumentReference><cac:RecipientParty><cac:PartyIdentification><cbc:ID>6-20601814120</cbc:ID></cac:PartyIdentification></cac:RecipientParty></cac:DocumentResponse></ar:ApplicationResponse>
10 changes: 10 additions & 0 deletions xsender/resources/test/bill_service_response_fault.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<soap-env:Envelope xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header/>
<soap-env:Body>
<soap-env:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>soap-env:Client.0111</faultcode>
<faultstring>No tiene el perfil para enviar comprobantes electronicos - Detalle: Rejected by policy.</faultstring>
</soap-env:Fault>
</soap-env:Body>
</soap-env:Envelope>
9 changes: 9 additions & 0 deletions xsender/resources/test/bill_service_response_ok.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<soap-env:Header/>
<soap-env:Body>
<br:sendBillResponse xmlns:br="http://service.sunat.gob.pe">
<applicationResponse>UEsDBBQAAgAIAEwklVcAAAAAAgAAAAAAAAAGAAAAZHVtbXkvAwBQSwMEFAACAAgATCSVVwwGkuIxBAAAGQ0AABsAAABSLTEyMzQ1Njc4OTEyLTAxLUYwMDEtMS54bWy1V2FP2zwQ/r5fEZUPk6Y3OElbWKPQqVDGsgFitDC0byY52uhN7WA7peXXv+e4SdMStHbSq/LBuXvuubvHZ1sEXxaz1JqDkAlnJy330GlZwCIeJ2xy0robf7U/t770PwRU+IMsS5OIKgTegsw4k2BhMJMnrVwwn1OZSJ/RGUhfZhAlTyuwnz+mvoymMKP+QsZ+yOY8icD2Wibcp2JPhoZK1mywUHvSnfHZjLPzhQKmVcBPpASm5Jo0eoz+ivQU4VEjIf07wsFkImBCFTSRxrgVU6Uyn5CXl5fDl/YhFxPiOY5DnB5BTCyTyUGJlpxmFd4kkofo0vYiUC8IsDmkPANSJcHkVRgsZKoKsDZLm7LYVgn2UiUp+5Q5o+rdPjMQeb3ZkUY39eqWxIv3enXJw9XlqKAqscgCi6yhaHTkKRU2egVIvfmy1Q9wgvy708tqIGQ55g0+Y6nNDsOV6gejZIId5KI6IjvsCx4zHQZxyJ54/4NlBWeUcYY6pclrodUVqCmPrUE64SJR09m7EriOpsW+IjtyO+zgF6L1AGkNW6TgrircmdTplLXaMy7gQEhqyyntut6K8haeQODtAdbdbajlQiOax4Iy+cTFTBpD3fTHtBsSlcMY27Ks3qTek3QXgZCQbFceDJMJSLWnYqjIQV2niueepjn0H16PRPsBEvXt+ntGw3m4hMvrQXZ+OoB0zKYv98+/w2V4/hS/dm/uur+PB/C8OLvoEX41ypxzGf5KLn9cPF9E38/vczn8OVVikRz9PDkJSD2L3h9SbRCOGtmctfpEmIhPNyKZ4+mz/oWl9fEUFL3Bo4rXGQj10WJcWXn2ydDUooIfsCw4g4eu0xtSRc1KR5kzj8zXeA3EVrQ2rfhNQmSo8W8HF2yhlDmIEYiEpnWLJt6fvhZbcBne63z2CGJ/to3oeoKyXLJWhlRqrXXEdfOdQt5ePm9Msh/gW6VN9+ZND4d979AJyBtrgTvLpeKz1e2CRreEbjsKtAYcO20XJ/mo2z72DLTy6iaHeos8x+3Zrmd7nbHj+MXfClpB1hFjfC76DbDCXsDKN37F7bULbtdgN5wbcEPc8dsd3+tuglfcNPJrqq960ZbR3fVgXOuuAnKxvKFCLY2tWIYxbk71mlU0qEEbf16v210TkfejSoeZQh1QrGqVGA/ZQpL3isPDnyiaVg0OlKLRdFZMkvbrkRGMpus7wUzObdg/2NJA20yihiDyp2RkW2f9CSwG8f9ISRoT3EIEyXznnK7X7nSPjj/3XG/nnA0phjzKtQrl4JW1VF/FUK60xBRf8dWwq8le2zcG+4zHONibE13YCtQQZCSSrKjrklpfaYSyU4thHYJbJsE/1pRaMom5RSPIFI2pYavHlj3VC1+3szEzW4VXUjXBjU5JlqB9x704wvNe/fbZjY0spHk/SPN/Nv3/AFBLAQIAABQAAgAIAEwklVcAAAAAAgAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAABkdW1teS9QSwECAAAUAAIACABMJJVXDAaS4jEEAAAZDQAAGwAAAAAAAAABAAAAAAAmAAAAUi0xMjM0NTY3ODkxMi0wMS1GMDAxLTEueG1sUEsFBgAAAAACAAIAfQAAAJAEAAAAAA==</applicationResponse>
</br:sendBillResponse>
</soap-env:Body>
</soap-env:Envelope>
8 changes: 8 additions & 0 deletions xsender/resources/test/bill_service_response_ticket.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<soap-env:Header/>
<soap-env:Body>
<br:sendSummaryResponse xmlns:br="http://service.sunat.gob.pe">
<ticket>1703154974517</ticket>
</br:sendSummaryResponse>
</soap-env:Body>
</soap-env:Envelope>
11 changes: 11 additions & 0 deletions xsender/resources/test/get_status_response_ok.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getStatusResponse xmlns:ns2="http://service.sunat.gob.pe">
<status>
<content>UEsDBBQAAgAIAK07lVcAAAAAAgAAAAAAAAAGAAAAZHVtbXkvAwBQSwMEFAACAAgArTuVV2PumuIyBAAACA0AAB8AAABSLTEyMzQ1Njc4OTEyLVJBLTIwMjAwMzI4LTEueG1stVdRT+M4EH7fXxGVh5X2LjhJoYUoZFUo3FULPba0gPbNJEMbLrFzttMWfv2OkyZNS9C2K53gwZn55puZz2MbvK/LJDbmIGTE2VnLPrRaBrCAhxGbnrUm4yvzpPXV/+RR4fbSNI4CqhA4AplyJsHAYCbPWplgLqcyki6jCUhXphBEzyuwmz3FrgxmkFB3KUN3wOY8CsB0WkW4S8WeDA2VrNlgqfaku+BJwtnlUgHTKuAnUgJTck0aPAW/RXqO8KCRkP4eYW86FTClCppIQ9yKmVKpS8hisThctA+5mBLHsixinRLEhDKaHpRoyWla4YtE8hBd2p4H6gUBNoeYp0CqJJi8CoOljFUO1mZpUhaaKsJeqiRlnzJjVH3YZwoiqzd7p9FNvdol8fKjXm3yeHN9l1OVWGSBZdpQNDqymAoTvQKk3nzZ8j2cIHdyfl0NhCzHvMFXWGqzw3ClfO8ummIHmaiOyA77gsdMh0E4YM/c/2QY3gVlnKFOcfSWa3UDasZDoxdPuYjULPl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AACAAIAgQAAAJUEAAAAAA==</content>
<statusCode>0</statusCode>
</status>
</ns2:getStatusResponse>
</S:Body>
</S:Envelope>
Loading

0 comments on commit 11a34a6

Please sign in to comment.