-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgovernment.cpp
More file actions
132 lines (110 loc) · 3.87 KB
/
government.cpp
File metadata and controls
132 lines (110 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//
// government.cpp
// Test Product
//
// Created by David Brown on 05/06/2017.
// Copyright © 2017 David Brown. All rights reserved.
//
#include "account.hpp"
Government *Government::_instance = nullptr;
Government *Government::Instance()
{
if (_instance == nullptr) {
_instance = new Government();
_instance->gov_firm = nullptr;
}
return _instance;
}
void Government::init()
{
exp = 0;
rec = 0;
ben = 0;
// This must be the first Firm created, as this ensures that government
// money is always spent at the start of the period. However, we defer it
// t here because if it's in the constructure you get a recursive
// declaration: Givernment instantiates Firm, which instantiates
// Government).
if (gov_firm == nullptr) {
gov_firm = reg->createFirm();
}
}
Government::Government()
{
reg = Register::Instance();
}
// TO DO NEXT. OR AT LEAST VERY SOON
// ---------------------------------
// This method creates and registers a new independent firm with, at present,
// no visible means of support. To fix this we will need to provide a means
// of accessing government funds. Conventionally this is achieved via banks,
// so what we probably need to do is implement the Bank class and set the
// new firm up with a 'line of credit'. I think this means that the firm can
// keep borrowing more money as long as it keeps up the repayments on the
// existing loan and pays the interest due. I suspect this is inherently
// unstable and is only sustainable as long as the firm continues to grow.
// Eventually the market becomes saturated and the firm dies -- or possibly
// it just sucks in business from other less successful firms in the same
// field, and they die.
size_t Government::getNumEmployees()
{
return gov_firm->getNumEmployees();
}
int Government::getExpenditure()
{
return exp;
}
int Government::getBenefitsPaid()
{
return ben;
}
int Government::getReceipts()
{
return rec;
}
void Government::trigger(int period)
{
//std::cout << "\nGovernment::trigger(" << period << ")\n";
init();
reg->init();
// Government grants (incl support of gov-owned businesses)
int amt = settings->getGovExpRate();
gov_firm->grant(amt);
balance -= amt;
exp += amt;
// Pay benefits to all unemployed workers
ben += reg->payWorkers((settings->getStdWage() * settings->getUBR()) / 100,
0, // no max amount
this, // source
Register::benefits, // reason
period
);
balance -= ben;
reg->trigger(period);
}
//
// This function overrides Account::transferTo to allow a negative balance.
//
void Government::transferTo(Account *recipient, int amount, Account *creditor)
{
// We adopt the convention that receipts from the government are not
// taxable. This is probably a rather murky area, given that the
// mechanisms by which government injects money into the economy are
// unclear and seem to involve financing banks to make more loans.
// In the case of the NHS, nationalised industries, the civil service
// and the 'armed forces' the mechanism is probably more direct.
// Anyway, to go into this would be a distraction so we'll simply
// treat it as untaxable payment for services.
recipient->credit(amount, this);
balance -= amount;
}
// All credits to the Government are (at present) regarded as tax. This
// means that while they offset the deficit we need to keep a separate
// record as well. However we don't distinguish between income tax, sales
// tax, and 'pre-tax deductions'. These are all accounted for elsewhere.
// Obviously, the government doesn't pay tax.
void Government::credit(int amount, Account *creditor)
{
Account::credit(amount);
rec += amount;
}