Skip to content
Permalink
Browse files
Create ledger accounts
  • Loading branch information
Anh3h committed Nov 23, 2019
1 parent 524c128 commit 0279198e7b860f73378a77def667f2e93bee723b
Showing 2 changed files with 132 additions and 1 deletion.
@@ -0,0 +1,55 @@
parentIdentifier,identifier,description,type,show
,1000,"Income",REVENUE,true
1000,1100,"Income from Loans",REVENUE,true
1000,1200,"Investment Income",REVENUE,true
1000,1300,"Fees and Charges",REVENUE,true
1000,1400,"Gain (Loss) on Sale of Loans",REVENUE,true
1000,1500,"Miscellaneous Income",REVENUE,true
1000,1600,"Service Income on Loans",REVENUE,true
1000,1700,"Trading Profits & Losses",REVENUE,true
,2000,"Expenses",EXPENSE,true
2000,2100,"Employee Compensation",EXPENSE,true
2000,2200,"Employee Benefits",EXPENSE,true
2000,2300,"Travel and Conference Expenses",EXPENSE,true
2000,2400,"Association Dues",EXPENSE,true
2000,2500,"Office Occupancy Expenses",EXPENSE,true
2000,2600,"Office Operations Expenses",EXPENSE,true
2000,2700,"Educational and Promotional Expenses",EXPENSE,true
2000,2800,"Loan Servicing Expenses",EXPENSE,true
2000,2900,"Professional and Outside Services",EXPENSE,true
2000,3000,"Provision for Loan Losses",EXPENSE,true
2000,3100,"Member Insurance",EXPENSE,true
2000,3220,"Federal Operating Fee",EXPENSE,true
2000,3300,"Cash Over and Short",EXPENSE,true
2000,3400,"Interest on Borrowed Money",EXPENSE,true
2000,3550,"Annual Meeting Expenses",EXPENSE,true
2000,3700,"Miscellaneous Operating Expenses",EXPENSE,true
2000,3800,"Interest (Dividend) Expense",EXPENSE,true
,7000,"Assets",ASSET,true
7000,7010,"Loans to Members",ASSET,true
7000,7020,"Lines of Credit to Members",ASSET,true
7000,7030,"Real Estate Loans",ASSET,true
7000,7100,"Other Loans",ASSET,true
7000,7200,"Other Receivables",ASSET,true
7000,7300,"Cash Accounts",ASSET,true
7300,7310,"Bank account one",ASSET,true
7300,7311,"Bank account two",ASSET,true
7300,7350,"Change Fund",ASSET,true
7000,7400,"Investments",ASSET,true
7400,7420,"Federal Agency Securities",ASSET,true
7000,7500,"Investments—Investment Allowance",ASSET,true
7000,7600,"Prepaid Expenses and Deferred Charges",ASSET,true
7000,7700,"Fixed Assets",ASSET,true
7000,7800,"Accrued Income",ASSET,true
7000,7900,"Other Assets",ASSET,true
,8000,"Accounts Payable",LIABILITY,true
8000,8100,"Accounts Payable",LIABILITY,true
8000,8200,"Interest Payable",LIABILITY,true
8000,8400,"Taxes Payable",LIABILITY,true
8000,8500,"Accrued Expenses",LIABILITY,true
,9000,"Equity",EQUITY,true
9000,9100,"Member Savings",EQUITY,true
9000,9300,"Reserves",EQUITY,true
9000,9400,"Undivided Earnings",EQUITY,true
9000,9550,"Donated Equity",EQUITY,true
9000,9560,"Net Income (Loss)",EQUITY,true
@@ -261,6 +261,80 @@ function set-application-permission-enabled-for-user {
echo "Enabled permission, $permission for service $service"
}

function create_chart_of_accounts {
local ledger_file="ledgers.csv"
local accounts_file="accounts.csv"
local tenant="$1"
local user="$2"

while IFS="," read -r parent_id id description ledger_type show; do
if [ "$parent_id" != "parentIdentifier" ]; then
if [ -z "$parent_id" ]; then
create_ledger "$tenant" "$user" "$id" "$description" "$ledger_type" "$show"
sleep 5s
else
update_ledger "$tenant" "$user" "$id" "$parent_id" "$description" "$ledger_type" "$show"
fi
fi

done < "$ledger_file"
}

function create_ledger {
local tenant="$1"
local user="$2"
local id="$3"
local description="$4"
local ledger_type="$5"
local show="$6"

curl -X POST -H "Content-Type: application/json" -H "User: $user" -H "Authorization: ${ACCESS_TOKEN}" -H "X-Tenant-Identifier: $tenant" \
--data '{
"type": "'"$ledger_type"'",
"identifier": "'"$id"'",
"name": "'"$id"'",
"description": '"$description"',
"subLedgers": [],
"totalValue": 0,
"createdOn": "",
"createdBy": "",
"lastModifiedOn": "",
"lastModifiedBy": "",
"showAccountsInChart": '$show'
}' \
${ACCOUNTING_URL}/ledgers
echo ""
echo "Created ledge account $id : $description"
}

function update_ledger {
local tenant="$1"
local user="$2"
local id="$3"
local parent_id="$4"
local description="$5"
local ledger_type="$6"
local show="$7"

curl -X POST -H "Content-Type: application/json" -H "User: $user" -H "Authorization: ${ACCESS_TOKEN}" -H "X-Tenant-Identifier: $tenant" \
--data '{
"type": "'"$ledger_type"'",
"identifier": "'"$id"'",
"name": "'"$id"'",
"description": '"$description"',
"parentLedgerIdentifier": "'"$parent_id"'",
"subLedgers": [],
"totalValue": 0,
"createdOn": "",
"createdBy": "",
"lastModifiedOn": "",
"lastModifiedBy": "",
"showAccountsInChart": '$show'
}' \
${ACCOUNTING_URL}/ledgers/${parent_id}
echo "Add ledge account $id : $description to $parent_id"
}

init-variables
auto-seshat
create-application "$IDENTITY_MS_NAME" "" "$MS_VENDOR" "$IDENTITY_URL"
@@ -277,7 +351,7 @@ create-application "$PAYROLL_MS_NAME" "" "$MS_VENDOR" "$PAYROLL_URL"
create-application "$GROUP_MS_NAME" "" "$MS_VENDOR" "$GROUP_URL"
create-application "$NOTIFICATIONS_MS_NAME" "" "$MS_VENDOR" "$NOTIFICATIONS_URL"

#Set tenant identifier
# Set tenant identifier
TENANT=$1
create-tenant ${TENANT} "${TENANT}" "All in one Demo Server" ${TENANT}
assign-identity-ms ${TENANT}
@@ -313,3 +387,5 @@ provision-app ${TENANT} $PAYROLL_MS_NAME
provision-app ${TENANT} $GROUP_MS_NAME
provision-app ${TENANT} $NOTIFICATIONS_MS_NAME
echo "COMPLETED PROVISIONING PROCESS."
login ${TENANT} "operator" "aW5pdDFAbDIz"
create_chart_of_accounts ${TENANT} "operator"

0 comments on commit 0279198

Please sign in to comment.