Пример #1
0
def SQL_FindMonthly(sSellingPrice, sInvoice, iCashCost, sTradeIn, sPayoff, fDownCash, sFico, sTerm):
    # Find required MonthlyPayments for a given DownCash figure
    # Logic: LoanAmount = Price - [ DownCash + TradeIn - TradeInPayoff ]
    #        LTV = LoanAmount / Invoice
    #        Use LTV and FICO to find [Monthly%] in the M72 table
    #        The M72 tables incorporates the active APR grid
    #        Monthly% is the Monthly payment as a % of LoanAmount
    #        MonthlyPayment = [Monthly%] * LoanAmount
    try:
        Invoice = float(fixZero(sInvoice, fixZero(sSellingPrice, iCashCost)))
        if Invoice == 0:
            return "0"
        TradeInNet = float0(sTradeIn) - float0(sPayoff)
        DownPayment = float0(fDownCash) + TradeInNet
        LoanAmount = iCashCost - DownPayment
        LTV = LoanAmount / Invoice
        sFico = fixNull(sFico, str(cfg.LowestFicoAnywhere))
        Results = MyAPR.GetMonthly(sFico, LTV, sTerm) * LoanAmount
        return int(round(Results))
    except ValueError:
        return ""
    except:
        print "Unexpected error in SQL_FindMonthly:"
        print "sSellingPrice = " + str(sSellingPrice)
        print "sInvoice = " + str(sInvoice)
        print "iCashCost = " + str(iCashCost)
        print "sTradeIn = " + str(sTradeIn)
        print "sPayoff = " + str(sPayoff)
        print "fDownCash = " + str(fDownCash)
        print "sFico = " + str(sFico)
        print "sTerm = " + str(sTerm)
        raise
Пример #2
0
def SQL_FindAPR(sSellingPrice, sInvoice, iCashCost, sTradeIn, sPayoff, fDownCash, sFico, sTerm):
    # Find the APR for a given DownCash figure
    # Logic: LoanAmount = Price - [ DownCash + TradeIn - TradeInPayoff ]
    #        LTV = LoanAmount / Invoice
    #        Use LTV and FICO to find APR in the APR table
    global GlobalAPR
    try:
        Invoice = float(fixZero(sInvoice, fixZero(sSellingPrice, iCashCost)))
        if Invoice == 0:
            return "0"
        TradeInNet = float0(sTradeIn) - float0(sPayoff)
        DownPayment = float0(fDownCash) + TradeInNet
        LoanAmount = iCashCost - DownPayment
        LTV = LoanAmount / Invoice
        sFico = fixNull(sFico, str(cfg.LowestFicoAnywhere))
        Results = MyAPR.GetAPR(sFico, LTV, sTerm)
        return str(Results)
    except ValueError:
        return ""
    except:
        print "Unexpected error in SQL_FindAPR:"
        print "sSellingPrice = " + str(sSellingPrice)
        print "sInvoice = " + str(sInvoice)
        print "iCashCost = " + str(iCashCost)
        print "sTradeIn = " + str(sTradeIn)
        print "sPayoff = " + str(sPayoff)
        print "fDownCash = " + str(fDownCash)
        print "sFico = " + str(sFico)
        print "sTerm = " + str(sTerm)
        raise
Пример #3
0
def SQL_FindDown(sSellingPrice, sInvoice, iCashCost, sTradeIn, sPayoff, fMonthly, sFico, sTerm):
    # Find required DownCash for a given MonthlyPayment figure
    # This is the reverse of SQL_DealUpfront()
    # Note: This one is tricky, since APR computation requires knowing LTV,
    #       but LTV is driven by DownCash -- which is the solution we seek
    #       It is assumed that APR is monotone increasing with LTV
    #
    # Logic: Try each LTV granularity possibility starting with the lowest LTV
    #       The list length is the number of LTV granulations (=17)
    #       For each LTV in the list:
    #           Use FICO and LTV to find [Monthly%] in the M72 Table
    #           LoanAmount = MonthlyPayment / [%Monthly]
    #           ConsequentLTV = LoanAmount / Invoice
    #           If ConsequentLTV > LTV, not a solution; continue to next LTV
    #       If reached highest LTV, and still not a solution; use highest LTV
    #       Once a solution is found (or using highest):
    #           DownCash = Price - LoanAmount - [TradeIn - TradeInPayoff]
    try:
        Invoice = float(fixZero(sInvoice, fixZero(sSellingPrice, iCashCost)))
        if Invoice == 0:
            return "0"
        TradeInNet = float0(sTradeIn) - float0(sPayoff)
        Monthly = float0(fMonthly)
        sFico = fixNull(sFico, str(cfg.LowestFicoAnywhere))

        NeedSolution = True
        TryLTV = MyAPR.LowLTV
        while TryLTV <= MyAPR.HighLTV and NeedSolution:
            LoanAmount = Monthly / MyAPR.GetMonthly(sFico, TryLTV, sTerm)
            NeedSolution = (LoanAmount / Invoice) > TryLTV
            TryLTV += MyAPR.StepLTV

        Results = iCashCost - LoanAmount - TradeInNet
        return int(round(Results))
    except ValueError:
        return ""
    except:
        print "Unexpected error in SQL_FindDown:"
        print "sSellingPrice = " + str(sSellingPrice)
        print "sInvoice = " + str(sInvoice)
        print "iCashCost = " + str(iCashCost)
        print "sTradeIn = " + str(sTradeIn)
        print "sPayoff = " + str(sPayoff)
        print "fMonthly = " + str(fMonthly)
        print "sFico = " + str(sFico)
        raise


#MySelections = VehicleArray(SessionFilterArray, SessionConsumer, MyAPR)
#MySelections0 = MySelections
Пример #4
0
def SQL_BestSellingPrice(sSellingPrice, sInvoice):
    # Data Cleaning process to ascertain the vehcile selling price
    # Logic: If SellingPrice is clean and >0, use it
    #       Else, if Invoice is clean, use it,
    #       Else, use "0" (for lack of a better alternative)
    try:
        Results = float(fixZero(sSellingPrice, fixZero(sInvoice, 0)))
        return int(round(Results))
    except ValueError:
        return 0
    except:
        print "Unexpected error in SQL_SalesTax:"
        print "sSellingPrice = " + str(sSellingPrice)
        print "sInvoice = " + str(sInvoice)
        raise
Пример #5
0
def SQL_CashCost(sBestSellingPrice, sDistance, sTax):
    # Find the Cash Cost of a vehicle
    # Logic: CashCost = SellingPrice + Transport + SalesTax
    #       Transport is computed using SQL_Transport() from coords
    #       SalesTax is computed using SQL_SalesTax() from price, tradeIn, Rate
    try:
        TransportCost = float0(fixZero(SQL_Transport(sDistance), cfg.ShippingMissing))
        SalesTax = float0(sTax)
        SellingPrice = float0(sBestSellingPrice)
        Results = SellingPrice + TransportCost + SalesTax
        return int(round(Results))
    except ValueError:
        return 0
    except:
        print "Unexpected error in SQL_CashCost:"
        print "sBestSellingPrice = " + str(sBestSellingPrice)
        print "sDistance = " + str(sDistance)
        print "sTax = " + str(sTax)
        raise