def tiempo_para_pagar() -> FullResponseJSON: calculator = LoanCalculator(**request.get_json()) nper = calculator.get_nper_loans() num_of_years = calculator.num_of_years time_scale = calculator.time_scale periods = calculator.get_periods() payments, payments_r, payments_e = calculator.get_payments() a_payments = aggregate(payments, periods) interests = calculator.interests a_interests = aggregate(interests, periods) balances = calculator.balances table = format_tables(calculator, 1, "loans") table_m = format_tables(calculator, calculator.freq / 12, "loans") table_a = format_tables(calculator, calculator.freq / 1, "loans") return ( jsonify({ "nper": nper, "num_of_years": num_of_years, "time_scale": time_scale, "total_pmt": sum(payments), "total_int": sum(interests), "total_prin": calculator.loan, "periods": periods, "a_payments": a_payments, "a_interests": a_interests, "balances": balances, "table": table, "table_m": table_m, "table_a": table_a, }), 200, HEADERS, )
def fondo_para_retiros() -> FullResponseJSON: calculator = RetirementCalculator(**request.get_json()) time_scale = calculator.time_scale ret_fund = calculator.get_ret_fund() periods = calculator.periods calculator.get_withdrawals() interests = calculator.get_interests_retirements() withdrawals = calculator.withdrawals a_withdrawals = aggregate(withdrawals, periods) a_interests = aggregate(interests, periods) balances = calculator.get_balances_retirements() table = format_tables(calculator, 1, "retirements") table_m = format_tables(calculator, calculator.freq / 12, "retirements") table_a = format_tables(calculator, calculator.freq / 1, "retirements") return ( jsonify( { "time_scale": time_scale, "total_wdr": sum(withdrawals), "total_int": sum(interests), "ret_fund": ret_fund, "periods": periods, "a_withdrawals": a_withdrawals, "a_interests": a_interests, "balances": balances, "table": table, "table_m": table_m, "table_a": table_a, } ), 200, HEADERS, )
def tiempo_para_lograr_meta() -> FullResponseJSON: calculator = SavingCalculator(**request.get_json()) nper = calculator.get_nper_savings() num_of_years = calculator.num_of_years time_scale = calculator.time_scale periods = calculator.get_periods() deposits = calculator.get_deposits() a_deposits = aggregate(deposits, periods) interests = calculator.get_interests_savings() a_interests = aggregate(interests, periods) balances = calculator.get_balances_savings() table = format_tables(calculator, 1, "savings") table_m = format_tables(calculator, calculator.freq / 12, "savings") table_a = format_tables(calculator, calculator.freq / 1, "savings") return ( jsonify({ "nper": nper, "num_of_years": num_of_years, "time_scale": time_scale, "total_dep": sum(deposits), "total_int": sum(interests), "fin_bal_r": balances[-1], "periods": periods, "a_deposits": a_deposits, "a_interests": a_interests, "balances": balances, "table": table, "table_m": table_m, "table_a": table_a, }), 200, HEADERS, )
def calculadora_de_ahorros() -> FullResponseJSON: calculator = SavingCalculator(**request.get_json()) time_scale = calculator.time_scale periods = calculator.periods deposits = calculator.get_deposits() a_deposits = aggregate(deposits, periods) interests = calculator.get_interests_savings() a_interests = aggregate(interests, periods) balances = calculator.get_balances_savings() table = format_tables(calculator, 1, "savings") table_m = format_tables(calculator, calculator.freq / 12, "savings") table_a = format_tables(calculator, calculator.freq / 1, "savings") return ( jsonify({ "time_scale": time_scale, "total_dep": sum(deposits), "total_int": sum(interests), "fin_bal": balances[-1], "periods": periods, "a_deposits": a_deposits, "a_interests": a_interests, "balances": balances, "table": table, "table_m": table_m, "table_a": table_a, }), 200, HEADERS, )
def calculadora_de_prestamos() -> FullResponseJSON: calculator = LoanCalculator(**request.get_json()) time_scale = calculator.time_scale reg_pmt = calculator.get_reg_pmt() calculator.get_payments() periods = calculator.periods interests = calculator.interests a_interests = aggregate(interests, periods) balances = calculator.balances payments = calculator.payments _ = calculator.payments_e _ = calculator.payments_r a_payments = aggregate(payments, periods) num_of_years = calculator.num_of_years num_of_years_t = calculator.num_of_years_t nper = num_of_years * calculator.freq nper_t = calculator.nper_t total_pmt = nper * reg_pmt total_int = total_pmt - calculator.loan table = format_tables(calculator, 1, "loans") table_m = format_tables(calculator, calculator.freq / 12, "loans") table_a = format_tables(calculator, calculator.freq / 1, "loans") return ( jsonify({ "time_scale": time_scale, "total_pmt": total_pmt, "total_int": total_int, "num_of_years": num_of_years, "num_of_years_t": num_of_years_t, "years_saved": num_of_years - num_of_years_t, "cash_saved": total_pmt - sum(payments), "nper": nper, "nper_t": nper_t, "total_pmt_t": sum(payments), "total_int_t": sum(interests), "total_prin": calculator.loan, "total_prin_t": calculator.loan, "reg_pmt": reg_pmt, "periods": periods, "a_payments": a_payments, "a_interests": a_interests, "balances": balances, "table": table, "table_m": table_m, "table_a": table_a, }), 200, HEADERS, )
def duracion_de_fondos() -> FullResponseJSON: calculator = RetirementCalculator(**request.get_json()) nper = calculator.get_nper_retirements() num_of_years = calculator.num_of_years ret_fund = calculator.ret_fund time_scale = calculator.time_scale periods = calculator.get_periods() calculator.get_withdrawals() interests = calculator.get_interests_retirements() withdrawals = calculator.withdrawals a_withdrawals = aggregate(withdrawals, periods) a_interests = aggregate(interests, periods) balances = calculator.get_balances_retirements() table = format_tables(calculator, 1, "retirements") table_m = format_tables(calculator, calculator.freq / 12, "retirements") table_a = format_tables(calculator, calculator.freq / 1, "retirements") return ( jsonify( { "nper": nper, "num_of_years": num_of_years, "time_scale": time_scale, "total_wdr": sum(withdrawals), "total_int": sum(interests), "ret_fund": ret_fund, "periods": periods, "a_withdrawals": a_withdrawals, "a_interests": a_interests, "balances": balances, "table": table, "table_m": table_m, "table_a": table_a, } ), 200, HEADERS, )
def tarjeta_de_credito() -> FullResponseJSON: calculator = CreditCardCalculator(**request.get_json()) time_scale = calculator.time_scale first_p = calculator.get_payment_cc() periods = calculator.periods nper = periods[-1] num_of_years = nper / 12 payments = calculator.payments a_payments = aggregate(payments, periods) interests = calculator.interests a_interests = aggregate(interests, periods) balances = calculator.balances table = format_tables(calculator, 1, "cc") table_m = format_tables(calculator, calculator.freq / 12, "cc") table_a = format_tables(calculator, calculator.freq / 1, "cc") return ( jsonify({ "time_scale": time_scale, "first_p": first_p, "total_pmt": sum(payments), "total_int": sum(interests), "total_prin": calculator.cc_debt, "nper": nper, "num_of_years": num_of_years, "periods": periods, "a_payments": a_payments, "a_interests": a_interests, "balances": balances, "table": table, "table_m": table_m, "table_a": table_a, }), 200, HEADERS, )