예제 #1
0
파일: statements.py 프로젝트: blippy/pypms
def create_job_statement(job, all_tasks, exps, times):

    title = "Work Statement: {0}".format(period.mmmmyyyy())
    out = rtf.Rtf()
    out.addTitle(title)
    AddTopInfo(out, job)

    tasks = map(lambda o: getattr(o, "task"), times + exps)
    tasks = common.unique(tasks)
    tasks.sort()
    if tasks[0] == "" and len(tasks) > 1:
        tasks = tasks[1:] + [tasks[0]]  # rotate unassigned to end

    # distribute invoice items into sections
    job_code = job["job"]
    sections = []  # a list of Section classes
    totalWork = 0.0
    totalExpenses = 0.0
    for task_key in tasks:

        # work out heading
        if len(task_key) == 0:
            heading = "Expenses not categorised to a specific task"
        else:
            desc = all_tasks[(job_code, task_key)]["TaskDes"]
            heading = "Task {0}: {1}".format(task_key, desc)
        out.add(heading)

        amount_work, num_times = ProcessSubsection(out, times, task_key, "Work subtotal")
        totalWork += amount_work

        amount_expenses, num_expenses = ProcessSubsection(out, exps, task_key, "Expenses subtotal")
        totalExpenses += amount_expenses

        if num_times > 0 and num_expenses > 0:
            subtotal(out, "Task subtotal", amount_work + amount_expenses)
            out.para()

    # output grand summary
    out.add("Overall summary")
    subtotal(out, "Work total", totalWork)
    subtotal(out, "Expenses total", totalExpenses)
    net = totalWork + totalExpenses
    subtotal(out, "Net total", net)

    out.annotation(job)
    outdir = period.perioddir() + "\\statements"
    outfile = job_code + ".rtf"
    out.save(outdir, outfile)

    # remember what we have produced for the invoice summaries
    if job["Weird"] or job["WIP"]:
        billed = 0.0
    else:
        billed = net

    invoice = {"work": totalWork, "expenses": totalExpenses, "net": billed}
    return invoice
예제 #2
0
파일: rtfsprint.py 프로젝트: blippy/pypms
def timesheets(debug = False):
    "Print timesheets"
    jobs = [x['job'] for x in db.GetJobs().values() if x['Autoprint']]
    jobs.sort()
    for job in jobs:
        fname = '{0}\\timesheets\\{1}.rtf'.format(period.perioddir(), job)
        if not os.path.isfile(fname):
            continue
        if debug:
            print fname
        else: print_file(fname)
예제 #3
0
파일: rtfsprint.py 프로젝트: blippy/pypms
def work_statements():
    'Print workstatements'
    pattern = '{0}\\statements\\*.rtf'.format(period.perioddir())
    files = glob.glob(pattern)
    files.sort()
    for fname in files:
        
        # bail out on special files
        fname0 = os.path.basename(fname)[0]
        if fname0 in ['0','5']: 
            continue
        
        print_file(fname)
예제 #4
0
파일: timesheets.py 프로젝트: blippy/pypms
def create_timesheets(d):
    title = 'Timesheet: ' + period.mmmmyyyy()
    outdir = period.perioddir() + '\\timesheets'
    for jobKey, job_items in aggregate(d['timeItems'], common.mkKeyFunc('JobCode')):
        #pdb.set_trace()
        CreateJobsheet(jobKey, job_items, d, title, outdir)