2 #include "../firm_agent_header.h"
48 for (
int i = 0; i < 2; i++) {
66 filename = malloc(100*
sizeof(
char));
69 strcpy(filename,
"./outputs/data/Constructor_Firm_Quarterly_IncomeStatement.txt");
70 file1 = fopen(filename,
"a");
73 strcpy(filename,
"./outputs/data/Firm_Quarterly_IncomeStatement.txt");
74 file1 = fopen(filename,
"a");
115 RETAINED_EARNINGS = 0;
118 printf(
"Firm ID = %d, has no positive earnings to send out to share holders. \n",
ID);
187 printf(
"Firm ID = %d @ Loan Stage 1 received %f of loans. \n",
ID, amount);
224 printf(
"Firm ID = %d @ Loan Stage 2 received %f of loans. \n",
ID, amount);
284 printf(
"Firm ID = %d @ Loan - Equity Fund received %f amount of funding investment. \n",
ID, amount);
299 printf(
"Firm ID = %d is illiquidity bankrupt!\n",
ID);
303 double ratio, current_amount, new_amount, delta_amount;
316 ratio = new_loans /
DEBT;}
321 if (ratio >= 1) {
return 0;}
324 for (
int i = 0; i < 2; i++) {
327 new_amount = current_amount * ratio;
330 delta_amount = current_amount - new_amount;
332 if (delta_amount > 0.1) {
335 if (delta_amount < 0) {
336 printf(
"Warning @firm_credit_illiquidity_bankrupt(): The illiquid Firm ID = %d new loan request is higher than its existing loan to Bank ID = %d, The difference is = %f \n",
ID, bank, delta_amount);
343 printf(
"Firm ID = %d illiquidity bankrupt burden on Bank = %d is = %f \n",
ID,bank, delta_amount);
349 filename = malloc(100*
sizeof(
char));
351 strcpy(filename,
"./outputs/data/BankruptcyInspection.txt");
352 file1 = fopen(filename,
"a");
353 fprintf(file1,
"%d %d %s %s %d %f\n",
IT_NO,
ID,
"Firm",
"Illiquidity", bank, delta_amount);
373 for (
int i = 0; i < 2; i++) {
401 filename = malloc(100*
sizeof(
char));
404 strcpy(filename,
"./outputs/data/Constructor_Firm_Quarterly_Dividends.txt");
405 file1 = fopen(filename,
"a");
408 strcpy(filename,
"./outputs/data/Firm_Quarterly_Dividends.txt");
409 file1 = fopen(filename,
"a");
446 filename = malloc(100*
sizeof(
char));
449 strcpy(filename,
"./outputs/data/Constructor_Firm_Quarterly_BalanceSheet.txt");
450 file1 = fopen(filename,
"a");
451 fprintf(file1,
"%d %d %d %d %d %f %d %d %f %f %d %f %f %d %f %f\n",
IT_NO,
ID,
ISLIQUIDSHORT,
HASLOAN,
HASINVESTMENT,
LIQUIDITY_NEED,
ISINSOLVENT,
ISILLIQUID,
TOTAL_ASSETS,
LIQUIDITY,
INVENTORY,
UNIT_HOUSE_PRICE, CAPITAL_GOODS_PRICE,
CAPITAL_GOODS, DEBT,
EQUITY);
453 strcpy(filename,
"./outputs/data/Firm_Quarterly_BalanceSheet.txt");
454 file1 = fopen(filename,
"a");
455 fprintf(file1,
"%d %d %d %d %d %f %d %d %f %f %d %f %f %d %f %f\n",
IT_NO,
ID,
ISLIQUIDSHORT,
HASLOAN,
HASINVESTMENT,
LIQUIDITY_NEED,
ISINSOLVENT,
ISILLIQUID,
TOTAL_ASSETS,
LIQUIDITY,
INVENTORY,
UNIT_GOODS_PRICE, CAPITAL_GOODS_PRICE,
CAPITAL_GOODS, DEBT,
EQUITY);
484 printf(
"Firm ID = %d is insolvent bankrupt!! \n",
ID);
512 for (
int i = 0; i < 2; i++) {
515 if (amount > 0.001) {
523 filename = malloc(100*
sizeof(
char));
525 strcpy(filename,
"./outputs/data/BankruptcyInspection.txt");
526 file1 = fopen(filename,
"a");
527 fprintf(file1,
"%d %d %s %s %d %f\n",
IT_NO,
ID,
"Firm",
"Insolvency", bank, amount);