コード例 #1
0
 def __init__(self, var, config_section_name):
     super(ManagedLandWithFarmerBehaviour, self).__init__(
         var,
         config_section_name)
     
     self.lc_parameters_module = ManagedLandWithFarmerBehaviourParameters(self, config_section_name)
     self.initial_condition_module = InitialConditionManagedLand(self)
     self.root_zone_water_module = RootZoneWaterIrrigatedLand(self)
     self.snow_frost_module = SnowFrost(self)
     
     # self.drainage_module = Drainage(self)
     self.potential_et_module = PotentialEvapotranspiration(self)
     
     # self.evapotranspiration_module = Evapotranspiration(self)
     self.interception_module = Interception(self)
     self.irrigation_demand_module = IrrigationMultipleCrops(self)
     self.irrigation_supply_module = IrrigationSupply(self)
     self.infiltration_module = Infiltration(self)
     self.capillary_rise_module = CapillaryRise(self)
     self.drainage_module = Drainage(self)
     self.actual_et_module = ActualEvapotranspiration(self)
     
     self.crop_yield_module = CropYield(self)
     self.income_module = Income(self)
     self.investment_module = Investment(self)
     self.accounting_module = Accounting(self)
     self.grid_cell_mean_module = GridCellMean(self)
     self.add_dimensions()
コード例 #2
0
ファイル: Parser.py プロジェクト: kingshuk-ban/Projects
def init():
    p = Personal()
    i = Income()
    t = Tax()
    e = Expense()
    d = Debt()
    a = Assets()
    return (p, i, t, d, e, a)
コード例 #3
0
class ManagedLandWithFarmerBehaviour(LandCover):
    def __init__(self, var, config_section_name):
        super(ManagedLandWithFarmerBehaviour, self).__init__(
            var,
            config_section_name)
        
        self.lc_parameters_module = ManagedLandWithFarmerBehaviourParameters(self, config_section_name)
        self.initial_condition_module = InitialConditionManagedLand(self)
        self.root_zone_water_module = RootZoneWaterIrrigatedLand(self)
        self.snow_frost_module = SnowFrost(self)
        
        # self.drainage_module = Drainage(self)
        self.potential_et_module = PotentialEvapotranspiration(self)
        
        # self.evapotranspiration_module = Evapotranspiration(self)
        self.interception_module = Interception(self)
        self.irrigation_demand_module = IrrigationMultipleCrops(self)
        self.irrigation_supply_module = IrrigationSupply(self)
        self.infiltration_module = Infiltration(self)
        self.capillary_rise_module = CapillaryRise(self)
        self.drainage_module = Drainage(self)
        self.actual_et_module = ActualEvapotranspiration(self)
        
        self.crop_yield_module = CropYield(self)
        self.income_module = Income(self)
        self.investment_module = Investment(self)
        self.accounting_module = Accounting(self)
        self.grid_cell_mean_module = GridCellMean(self)
        self.add_dimensions()
        
    def initial(self):
        self.lc_parameters_module.initial()
        self.initial_condition_module.initial()
        self.root_zone_water_module.initial()
        self.snow_frost_module.initial()

        # self.drainage_module.initial()
        
        # self.evapotranspiration_module.initial()
        self.potential_et_module.initial()
        
        self.interception_module.initial()
        self.irrigation_demand_module.initial()
        self.irrigation_supply_module.initial()
        self.infiltration_module.initial()
        self.capillary_rise_module.initial()
        self.drainage_module.initial()
        
        self.actual_et_module.initial()
        
        self.crop_yield_module.initial()
        self.income_module.initial()
        self.investment_module.initial()
        self.accounting_module.initial()
        self.grid_cell_mean_module.initial()
        self.reporting_module = Reporting(
            self,
            self._configuration.outNCDir,
            self._configuration.NETCDF_ATTRIBUTES,
            self._configuration.irrNonPaddy,
            variable_list_crop,
            'irrNonPaddy')
        
    def dynamic(self):
        self.lc_parameters_module.dynamic()
        self.initial_condition_module.dynamic()
        
        self.root_zone_water_module.dynamic()
        self.snow_frost_module.dynamic()
        # self.drainage_module.dynamic()
        # self.evapotranspiration_module.dynamic()
        self.potential_et_module.dynamic()
        self.interception_module.dynamic()
        self.root_zone_water_module.dynamic()
        self.infiltration_module.compute_infiltration_capacity()        
        self.irrigation_demand_module.dynamic()        
        self.irrigation_supply_module.dynamic()

        # the order here (infiltration/cap rise/drainage)
        # is the same as in CWATM
        self.infiltration_module.dynamic()
        self.root_zone_water_module.dynamic()
        self.capillary_rise_module.dynamic()
        self.drainage_module.dynamic()
        
        self.root_zone_water_module.dynamic()
        self.actual_et_module.dynamic()
        self.crop_yield_module.dynamic()
        self.income_module.dynamic()
        self.investment_module.dynamic()
        self.accounting_module.dynamic()
        self.grid_cell_mean_module.dynamic()
        self.reporting_module.report()
コード例 #4
0
                -(self.surplus))
        else:
            output.info("You have surplus %.2f to invest." % (self.surplus))
        pie_n = [n for n, v in self.data.items() if (n != "income")]
        pie_v = [abs(v) for n, v in self.data.items() if (n != "income")]
        pie_n.append("surplus")
        pie_v.append(self.surplus)
        utils.piechart("Budget", "Budget Allocation", pie_n, pie_v)

    def get_monthly(self):
        return self.surplus


# Test
if __name__ == "__main__":
    i = Income()
    i.add("w2", 193000)
    i.deduct("401k", 19500)
    i.deduct("hsa", 7100)
    i.report()

    t = Tax(i.data)
    t.credit("child1", 500)
    t.credit("child2", 500)
    t.calculate()
    t.report()

    d = Debt()
    d.add_fixed("mortgage", 225000, 4.125, 30)
    d.add_variable("cc1", 4000, 10)
    d.add_variable("cc2", 10000, 10)
コード例 #5
0
        if name_type == 'Income' or name_type == 'Expense':
            break
        else:
            print('Please enter valid input')
            continue
    data = {}
    while True:
        try:
            inc_type = input(f"Enter the {name_type} Type: ")
            inc_amount = int(input("Enter the Amount: "))
            data[inc_type] = inc_amount
            flag = input('Wish to continue (y/n)').lower()
            if flag == 'y':
                continue
            elif flag == 'n':
                break
            else:
                print('invalid input')
                continue
        except:
            print('Invalid input')
            continue
    if name_type == 'Expense':
        class_obj = Expense(data)
        dict_value = class_obj.expense_dict
    else:
        class_obj = Income(data)
        dict_value = class_obj.income_dict

    monthly_expense = MonthlyExpense(name_type)
    monthly_expense.input_data(dict_value)
コード例 #6
0
ファイル: Case2_India.py プロジェクト: kingshuk-ban/Projects
# VRO case study
from Income import Income
from Tax import Tax
from Budget import Budget
from Expense import Expense
from Debt import Debt
from Assets import Assets
from Metrics import Metrics
import utils
from Analysis import tortoise_analyze

i = Income()
i.add("salary", 52000 * 12)
i.report()

t = Tax(i.data)
#t.calculate()
t.report()

d = Debt()
d.report()

e = Expense()
e.add("household", 20000)
e.add_yearly("premiums", 165000)
e.report()

b = Budget()
b.add(i, t, d, e)
b.report()
コード例 #7
0
ファイル: test.py プロジェクト: miniman1/Financial-Tracker
from FinanceTrackingSystem import FinanceTrackingSystem
from Expense import Expense
from Income import Income

# test for adding an expense - 1 january 2020
sys = FinanceTrackingSystem()
exp = Expense(1, 1, 2020, 205, "good shit", True)
sys.addLog(exp)
print(sys._yearlyLogs)
print(sys.getDailyLog(1, 1, 2020)._logs[0].getAmount())
print(sys.getMonthlyLog(10, 1997))

# test for removing the expense created above - 1 january 2020
sys.removeLog(exp)
print(sys.getDailyLog(1, 1, 2020)._logs)

#  getting a daily log and getting the correct total expense and income

sys = FinanceTrackingSystem()
sys.addLog(Expense(1, 1, 2020, 200, "good shit", True))
sys.addLog(Expense(1, 1, 2020, 300, "shit", True))
sys.addLog(Income(1, 1, 2020, 100, "god shit"))
sys.addLog(Expense(1, 1, 2020, 100, "gd shit", True))
print(sys.getDailyLog(1, 1, 2020).netProfit())
print(sys.getMonthlyLog(1, 2020).netProfit())
print(sys.getYearlyLog(2020).netProfit())
print(sys.getMonthlyLog(1, 2020).totalExpenses())
コード例 #8
0
ファイル: stapp.py プロジェクト: kingshuk-ban/Projects
                                 10000.0,
                                 format="%f")
st.info("Your monthly gross income is: %.2f" % (income / 12.0))
#deductions = st.sidebar.slider("Total pre-tax deductions (401k, HSA)", 0, min(income, 19500+7100), step=100, format="%d")
deductions = st.sidebar.number_input("Total pre-tax deductions",
                                     0.0,
                                     income,
                                     format="%f")
st.info("Your monthly pre-tax deductions: %.2f " % (deductions / 12.0))
st.info("Your monthly pre-tax income: %.2f" % ((income - deductions) / 12.0))
tax_status = st.sidebar.selectbox(
    "Tax filling status",
    ['single', 'married_separate', 'married_joint', 'head_household'], 2)
# st.write("Tax filling status: ", tax_status)

i = Income()
i.add("Paycheck", income)
i.deduct("deductions", deductions)

st.subheader("Monthly expenses")
t = Tax()
t.addIncome(i.data)
t.addFilling(tax_status)
t.calculate()

st.info("Your total tax outgo per month: %.2f" % (t.total / 12.0))
for n, v in t.taxes.items():
    st.info("%s : %.2f" % (n, v / 12.0))

# Expenses
st.sidebar.subheader("Expenses")
コード例 #9
0
ファイル: BudgetTracker.py プロジェクト: VBoB13/BudgetTracker
def inputIncome(incomeInfo):
    '''
    This function simply takes the income input from the user and splits, converts and uploads it (if input is correct) to the database.
    INPUT: incomeInfo (string)
    Output: income (Income)
    '''

    try:
        # Attempts to split the input data to later decipher and handle
        incomeInfoList = incomeInfo.split(',')
    except Exception as err:
        # Error that's printed if that does not go well.
        print("Wasn't able to properly derive values from input.")
        print(err)
    else:
        if len(incomeInfoList[0]) == 8 and len(incomeInfoList) <= 5:
            try:
                # If the date-spot in the list has the correct length, we attempt to extract the value of entered year, month and date
                # through list index slicing and directly put it into a
                # variable that is of the class 'datetime'
                incomeDate = datetime.date(int(incomeInfoList[0][0:4]), int(
                    incomeInfoList[0][4:6]), int(incomeInfoList[0][6:8]))
            except Exception as err:
                print(
                    "Something went wrong when trying to convert input date format to datetime-class.")
                print(err)
            else:
                try:
                    # Attempt to put the category-data that was prompted by the
                    # user into 'incomeCategory'
                    incomeCategory = incomeInfoList[1]
                except Exception as err:
                    print("Wasn't able to load category data into variable.")
                    print(err)
                else:
                    try:
                        # Attempt to put the amount that was prompted by the
                        # user into 'incomeAmount'
                        incomeAmount = int(incomeInfoList[2])
                    except Exception as err:
                        print("Wasn't able to load income amount data into variable.")
                        print(err)
                    else:

                        try:
                            # Attempt to put the comment-data that was prompted
                            # by the user into 'incomeComment'
                            incomeComment = incomeInfoList[3]
                        except Exception as err:
                            print(
                                "Wasn't able to load income comment data into variable.")
                            print(err)
                        else:
                            # Creating an income object called 'income' for
                            # convenience.
                            if len(incomeInfoList) == 4:
                                income = Income(
                                    incomeDate, incomeCategory, incomeAmount, incomeComment)
                                return income
                            else:
                                try:
                                    # Attempt to put the investment period that
                                    # was prompted by the user into
                                    # 'investment_period'
                                    incomeInvestmentPeriod = incomeInfoList[4]
                                except Exception as err:
                                    print(
                                        "Wasn't able to load income investment period data into variable.")
                                    print(err)
                                else:
                                    # Creating an income object called 'income'
                                    # for convenience.
                                    income = Income(
                                        incomeDate,
                                        incomeCategory,
                                        incomeAmount,
                                        incomeComment,
                                        incomeInvestmentPeriod)
                                    return income

        else:
            print("Invalid date input (too long/short).")
            print(
                "Please enter a date such as if the current date is Oct 7, 2019, enter '20191007'")
            return None