Пример #1
0
    def test_get_document_sellers(self):
        with HTTMock(mock_api_bsale):
            self.document = bsale.Document()

            id_document = 10829
            seller = self.document.GetDocumentSeller(id_document)['items'][0]
            self.assertEqual(seller["id"], 2)
Пример #2
0
    def test_credit_note(self):
        with HTTMock(mock_api_bsale):
            self.document = bsale.Document()

            detail = self.document.GetDetailDocument(14528)

            details = []
            for items in detail["items"]:
                det = {
                    "documentDetailId": items["id"],
                    "quantity": int(items["quantity"]),
                    "unitValue": (items['netAmount'] / 1.19)
                }
                details.append(det)

            client = {
                "code": 111111111,
                "city": "Santiago",
                "municipality": "Las Condes",
                "activity": "giro",
                "address": "Alonso de Cordova"
            }

            params = {
                "documentTypeId": 2,
                "officeId": 5,
                "referenceDocumentId": 14528,
                "expirationDate": 1474588800,
                "emissionDate": 1474588800,
                "motive": "prueba api",
                "declareSii": 1,
                "priceAdjustment": 0,
                "editTexts": 0,
                "type": 0,
                "details": details,
                "client": client
            }

            self.document.CreateCreditNote(params)
Пример #3
0
 def test_add_nota_credito(self):
     """
     """
     with HTTMock(mock_api_bsale):
         self.document = bsale.Document()
         self.document.Create({
             "href": "https://api.bsale.cl/v1/documents/382.json",
             "id": 382,
             "emissionDate": 1463540400,
             "expirationDate": 1464663600,
             "generationDate": 1463593575,
             "number": 1,
             "totalAmount": 14280.0,
             "netAmount": 12000.0,
             "taxAmount": 2280.0,
             "exemptAmount": 0,
             "exportTotalAmount": 0,
             "exportNetAmount": 0,
             "exportTaxAmount": 0,
             "exportExemptAmount": 0,
             "commissionRate": 0,
             "commissionNetAmount": 0,
             "commissionTaxAmount": 0,
             "commissionTotalAmount": 0,
             "percentageTaxWithheld": 0,
             "purchaseTaxAmount": 0,
             "purchaseTotalAmount": 0,
             "urlTimbre": None,
             "ted": None,
             "urlPublicView":
             "http://app2.bsale.cl/view/2/a2d9b4da5128?sfd=99",
             "urlPdf":
             "http://app2.bsale.cl/view/2/a2d9b4da5128.pdf?sfd=99",
             "urlPublicViewOriginal":
             "http://app2.bsale.cl/view/2/a2d9b4da5128",
             "urlPdfOriginal":
             "http://app2.bsale.cl/view/2/a2d9b4da5128.pdf",
             "token": "a2d9b4da5128",
             "state": 0,
             "userId": 2,
             "urlXml": None,
             "address": None,
             "municipality": None,
             "city": None,
             "informedSii": 1,
             "responseMsgSii": None,
             "document_type": {
                 "href": "https://api.bsale.cl/v1/document_types/1.json",
                 "id": "1"
             },
             "client": {
                 "href": "https://api.bsale.cl/v1/clients/7.json",
                 "id": "7"
             },
             "office": {
                 "href": "https://api.bsale.cl/v1/offices/2.json",
                 "id": "2"
             },
             "user": {
                 "href": "https://api.bsale.cl/v1/users/2.json",
                 "id": "2"
             },
             "references": {
                 "href":
                 "https://api.bsale.cl/v1/documents/382/references.json"
             },
             "document_taxes": {
                 "href":
                 "https://api.bsale.cl/v1/documents/382/document_taxes.json"
             },
             "details": {
                 "href":
                 "https://api.bsale.cl/v1/documents/382/details.json"
             },
             "sellers": {
                 "href":
                 "https://api.bsale.cl/v1/documents/382/sellers.json"
             }
         })
Пример #4
0
 def test_update_state_sii(self):
     with HTTMock(mock_api_bsale):
         self.document = bsale.Document()
         id_document = 10829
         state = 1
         document = self.document.UpdateStateSII(id_document, state)
Пример #5
0
    def test_get_one_document(self):
        with HTTMock(mock_api_bsale):
            self.document = bsale.Document()

            id_document = 10829
            self.document.GetOneDocument(id_document)
Пример #6
0
 def test_delete_document(self):
     with HTTMock(mock_api_bsale):
         self.document = bsale.Document()
Пример #7
0
 def test_get_documents(self):
     with HTTMock(mock_api_bsale):
         self.document = bsale.Document()
         self.document.Get(limit=4, offset=0)
Пример #8
0
    #         # {'id': 1747},
    #         # {'id': 1748},
    #         # {'id': 1749},
    #         # {'id': 1750},
    #         # {'id': 1751},
    #         # {'id': 1752},
    #         # {'id': 1753},
    #         # {'id': 1754},
    #         # {'id': 1755},
    #         # {'id': 1756},
    #         # { 'id' : 1757}
    #       ]}

    # last 1796

    document = bsale.Document()

    counter = 0
    last_id = 1757
    q = 50

    for item in json_data["items"]:

        if counter < q and item["id"] > last_id:

            detail = document.GetDetailDocument(item["id"])
            details = []
            for items in detail["items"]:
                det = {
                    "documentDetailId": items["id"],
                    "quantity": int(items["quantity"]),