def __FillNonSums(self, body_element):
        children = lxml_functions.GetSubElements(body_element)

        for child_element in children:
            grand_children = lxml_functions.GetSubElements(child_element)
            if (len(grand_children) > 0):
                self.__FillNonSumWithChildren(child_element)
            else:
                self.__FillNonSumChildless(child_element)
Esempio n. 2
0
    def __FillOutCustomerNumber(self, invoice_batch, number):
        customer_element = self.__ExtractCustomerElement()
        children = lxml_functions.GetSubElements(customer_element)

        invoices_element = self.__FillOutInvoices(invoice_batch)
        lxml_functions.AddChildElementToElement(invoices_element,
                                                customer_element)

        customer_name = pandas_functions.GetFirstValueFromColumnFromFrame(
            data_settings.invoices_customer_name, invoice_batch)

        for child_element in children:
            data = False
            child_tag = lxml_functions.GetTag(child_element)

            if child_tag == "K1":
                data = number

            elif child_tag == "K2":
                data = 1

            elif child_tag == "K3":
                number = pandas_functions.GetValueFromColumnFromFrameIfColumnHasValue(
                    data_settings.customers_tax_number, self.customers,
                    data_settings.customers_name, customer_name)
                data = transform_data.AddLeadingZerosToStringUntilLength(
                    number, 11)

            elif child_tag == "K4":
                data = customer_name

            elif child_tag == "K5":
                data = lxml_functions.GetSumOfAllSubElementsWithTagPatternOfElement(
                    "R6", invoices_element)

            elif child_tag == "K6":
                data = lxml_functions.GetSumOfAllSubElementsWithTagPatternOfElement(
                    "R7", invoices_element)

            elif child_tag == "K7":
                data = lxml_functions.GetSumOfAllSubElementsWithTagPatternOfElement(
                    "R8", invoices_element)

            elif child_tag == "K8":
                data = lxml_functions.GetSumOfAllSubElementsWithTagPatternOfElement(
                    "R9", invoices_element)

            elif child_tag == "K9":
                data = lxml_functions.GetSumOfAllSubElementsWithTagPatternOfElement(
                    "R10", invoices_element)

            if (data != False):
                lxml_functions.SetElementText(child_element, data)

        return customer_element
    def __FillNonSumWithChildren(self, child_element):
        child_tag = lxml_functions.GetTag(child_element)
        grandchildren = lxml_functions.GetSubElements(child_element)

        for grandchild_element in grandchildren:
            data = False
            grandchild_tag = lxml_functions.GetTag(grandchild_element)

            if child_tag == "Podatak203":
                if grandchild_tag == "Vrijednost":
                    data = pandas_functions.SumColumnInFrame(
                        data_settings.IRA_EU_taxable_base, self.IRA_EU)
                elif grandchild_tag == "Porez":
                    data = pandas_functions.SumColumnInFrame(
                        data_settings.IRA_EU_taxable_tax, self.IRA_EU)

            elif child_tag == "Podatak207":
                if grandchild_tag == "Vrijednost":
                    data = pandas_functions.SumColumnInFrame(
                        data_settings.URA_EU_DC_tax_base, self.URA_EU_DC)
                elif grandchild_tag == "Porez":
                    data = pandas_functions.SumColumnInFrame(
                        data_settings.URA_EU_DC_total, self.URA_EU_DC)

            elif child_tag == "Podatak303":
                if grandchild_tag == "Vrijednost":
                    data = 4 * pandas_functions.SumColumnInFrame(
                        data_settings.URA_EU_DOM_refundable, self.URA_EU_DOM)
                elif grandchild_tag == "Porez":
                    data = pandas_functions.SumColumnInFrame(
                        data_settings.URA_EU_DOM_refundable, self.URA_EU_DOM)

            elif child_tag == "Podatak307":
                if grandchild_tag == "Vrijednost":
                    data = pandas_functions.SumColumnInFrame(
                        data_settings.URA_EU_DC_tax_base, self.URA_EU_DC)
                elif grandchild_tag == "Porez":
                    data = pandas_functions.SumColumnInFrame(
                        data_settings.URA_EU_DC_total, self.URA_EU_DC)

            elif child_tag == "Podatak314":
                if grandchild_tag == "Vrijednost":
                    data = 4 * pandas_functions.SumColumnInFrame(
                        data_settings.URA_EU_UVOZ_total, self.URA_EU_UVOZ)
                elif grandchild_tag == "Porez":
                    data = pandas_functions.SumColumnInFrame(
                        data_settings.URA_EU_UVOZ_total, self.URA_EU_UVOZ)

            if (data != False):
                lxml_functions.SetElementText(grandchild_element, data)
    def __FillFinalSum(self, body_element):
        children = lxml_functions.GetSubElements(body_element)

        podatak_000 = lxml_functions.GetSubElementsWithTagPattern(
            body_element, "Podatak000")[0]
        podatak_100 = lxml_functions.GetSubElementsWithTagPattern(
            body_element, "Podatak100")[0]
        podatak_200 = lxml_functions.GetSubElementsWithTagPattern(
            body_element, "Podatak200")[0]
        vrijednost_podatak_200 = lxml_functions.GetSubElementsWithTagPattern(
            podatak_200, "Vrijednost")[0]

        data = float(podatak_100.text) + float(vrijednost_podatak_200.text)
        lxml_functions.SetElementText(podatak_000, data)
    def __FillSumWithChildren(self, body_element, child_element):
        child_tag = lxml_functions.GetTag(child_element)
        grandchildren = lxml_functions.GetSubElements(child_element)

        for grandchild_element in grandchildren:
            data = False
            grandchild_tag = lxml_functions.GetTag(grandchild_element)

            if child_tag == "Podatak200":
                pattern_elements = lxml_functions.GetSubElementsWithTagPattern(
                    body_element, "Podatak2")
                sum = 0.0

                if grandchild_tag == "Vrijednost":
                    for pattern_element in pattern_elements:
                        sum += lxml_functions.GetSumOfSubElementsWithTagPatternOfElement(
                            "Vrijednost", pattern_element)
                    data = sum
                elif grandchild_tag == "Porez":
                    for pattern_element in pattern_elements:
                        sum += lxml_functions.GetSumOfSubElementsWithTagPatternOfElement(
                            "Porez", pattern_element)
                    data = sum

            elif child_tag == "Podatak300":
                pattern_elements = lxml_functions.GetSubElementsWithTagPattern(
                    body_element, "Podatak3")
                sum = 0.0

                if grandchild_tag == "Vrijednost":
                    for pattern_element in pattern_elements:
                        sum += lxml_functions.GetSumOfSubElementsWithTagPatternOfElement(
                            "Vrijednost", pattern_element)
                    data = sum
                elif grandchild_tag == "Porez":
                    for pattern_element in pattern_elements:
                        sum += lxml_functions.GetSumOfSubElementsWithTagPatternOfElement(
                            "Porez", pattern_element)
                    data = sum

            if (data != False):
                lxml_functions.SetElementText(grandchild_element, data)
Esempio n. 6
0
    def CreateAndFillOutBody(self):
        body_element = self.__ExtractBodyElement()
        children = lxml_functions.GetSubElements(body_element)

        customers_element = self.__FillOutCustomers()
        lxml_functions.InsertChildElementIntoElementAtIndex(
            customers_element, body_element, 0)

        for child_element in children:
            data = False
            child_tag = lxml_functions.GetTag(child_element)

            if child_tag == "UkupanIznosRacunaObrasca":
                data = lxml_functions.GetSumOfAllSubElementsWithTagPatternOfElement(
                    "K5", customers_element)

            elif child_tag == "UkupanIznosPdvObrasca":
                data = lxml_functions.GetSumOfAllSubElementsWithTagPatternOfElement(
                    "K6", customers_element)

            elif child_tag == "UkupanIznosRacunaSPdvObrasca":
                data = lxml_functions.GetSumOfAllSubElementsWithTagPatternOfElement(
                    "K7", customers_element)

            elif child_tag == "UkupniPlaceniIznosRacunaObrasca":
                data = lxml_functions.GetSumOfAllSubElementsWithTagPatternOfElement(
                    "K8", customers_element)

            elif child_tag == "NeplaceniIznosRacunaObrasca":
                data = lxml_functions.GetSumOfAllSubElementsWithTagPatternOfElement(
                    "K9", customers_element)

            elif child_tag == "OPZUkupanIznosRacunaSPdv":
                data = 0.0

            elif child_tag == "OPZUkupanIznosPdv":
                data = 0.0

            if (data != False):
                lxml_functions.SetElementText(child_element, data)

        return body_element