Esempio n. 1
0
    def to_entities(self):
        dt = self.data

        id_prefix = "tax_reg"

        company = company_entity(
            name=deal_with_mixed_lang(dt["company_name"]),
            code=dt["company_edrpou"],
            idNumber=dt["company_reg_no"],
            address=dt["company_address"],
            incorporationDate=dt_parse(dt["company_reg_date"], dayfirst=True),
        )

        yield company

        tax_office = ftm_model.make_entity("RingPublicBody")
        tax_office.make_id(id_prefix, "registrar", dt["tax_office_code"])
        tax_office.set("name", deal_with_mixed_lang(dt["tax_office_name"]))
        tax_office.set("jurisdiction", "Ukraine")

        yield tax_office

        registration = ftm_model.make_entity("Representation")
        registration.make_id(id_prefix, "registration", self.pk)

        registration.add("agent", tax_office)
        registration.add("client", company)
        registration.add("role", "registrar")

        yield registration
Esempio n. 2
0
    def to_entities(self):
        dt = self.data
        id_prefix = "lets_party"

        if dt["donator_code"]:
            donor = company_entity(
                name=dt["donator_name"],
                code=dt["donator_code"],
                address=dt["donator_location"],
            )
        else:
            donor = person_entity(
                dt["donator_name"],
                "Донор",
                id_prefix=id_prefix,
                address=dt["donator_location"],
            )

        donor.set(
            "description",
            "{}, {} зробила пожертву у розмірі {} гривень на {} {}".format(
                dt["donator_type"],
                dt["donation_date"],
                dt["amount"],
                "партію"
                if self.type in ["nacp", "parliament"]
                else "кандидата в президенти",
                self.ultimate_recepient,
            ),
        )
        yield donor

        if self.type in ["nacp", "parliament"]:
            if dt.get("branch_code"):
                beneficiary = company_entity(
                    name="{}, {}".format(dt["party"], dt["branch_name"]),
                    code=dt["branch_code"],
                    address=dt.get("geo"),
                )
            else:
                beneficiary = company_entity(
                    name=dt["party"],
                    code=dt["party"],
                    id_prefix=id_prefix,
                    address=dt.get("geo"),
                    entity_schema="RingOrganization",
                    legalForm="Політична партія"
                )
        else:
            beneficiary = person_entity(
                dt["candidate_name"],
                "Кандидат в президенти, {}".format(dt["party"]),
                id_prefix=id_prefix,
            )

        beneficiary.set(
            "description",
            "{} отримав пожертву у розмірі {} гривень від {} ({})".format(
                dt["donation_date"],
                dt["amount"],
                dt["donator_name"],
                dt["donator_type"],
            ),
        )

        yield beneficiary

        if dt.get("party", "cамовисування").lower() != "cамовисування" and dt.get(
            "branch_code"
        ):
            party = company_entity(
                name=dt["party"], code=dt["party"], id_prefix=id_prefix,
                entity_schema="RingOrganization",
                legalForm="Осередок політичної партії"
            )
            yield party

            directorship = ftm_model.make_entity("Membership")
            directorship.make_id(dt["party"], dt["branch_code"], "party")

            directorship.add("member", party.id)
            directorship.add("organization", beneficiary)
            directorship.add("role", "Головний офіс")
            yield directorship

        if dt.get("bank_name", "") and dt.get("account_number", ""):
            account = ftm_model.make_entity("BankAccount")
            account.make_id(dt["account_number"], "account")
            if dt.get("bank_name", ""):
                account.add("bankName", dt["bank_name"])

            if dt.get("account_number", ""):
                account.add("accountNumber", dt["account_number"])

            yield account
        else:
            account = None

        donation = ftm_model.make_entity("RingDonation")
        if dt.get("payment_subject"):
            donation.add("purpose", dt["payment_subject"])

        donation.add("payer", donor.id)
        donation.add("beneficiary", beneficiary.id)
        donation.add("amount", dt["amount"])
        donation.add("date", dt["donation_date"])
        donation.add("currency", "UAH")

        if account is not None:
            donation.add("beneficiaryAccount", account.id)

        donation.make_id(self.pk, "donation")
        yield donation
Esempio n. 3
0
    def to_entities(self):
        dt = self.data

        id_prefix = "tax_debts"

        if dt["TIN_S"]:
            debtor = company_entity(
                name=deal_with_mixed_lang(dt["NAME"]),
                code=dt["TIN_S"],
            )

            if dt["PIB"].strip():
                debtor_repr = person_entity(
                    dt["PIB"],
                    "Боржник",
                    id_prefix=id_prefix
                )

                directorship = ftm_model.make_entity("Directorship")
                directorship.make_id(dt["TIN_S"], dt["PIB"])

                directorship.add("director", debtor_repr)
                directorship.add("organization", debtor)
                directorship.add("role", "Керівник")
                yield directorship
                yield debtor_repr
        else:
            debtor = person_entity(
                dt["NAME"],
                "Боржник",
                id_prefix=id_prefix,
            )

        debtor.set(
            "description",
            "Станом на {} ма{} податковий борг у розмірі {} тисяч грн. перед {}".format(
                self.last_updated_from_dataset.date(),
                "ло" if dt["TIN_S"] else "в/ла",
                curformat(dt["SUM_D"] + dt["SUM_M"]),
                dt["DPI"],
            ),
        )
        yield debtor

        tax_office = company_entity(
            name=deal_with_mixed_lang(dt["DPI"]),
            code=dt["DPI"],
            id_prefix=id_prefix,
            entity_schema="RingPublicBody"
        )

        tax_office_head = person_entity(
            name=dt["DPI_BOSS"],
            positions="Керівник податкової інспекції",
            id_prefix=id_prefix,
            description="Станом на {} був керівником {}".format(
                self.last_updated_from_dataset.date(),
                dt["DPI"],
            )
        )

        tax_office_directorship = ftm_model.make_entity("Directorship")
        tax_office_directorship.make_id(dt["DPI"], dt["DPI_BOSS"])

        tax_office_directorship.add("director", tax_office_head)
        tax_office_directorship.add("organization", tax_office)
        tax_office_directorship.add("role", "Керівник")

        yield tax_office_directorship
        yield tax_office
        yield tax_office_head

        debt = ftm_model.make_entity("RingDebt")
        debt.make_id(self.pk, "debt")

        debt.add("debtor", debtor)
        debt.add("creditor", tax_office)
        debt.add("amount", round((dt["SUM_D"] + dt["SUM_M"]) * 1000, 2))
        debt.add("currency", "UAH")

        yield debt
Esempio n. 4
0
    def to_entities(self):
        dt = self.data
        id_prefix = "procurement_winners"

        buyer = company_entity(
            name=dt["purchase"]["buyer"]["name"],
            code=dt["purchase"]["buyer"]["code"],
            address=dt["purchase"]["buyer"]["address"],
            alias=dt["purchase"]["buyer"]["name_en"],
            entity_schema="RingPublicBody",
        )

        if dt["purchase"]["buyer"]["address_en"]:
            buyer.set("address", dt["purchase"]["buyer"]["address_en"])

        if dt["purchase"]["buyer"]["name_en"]:
            buyer.set("name", dt["purchase"]["buyer"]["name_en"])

        if dt["purchase"]["buyer"]["email"]:
            buyer.set("email", dt["purchase"]["buyer"]["email"])

        if dt["purchase"]["buyer"]["phone"]:
            buyer.set("phone", dt["purchase"]["buyer"]["phone"])

        if dt["purchase"]["buyer"]["fax"]:
            buyer.set("phone", dt["purchase"]["buyer"]["fax"])

        yield buyer

        if ((dt["purchase"]["cost_dispatcher_code"] or "").strip()
                and dt["purchase"]["cost_dispatcher_name"]
                and dt["purchase"]["cost_dispatcher_code"] !=
                dt["purchase"]["buyer"]["code"]):
            cost_dispatcher = company_entity(
                name=dt["purchase"]["cost_dispatcher_name"],
                code=dt["purchase"]["cost_dispatcher_code"],
            )
            yield cost_dispatcher

            cost_distpatcher_link = ftm_model.make_entity("UnknownLink")
            cost_distpatcher_link.make_id(
                dt["purchase"]["buyer"]["code"],
                "cost_dispatcher",
                dt["purchase"]["cost_dispatcher_code"],
            )

            cost_distpatcher_link.add("subject", buyer)
            cost_distpatcher_link.add("object", cost_dispatcher)
            cost_distpatcher_link.add("role", "Розпорядник коштів")
            yield cost_distpatcher_link

        seller = company_entity(
            name=dt["seller"]["name"],
            code=dt["seller"]["code"],
            address=dt["seller"]["address"],
        )

        if dt["seller"]["phone"]:
            seller.set("phone", dt["seller"]["phone"])

        yield seller

        if (dt["purchase"]["buyer"]["person"] or "").strip():
            representative = person_entity(
                dt["purchase"]["buyer"]["person"],
                "Представник замовника",
                id_prefix=id_prefix + dt["purchase"]["buyer"]["code"],
            )
            yield representative

            representation_link = ftm_model.make_entity("Representation")
            representation_link.make_id(dt["purchase"]["buyer"]["code"],
                                        dt["purchase"]["buyer"]["person"])
            representation_link.add("agent", representative)
            representation_link.add("client", buyer)
            representation_link.add("role", "Представник замовника")
            yield representation_link

        contract = ftm_model.make_entity("Contract")
        contract.make_id("Contract", dt["purchase"]["id"])
        contract.add("authority", buyer)
        contract.add(
            "name",
            "Закупівля {}".format(
                dt["purchase"].get("goods_name_short", "")
                or dt["purchase"].get("goods_name", "")).strip(),
        )
        contract.add("contractDate", dt["date"])
        yield contract

        contract_award = ftm_model.make_entity("ContractAward")
        contract_award.make_id("ContractAward", dt["id"])
        contract_award.add("amount", dt["volume_uah"])
        contract_award.add("currency", "UAH")
        contract_award.add("supplier", seller)
        contract_award.add("contract", contract)

        if dt["prozorro_number"]:
            contract_award.add("lotNumber", dt["prozorro_number"][:-3])

        yield contract_award