Exemple #1
0
def inv_currency(invoice, theuser):
    # currency is basically a meaningless string right now. 
    # if we were to have an invoice with rusages from 2 currency zones
    # we would just add the two currency values together
    # i.e. the application is not internationalised 
    if invoice:
       invoice = Invoice.get(invoice)
       return invoice.location.currency 
    return theuser.homeplace.currency
Exemple #2
0
def vat_switch():
    """add total taxes, resource_tax_dict, vat_included
    """
    from hubspace.model import Invoice, Location
    from hubspace.invoice import calculate_tax_and_amount
    #recalculate all the old invoice costs and amounts, as used to happen everytime we did looked at the invoice!

    london  = Location.get(1)
    bristol = Location.get(2)
    kx = Location.get(11)
    switch_time = datetime(2008, 12, 1, 0, 0) 
    special = Invoice.select(AND(IN(Invoice.q.locationID, [1, 2, 11]),
                                 Invoice.q.created < switch_time))

    not_special = Invoice.select(OR(NOT(IN(Invoice.q.locationID, [1, 2, 11])),
                                    Invoice.q.created >= switch_time))
    for inv in not_special:
        tmp = inv.sent
        inv.sent = None
        calculate_tax_and_amount(inv)
        inv.sent = tmp

    london.vat_default = 17.5
    bristol.vat_default = 17.5
    kx.vat_default = 17.5

    #might need to re-patch this bit later for bristol as I think they sent out some invoices at 17.5% after the 1st December
    for inv in special:
        tmp = inv.sent
        inv.sent = None
        calculate_tax_and_amount(inv)
        inv.sent = tmp

    london.vat_default = 15
    bristol.vat_default = 15
    kx.vat_default = 15
Exemple #3
0
def bristol_vat_switch():
    """get the bristol invoices that were sent at 15% before mid day on the 2nd of december and set them to 17.5%
    """
    from hubspace.model import Invoice, Location
    from hubspace.invoice import calculate_tax_and_amount
    #recalculate all the old invoice costs and amounts, as used to happen everytime we did looked at the invoice!

    bristol = Location.get(2)
    start_switch_time = datetime(2008, 12, 1, 0, 0)
    end_switch_time = datetime(2008, 12, 2, 12, 0) 
    special = Invoice.select(AND(Invoice.q.locationID == 2,
                                 Invoice.q.created < end_switch_time,
                                 Invoice.q.created > start_switch_time))


    bristol.vat_default = 17.5

    for inv in special:
        tmp = inv.sent
        inv.sent = None
        calculate_tax_and_amount(inv)
        inv.sent = tmp

    bristol.vat_default = 15.0
Exemple #4
0
def unsent_for_user(user):
    invoice = Invoice.select(AND(Invoice.q.userID==user.id,
                                 Invoice.q.sent==None))
    if invoice.count():
        return invoice[0]
    return False