Пример #1
0
def _addPaycheck(date, gross, tax, healthcare, fica, k401):

    paycheck = Paychecks()

    paycheck.date = date
    paycheck.gross = gross
    paycheck.healthcare = healthcare
    paycheck.fica = fica
    paycheck.k401 =k401

    paycheck.net = gross - (tax + k401 + healthcare + fica)

    paycheck.save()
Пример #2
0
def save_transaction(transaction):
    date = transaction["date"]
    description = transaction["description"]
    amount = transaction["amount"]
    transaction_type = transaction["transaction_type"]
    category = transaction["category"]
    notes = transaction["notes"]
    mint_id = transaction["mint_id"]

    #date needs to be passed in with the proper format (from mm/dd/yyyy to yyyy-mm-dd)
    #date = date.split("/")
    #date = date[2]+'-'+date[0]+'-'+date[1]
    #date = date

    amount = float(amount)

    if transaction_type == "credit":
        amount = -amount

    category =  category.lower()

    #concatenate "description - notes"
    if notes :
        description += " - "
        description += notes;

    #remap mint categories to budgetapp categories
    if category in CATEGORY_MAP:
        category = CATEGORY_MAP[category]

    #the below isn't necessary, I made mint categories
    #if description.find("National Grid") >= 0:
    #    category = "heat";
    #if description.find("NSTAR") >= 0:
    #    category = "electric"


    #skip categories
    if category in SKIP_MAP:
        category = "skip"
    
    if description.find("Reimbursable") >= 0:
        category = "skip"

    #if category == income
    if category == "income" or category == 'paycheck':
        #insert into paychecks
        paycheck = Paychecks()

        paycheck.net = amount * -1
        paycheck.gross = amount * -1
        paycheck.date = date
        paycheck.mint_id = mint_id
        if Paychecks.objects.filter(mint_id=mint_id):
            import pdb; pdb.set_trace()        
        paycheck.save()

    #else if category == skip
    elif category == "skip":
        return False
    else:
        #else add to purchases
        purchase = Purchases();

        try:
            category_object = SubCategory.objects.get(subCategory=category)
        except SubCategory.DoesNotExist:
            import pdb; pdb.set_trace()
            category_object = SubCategory.objects.get(subCategory="unknown")


        purchase.date = date
        purchase.item_desc = description
        purchase.cost = amount
        purchase.category = category_object
        purchase.mint_id = mint_id

        if Purchases.objects.filter(mint_id=mint_id):
            import pdb; pdb.set_trace()        
        purchase.save()

    return True