def build_transaction(transaction): transaction_id = str(transaction["id"]) transaction_date = transaction["transaction_date"].isoformat() transaction_value = transaction["transaction_value"] transaction_description = transaction["transaction_description"] trt = transaction["transaction_type"] if trt == "D": trtval = "D" if trt == "C": trtval = "C" tt = codelists("TransactionType") transaction_type = tt[trtval] t = et.Element("transaction") t.set("ref", transaction_id) t.append(el_with_code("transaction-type", transaction_type)) tdate = et.Element("transaction-date") t.append(tdate) tdate.set("iso-date", transaction_date) tvalue = et.Element("value") t.append(tvalue) tvalue.text = unicode(transaction_value) tvalue.set("value-date", transaction_date) if transaction_description: t.append(el_with_narrative("description", transaction_description)) return t
def el_date(start_end, iso_date): adt = codelists("ActivityDateType") actual_planned = actual_or_planned(iso_date) date_type = adt[start_end][actual_or_planned(iso_date)] el = et.Element('activity-date') el.set("type", date_type) el.set("iso-date", iso_date) return el
def el_date(start_end, iso_date): adt = codelists("ActivityDateType") actual_planned = actual_or_planned(iso_date) date_type = adt[start_end][actual_or_planned(iso_date)] el = et.Element("activity-date") el.set("type", date_type) el.set("iso-date", iso_date) return el
def el_org_103(role, o_name, o_ref=None, o_type=None): if role == "reporting": el = et.Element("reporting-org") else: r = codelists("OrganisationRole") el = et.Element("participating-org") el.set("role", role) if o_ref: el.set("ref", o_ref) if o_type: el.set("type", o_type) el.text = o_name return el
def el_org(role, o_name, o_ref=None, o_type=None): if role == "reporting": el = et.Element("reporting-org") else: r = codelists("OrganisationRole") el = et.Element("participating-org") el.set("role", r[role]) if o_ref: el.set("ref", o_ref) if o_type: el.set("type", o_type) el_nar = et.Element("narrative") el.append(el_nar) el_nar.text = o_name return el