Esempio n. 1
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
Esempio n. 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