Beispiel #1
0
def convert_Close(entry: data.Close) -> pb.Directive:
    pbent = pb.Directive()
    close = pbent.close
    copy_meta(entry.meta, pbent.meta)
    copy_date(entry.date, pbent.date)
    close.account = entry.account
    return pbent
Beispiel #2
0
def convert_Commodity(entry: data.Commodity) -> pb.Directive:
    pbdir = pb.Directive()
    comm = pbdir.commodity
    copy_meta(entry.meta, pbdir.meta, pbdir.location)
    copy_date(entry.date, pbdir.date)
    comm.currency = entry.currency
    return pbdir
Beispiel #3
0
def convert_Close(entry: data.Close) -> pb.Directive:
    pbdir = pb.Directive()
    close = pbdir.close
    copy_meta(entry.meta, pbdir.meta, pbdir.location)
    copy_date(entry.date, pbdir.date)
    close.account = entry.account
    return pbdir
Beispiel #4
0
def convert_Pad(entry: data.Pad) -> pb.Directive:
    pbdir = pb.Directive()
    pad = pbdir.pad
    copy_meta(entry.meta, pbdir.meta, pbdir.location)
    copy_date(entry.date, pbdir.date)
    pad.account = entry.account
    pad.source_account = entry.source_account
    return pbdir
Beispiel #5
0
def convert_Query(entry: data.Query) -> pb.Directive:
    pbdir = pb.Directive()
    query = pbdir.query
    copy_meta(entry.meta, pbdir.meta, pbdir.location)
    copy_date(entry.date, pbdir.date)
    query.name = entry.name
    query.query_string = entry.query_string
    return pbdir
Beispiel #6
0
def convert_Note(entry: data.Note) -> pb.Directive:
    pbdir = pb.Directive()
    note = pbdir.note
    copy_meta(entry.meta, pbdir.meta, pbdir.location)
    copy_date(entry.date, pbdir.date)
    note.account = entry.account
    note.comment = entry.comment
    return pbdir
Beispiel #7
0
def convert_Event(entry: data.Event) -> pb.Directive:
    pbdir = pb.Directive()
    event = pbdir.event
    copy_meta(entry.meta, pbdir.meta, pbdir.location)
    copy_date(entry.date, pbdir.date)
    event.type = entry.type
    event.description = entry.description
    return pbdir
Beispiel #8
0
def convert_Price(entry: data.Price) -> pb.Directive:
    pbdir = pb.Directive()
    price = pbdir.price
    copy_meta(entry.meta, pbdir.meta, pbdir.location)
    copy_date(entry.date, pbdir.date)
    price.currency = entry.currency
    copy_decimal(entry.amount.number, price.amount.number)
    price.amount.currency = entry.amount.currency
    return pbdir
Beispiel #9
0
def convert_Open(entry: data.Open) -> pb.Directive:
    pbent = pb.Directive()
    open = pbent.open
    copy_meta(entry.meta, pbent.meta)
    copy_date(entry.date, pbent.date)
    open.account = entry.account
    if entry.currencies:
        open.currencies.extend(entry.currencies)
    # TODO(blais): Add enum
    return pbent
Beispiel #10
0
def convert_Open(entry: data.Open) -> pb.Directive:
    pbdir = pb.Directive()
    open = pbdir.open
    copy_meta(entry.meta, pbdir.meta, pbdir.location)
    copy_date(entry.date, pbdir.date)
    open.account = entry.account
    if entry.currencies:
        open.currencies.extend(entry.currencies)
    if entry.booking:
        open.booking = ob.Booking.Value(entry.booking.name)
    return pbdir
Beispiel #11
0
def convert_Balance(entry: data.Balance) -> pb.Directive:
    pbdir = pb.Directive()
    balance = pbdir.balance
    copy_meta(entry.meta, pbdir.meta, pbdir.location)
    copy_date(entry.date, pbdir.date)
    balance.account = entry.account
    copy_decimal(entry.amount.number, balance.amount.number)
    balance.amount.currency = entry.amount.currency
    if entry.tolerance:
        copy_decimal(entry.tolerance, balance.tolerance)
    if entry.diff_amount:
        copy_decimal(entry.diff_amount.number, balance.diff_amount.number)
        balance.diff_amount.currency = entry.diff_amount.currency
    return pbdir
Beispiel #12
0
def convert_Transaction(entry: data.Transaction) -> pb.Directive:
    pbent = pb.Directive()
    txn = pbent.transaction
    copy_meta(entry.meta, pbent.meta)
    copy_date(entry.date, pbent.date)
    if entry.flag:
        txn.flag = entry.flag.encode('utf8')
    if entry.payee:
        txn.payee = entry.payee
    txn.narration = entry.narration
    if entry.tags:
        txn.tags.extend(entry.tags)
    if entry.links:
        txn.links.extend(entry.links)
    for posting in entry.postings:
        pbpost = txn.postings.add()
        copy_posting(posting, pbpost)
    return pbent