Exemple #1
0
    def run(self, command_list):

        """Execute subcommand."""

        # Get the command line arguments into a dictionary
        o, remainder_ = self.get_args(command_list, self.ops, self.help_text)

        # Got this far, then authenticate
        self.authenticate()

        if o['possible-fields']:
            alloc().possible_fields("project")

        # Initialize some variables
        personID = self.get_my_personID()

        # Get a projectID either passed via command line, or figured out from a
        # project name
        f = {}
        if o['project']:
            f['projectNameMatches'] = o['project']
        f["personID"] = personID
        f["projectStatus"] = "Current"
        fields = o["fields"] or ["projectID", "projectName"]
        self.print_table(
            "project", self.get_list("project", f), fields, sort="projectName")
Exemple #2
0
    def run(self, command_list):

        """Execute subcommand."""

        # Get the command line arguments into a dictionary
        o, remainder_ = self.get_args(command_list, self.ops, self.help_text)

        # Got this far, then authenticate
        self.authenticate()

        if o['possible-fields']:
            alloc().possible_fields("project")

        # Initialize some variables
        personID = self.get_my_personID()

        # Get a projectID either passed via command line, or figured out from a
        # project name
        f = {}
        if o['project']:
            f['projectNameMatches'] = o['project']
        f["personID"] = personID
        f["projectStatus"] = "Current"
        fields = o["fields"] or ["projectID", "projectName"]
        self.print_table(
            "project", self.get_list("project", f), fields, sort="projectName")
Exemple #3
0
    def run(self, command_list):

        # Get the command line arguments into a dictionary
        o, remainder_ = self.get_args(command_list, self.ops, self.help_text)

        # Got this far, then authenticate
        self.authenticate()

        if o['possible-fields']:
            alloc().possible_fields("invoice")

        # Initialize some variables
        personID = self.get_my_personID()

        # Get a clientID either passed via command line, or figured out from a
        # project name
        f = {}
        if self.is_num(o['client']):
            f["clientID"] = o['client']
        elif o['client']:
            f["clientID"] = self.search_for_client({"clientName": o['client']})

        # Get a projectID either passed via command line, or figured out from a
        # project name
        if self.is_num(o['project']):
            f["projectID"] = o['project']
        elif o['project']:
            f["projectID"] = self.search_for_project(o['project'], personID)

        f['return'] = "array"

        if o['num']:
            f['invoiceNum'] = o['num']
        if o['from']:
            f['dateOne'] = o['from']
        if o['to']:
            f['dateTwo'] = o['to']
        if o['status']:
            f['invoiceStatus'] = o['status']

        if o['items']:
            invoiceIDs = []
            invoices_list = self.get_list("invoice", f)
            if invoices_list:
                for i in invoices_list:
                    invoiceIDs.append(i)

                fields = o["fields"] or ["invoiceID", "invoiceItemID", "clientID", "clientName", "invoiceNum",
                                         "iiDate", "iiAmount", "iiQuantity", "iiUnitPrice", "iiMemo"]
                self.print_table("invoiceItem", self.get_list("invoiceItem", {"invoiceID": invoiceIDs}),
                                 fields, sort="invoiceID")

        else:
            fields = o["fields"] or ["invoiceID", "clientID", "clientName", "invoiceNum", "invoiceDateFrom",
                                     "invoiceDateTo", "invoiceStatus", "status_label", "amountPaidRejected",
                                     "amountPaidPending", "amountPaidApproved", "iiAmountSum"]

            self.print_table(
                "invoice", self.get_list("invoice", f), fields, sort="clientName")
Exemple #4
0
    def run(self, command_list):
        """Execute subcommand."""

        # Get the command line arguments into a dictionary
        o, remainder_ = self.get_args(command_list, self.ops, self.help_text)

        # Got this far, then authenticate
        self.authenticate()

        if o['possible-fields']:
            alloc().possible_fields("transaction")

        # Initialize some variables
        ops = {}

        if 'account' in o and o['account']:
            ops['tfIDs'] = self.make_request({
                'method': 'get_tfID',
                'options': o['account']
            })

        # Get transactions
        if 'items' in o and o['items']:
            if o['field']:
                fields = o['field']
            else:
                fields = [
                    "transactionID", "fromTfName", "tfName", "amount",
                    "status", "transactionDate"
                ]

            transactions = self.get_list("transaction", ops)
            if transactions:
                self.print_table("transaction", transactions, fields,
                                 "transactionDate")
                print "num rows:", len(transactions)

        # Get tf
        else:
            if o['field']:
                fields = o['field']
            else:
                fields = ["tfID", "tfName", "tfBalancePending", "tfBalance"]

            tfs = self.get_list("tf", ops)
            if tfs:
                self.print_table("tf", tfs, fields, "tfName")
Exemple #5
0
    def run(self, command_list):
        """Execute subcommand."""

        # Get the command line arguments into a dictionary
        o, remainder_ = self.get_args(command_list, self.ops, self.help_text)

        # Got this far, then authenticate
        self.authenticate()

        if o['possible-fields']:
            alloc().possible_fields("transaction")

        # Initialize some variables
        ops = {}

        if 'account' in o and o['account']:
            ops['tfIDs'] = self.make_request(
                {'method': 'get_tfID', 'options': o['account']})

        # Get transactions
        if 'items' in o and o['items']:
            if o['field']:
                fields = o['field']
            else:
                fields = ["transactionID", "fromTfName", "tfName",
                          "amount", "status", "transactionDate"]

            transactions = self.get_list("transaction", ops)
            if transactions:
                self.print_table(
                    "transaction", transactions, fields, "transactionDate")
                print "num rows:", len(transactions)

        # Get tf (tagged fund)
        else:
            if o['field']:
                fields = o['field']
            else:
                fields = ["tfID", "tfName", "tfBalancePending", "tfBalance"]

            tf_list = self.get_list("tf", ops)
            if tf_list:
                self.print_table("tf", tf_list, fields, "tfName")
Exemple #6
0
    def run(self, command_list):
        """Execute subcommand."""

        # Get the command line arguments into a dictionary
        o, remainder_ = self.get_args(command_list, self.ops, self.help_text)

        # Got this far, then authenticate
        self.authenticate()

        if o['possible-fields']:
            alloc().possible_fields("timeSheet")

        # Initialize some variables
        self.quiet = o['quiet']
        personID = self.get_my_personID()
        projectID = ""
        taskID = ""
        timeSheetID = ""
        order_ts = ["From", "ID"]
        order_tsi = ["Date", "Item ID"]
        status = "edit"

        if o['date']:
            o['date'] = self.parse_date(o['date'])

        # Get a projectID either passed via command line, or figured out from a
        # project name
        if self.is_num(o['project']):
            projectID = o['project']
        elif o['project']:
            projectID = self.search_for_project(o['project'],
                                                personID,
                                                die=False)

        if self.is_num(o['task']):
            taskID = o['task']
        elif o['task']:
            taskID = self.search_for_task({
                'taskName': o['task'],
                'taskView': 'prioritised'
            })

        if self.is_num(o['tsid']):
            timeSheetID = o['tsid']

        if 'all' in o['status']:
            status = [
                'edit', 'manager', 'admin', 'invoiced', 'finished', 'rejected'
            ]
        elif o['status']:
            status = o['status']

        if o['order']:
            order = o['order']
        elif o['items']:
            order = order_tsi
        else:
            order = order_ts

        ops = {}
        if timeSheetID:
            ops['timeSheetID'] = timeSheetID
        else:
            ops['status'] = status

            if 'account' in o and o['account']:
                tfargs = {}
                tfargs['method'] = 'get_tfID'
                tfargs['options'] = o['account']
                ops['tfID'] = self.make_request(tfargs)
            elif o['creator']:
                ops['personID'] = self.get_my_personID(o['creator'])
            else:
                ops['personID'] = personID

            if projectID:
                ops['projectID'] = projectID
            if taskID:
                ops['taskID'] = taskID

        if o['hours']:
            ops['timeSheetItemHours'] = o['hours']

        if o['items']:
            timeSheets = self.get_list("timeSheet", ops)
            if timeSheets:
                tids = []
                for i, t_ in timeSheets.items():
                    tids.append(i)
                if tids:
                    ops["timeSheetID"] = tids
                    if o['date']:
                        # >=
                        ops['date'], ops[
                            'dateComparator'] = self.parse_date_comparator(
                                o['date'])
                    timeSheetItems = self.get_list("timeSheetItem", ops)
                    self.print_table("timeSheetItem",
                                     timeSheetItems,
                                     o["fields"] or self.row_timeSheetItem,
                                     sort=order)

        else:
            if o['date']:
                # <=
                ops['dateFrom'], ops[
                    'dateFromComparator'] = self.parse_date_comparator(
                        o['date'])
            timeSheets = self.get_list("timeSheet", ops)
            self.print_table("timeSheet",
                             timeSheets,
                             o["fields"] or self.row_timeSheet,
                             sort=order)
Exemple #7
0
    def run(self, command_list):

        """Execute subcommand."""

        # Get the command line arguments into a dictionary
        o, remainder_ = self.get_args(command_list, self.ops, self.help_text)

        # Got this far, then authenticate
        self.authenticate()

        if o['possible-fields']:
            alloc().possible_fields("timeSheet")

        # Initialize some variables
        self.quiet = o['quiet']
        personID = self.get_my_personID()
        projectID = ""
        taskID = ""
        timeSheetID = ""
        order_ts = ["From", "ID"]
        order_tsi = ["Date", "Item ID"]
        status = "edit"

        if o['date']:
            o['date'] = self.parse_date(o['date'])

        # Get a projectID either passed via command line, or figured out from a
        # project name
        if self.is_num(o['project']):
            projectID = o['project']
        elif o['project']:
            projectID = self.search_for_project(
                o['project'], personID, die=False)

        if self.is_num(o['task']):
            taskID = o['task']
        elif o['task']:
            taskID = self.search_for_task(
                {'taskName': o['task'], 'taskView': 'prioritised'})

        if self.is_num(o['tsid']):
            timeSheetID = o['tsid']

        if 'all' in o['status']:
            status = [
                'edit', 'manager', 'admin', 'invoiced', 'finished', 'rejected']
        elif o['status']:
            status = o['status']

        if o['order']:
            order = o['order']
        elif o['items']:
            order = order_tsi
        else:
            order = order_ts

        ops = {}
        if timeSheetID:
            ops['timeSheetID'] = timeSheetID
        else:
            ops['status'] = status

            if 'account' in o and o['account']:
                tfargs = {}
                tfargs['method'] = 'get_tfID'
                tfargs['options'] = o['account']
                ops['tfID'] = self.make_request(tfargs)
            elif o['creator']:
                ops['personID'] = self.get_my_personID(o['creator'])
            else:
                ops['personID'] = personID

            if projectID:
                ops['projectID'] = projectID
            if taskID:
                ops['taskID'] = taskID

        if o['hours']:
            ops['timeSheetItemHours'] = o['hours']

        if o['items']:
            timeSheets = self.get_list("timeSheet", ops)
            if timeSheets:
                tids = []
                for i, t_ in timeSheets.items():
                    tids.append(i)
                if tids:
                    ops["timeSheetID"] = tids
                    if o['date']:
                        # >=
                        ops['date'], ops[
                            'dateComparator'] = self.parse_date_comparator(o['date'])
                    timeSheetItems = self.get_list("timeSheetItem", ops)
                    self.print_table("timeSheetItem", timeSheetItems, o[
                                     "fields"] or self.row_timeSheetItem, sort=order)

        else:
            if o['date']:
                # <=
                ops['dateFrom'], ops[
                    'dateFromComparator'] = self.parse_date_comparator(o['date'])
            timeSheets = self.get_list("timeSheet", ops)
            self.print_table(
                "timeSheet", timeSheets, o["fields"] or self.row_timeSheet, sort=order)
Exemple #8
0
    def run(self, command_list):

        """Execute subcommand."""

        # Get the command line arguments into a dictionary
        o, remainder_ = self.get_args(command_list, self.ops, self.help_text)

        # Got this far, then authenticate
        self.authenticate()

        if o['possible-fields']:
            alloc().possible_fields("task")

        order = []
        if o['order']:
            order = o['order']

        # Get personID, either assignee or logged in user
        personID = []
        if "all" not in o['assignee']:
            if not o['assignee']:
                personID.append(self.get_my_personID())
            elif o['assignee']:
                personID = self.person_to_personID([0 if x.lower() == 'null' else x for x in o['assignee']])

        managerID = []
        if o['manager']:
            managerID = self.person_to_personID(o['manager'])

        creatorID = []
        if o['creator']:
            creatorID = self.person_to_personID(o['creator'])

        # Setup options for the task search
        ops = {}
        ops["personID"] = personID
        ops["managerID"] = managerID
        ops["creatorID"] = creatorID
        if o['project']:
            ops["projectNameMatches"] = o['project']
        ops["taskView"] = "prioritised"
        ops["showTimes"] = True
        o["status"] = o["status"] or "open"
        ops['taskStatus'] = o['status']
        if o['type']:
            ops['taskTypeID'] = o['type']
        if o['tag']:
            ops['tags'] = o['tag']

        # Get a taskID either passed via command line, or figured out from a
        # task name
        if self.is_num(o['task']):
            ops["taskID"] = o['task']
            if 'taskTypeID' in ops:
                del ops["taskTypeID"]
            if 'taskStatus' in ops:
                del ops["taskStatus"]
            if 'personID' in ops:
                del ops["personID"]
        elif o['task']:
            ops["taskName"] = o["task"]

        if not o['fields']:
            if not order:
                order = ["priorityLabel", "taskTypeID", "_rate",
                         "taskStatusLabel"]
            fields = ["taskID", "taskTypeID", "taskStatusLabel",
                      "priorityLabel", "timeExpected", "timeLimit",
                      "timeActual", "rate", "projectName", "taskName", "tags"]
        else:
            fields = o["fields"]

        if 'timeBest' not in o['fields'] \
                and 'timeWorst' not in o['fields'] \
                and 'timeExpected' not in o['fields'] \
                and 'timeLimit' not in o['fields'] \
                and 'timeActual' not in o['fields']:
            del ops['showTimes']

        if 'showTimes' not in ops:
            if 'timeWorst' in fields:
                fields.remove('timeWorst')
            if 'timeExpected' in fields:
                fields.remove('timeExpected')
            if 'timeLimit' in fields:
                fields.remove('timeLimit')
            if 'timeActual' in fields:
                fields.remove('timeActual')

        # Get list of tasks
        task_list = self.get_list("task", ops)

        if task_list:
            self.print_table("task", task_list, fields, order)
Exemple #9
0
    def run(self, command_list):

        # Get the command line arguments into a dictionary
        o, remainder_ = self.get_args(command_list, self.ops, self.help_text)

        # Got this far, then authenticate
        self.authenticate()

        if o['possible-fields']:
            alloc().possible_fields("invoice")

        # Initialize some variables
        personID = self.get_my_personID()

        # Get a clientID either passed via command line, or figured out from a
        # project name
        f = {}
        if self.is_num(o['client']):
            f["clientID"] = o['client']
        elif o['client']:
            f["clientID"] = self.search_for_client({"clientName": o['client']})

        # Get a projectID either passed via command line, or figured out from a
        # project name
        if self.is_num(o['project']):
            f["projectID"] = o['project']
        elif o['project']:
            f["projectID"] = self.search_for_project(o['project'], personID)

        f['return'] = "array"

        if o['num']:
            f['invoiceNum'] = o['num']
        if o['from']:
            f['dateOne'] = o['from']
        if o['to']:
            f['dateTwo'] = o['to']
        if o['status']:
            f['invoiceStatus'] = o['status']

        if o['items']:
            invoiceIDs = []
            invoices_list = self.get_list("invoice", f)
            if invoices_list:
                for i in invoices_list:
                    invoiceIDs.append(i)

                fields = o["fields"] or [
                    "invoiceID", "invoiceItemID", "clientID", "clientName",
                    "invoiceNum", "iiDate", "iiAmount", "iiQuantity",
                    "iiUnitPrice", "iiMemo"
                ]
                self.print_table("invoiceItem",
                                 self.get_list("invoiceItem",
                                               {"invoiceID": invoiceIDs}),
                                 fields,
                                 sort="invoiceID")

        else:
            fields = o["fields"] or [
                "invoiceID", "clientID", "clientName", "invoiceNum",
                "invoiceDateFrom", "invoiceDateTo", "invoiceStatus",
                "status_label", "amountPaidRejected", "amountPaidPending",
                "amountPaidApproved", "iiAmountSum"
            ]

            self.print_table("invoice",
                             self.get_list("invoice", f),
                             fields,
                             sort="clientName")
Exemple #10
0
    def run(self, command_list):
        """Execute subcommand."""

        # Get the command line arguments into a dictionary
        o, remainder_ = self.get_args(command_list, self.ops, self.help_text)

        # Got this far, then authenticate
        self.authenticate()

        if o['possible-fields']:
            alloc().possible_fields("task")

        order = []
        if o['order']:
            order = o['order']

        # Get personID, either assignee or logged in user
        personID = []
        if not o['assignee']:
            personID.append(self.get_my_personID())
        elif o['assignee']:
            personID = self.person_to_personID(
                [0 if x.lower() == 'null' else x for x in o['assignee']])

        managerID = []
        if o['manager']:
            managerID = self.person_to_personID(o['manager'])

        creatorID = []
        if o['creator']:
            creatorID = self.person_to_personID(o['creator'])

        # Setup options for the task search
        ops = {}
        ops["personID"] = personID
        ops["managerID"] = managerID
        ops["creatorID"] = creatorID
        if o['project']:
            ops["projectNameMatches"] = o['project']
        ops["taskView"] = "prioritised"
        ops["showTimes"] = True
        o["status"] = o["status"] or "open"
        ops['taskStatus'] = o['status']
        if o['type']:
            ops['taskTypeID'] = o['type']
        if o['tag']:
            ops['tags'] = o['tag']

        # Get a taskID either passed via command line, or figured out from a
        # task name
        if self.is_num(o['task']):
            ops["taskID"] = o['task']
            if 'taskTypeID' in ops:
                del ops["taskTypeID"]
            if 'taskStatus' in ops:
                del ops["taskStatus"]
            if 'personID' in ops:
                del ops["personID"]
        elif o['task']:
            ops["taskName"] = o["task"]

        if not o['fields']:
            if not order:
                order = [
                    "priorityLabel", "taskTypeID", "_rate", "taskStatusLabel"
                ]
            fields = [
                "taskID", "taskTypeID", "taskStatusLabel", "priorityLabel",
                "timeExpected", "timeLimit", "timeActual", "rate",
                "projectName", "taskName", "tags"
            ]
        else:
            fields = o["fields"]

        if 'timeBest' not in o['fields'] \
                and 'timeWorst' not in o['fields'] \
                and 'timeExpected' not in o['fields'] \
                and 'timeLimit' not in o['fields'] \
                and 'timeActual' not in o['fields']:
            del ops['showTimes']

        if 'showTimes' not in ops:
            if 'timeWorst' in fields:
                fields.remove('timeWorst')
            if 'timeExpected' in fields:
                fields.remove('timeExpected')
            if 'timeLimit' in fields:
                fields.remove('timeLimit')
            if 'timeActual' in fields:
                fields.remove('timeActual')

        # Get list of tasks
        task_list = self.get_list("task", ops)

        if task_list:
            self.print_table("task", task_list, fields, order)