Esempio n. 1
0
File: subrow.py Progetto: Jasu/Lokki
def commandSubrowGet(args, session):
    invoice = beginRowCommand(args, session)
    row = findRow(args, invoice, session, CompositeRow)
    subrow = findSubrow(row, args.subrow_index)
    dieIf(not hasattr(subrow, args.setting_name), 
          "Setting '" + args.setting_name + "' not found.")
    print(getattr(subrow, args.setting_name))
Esempio n. 2
0
File: subrow.py Progetto: Jasu/Lokki
def commandSubrowRemove(args, session):
    invoice = beginRowCommand(args, session)
    row = findRow(args, invoice, session, CompositeRow)
    subrow = findSubrow(row, args.subrow_index)
  
    session.delete(subrow)
    session.commit()
  
    print("Deleted subrow '" + str(subrow.index) + "'.")
Esempio n. 3
0
File: subrow.py Progetto: Jasu/Lokki
def commandSubrowSet(args, session):
    invoice = beginRowCommand(args, session)
    row = findRow(args, invoice, session, CompositeRow)
    subrow = findSubrow(row, args.subrow_index)
    dieIf(not hasattr(subrow, args.setting_name), 
          "Setting '" + args.setting_name + "' not found.")
    setattr(subrow, args.setting_name, args.setting_value)
    session.commit()
  
    print('Updated subrow ' + str(subrow.index)
          + ' of row ' + str(row.index)
          + ' of invoice ' + str(invoice.invoice_number) + '.')
Esempio n. 4
0
File: subrow.py Progetto: Jasu/Lokki
def commandSubrowMv(args, session):
    invoice = beginRowCommand(args, session)
    srcRow = invoice.rows[int(args.src_row_index) - 1]
    dstRow = invoice.rows[int(args.dst_row_index) - 1]

    if srcRow == dstRow:
        print('Source and destination are the same row.')
        print('Nothing done.')
        return 

    subrow = findSubrow(srcRow, args.subrow_index)

    subrow.row_id = dstRow.id
    subrow.index = len(dstRow.subrows) + 1
    session.commit()

    compressIndices(session, Subrow, row_id=srcRow.id)

    session.commit()