Skip to content
Permalink
Browse files
Create account after provisioning
  • Loading branch information
Anh3h committed Nov 23, 2019
1 parent 0279198 commit 41e6f09be4bc719ad6d5dc915bacfd91265f1cbb
Showing 2 changed files with 141 additions and 14 deletions.
@@ -0,0 +1,85 @@
parentIdentifier,identifier,name
1100,1101,"Interest on Business Loans"
1100,1102,"Interest on Agriculture Loans"
1100,1103,"Interest on Consumer Loans"
1100,1104,"Interest on Savings Secured"
1100,1105,"Interest on Other Member Loans"
1100,1120,"Interest on Lines of Credit"
1100,1121,"Interest on Credit Cards"
1100,1140,"Interest on Real Estate Loans"
1100,1190,"Interest Refunds"
1200,1210,"Income from Government Investments"
1200,1220,"Income from Govenment Agency Securities"
1200,1230,"Income from Savings/Deposits/Certificates"
1200,1290,"Income from Other Investments"
1300,1310,"Loan Origination Fees"
1300,1311,"Loan Late Payment Fee"
1300,1312,"Processing Fee"
1300,1313,"Disbursement Fee"
1300,1320,"Loan Refinance Fee"
1300,1390,"Other Loan Fee"
2800,2820,"Collection Expenses"
2800,2830,"Recording Fees—Chattel Lien Insurance"
2800,2840,"Credit Reports"
2800,2850,"Refunds—Real Estate Service Charges"
2800,2860,"Credit Card Program Expenses"
2800,2870,"Service Fees on Loans Purchased"
2800,2890,"Other Loan Servicing Expenses"
3000,3010,"Provision for Loan Losses—Consumer Loans"
3000,3020,"Provision for Loan Losses—Lines of Credit"
3000,3030,"Provision for Loan Losses—Real Estate Loans"
3000,3040,"Provision for Loan Losses—Other Loans"
3000,3090,"Other Provision for Losses"
3100,3110,"Saving Insurance"
3100,3120,"Life Savings Insurance"
3100,3130,"Borrowers' Insurance"
3100,3190,"Other Members' Insurance"
3800,3801,"Share Dividend"
3800,3810,"Regular Saving Interest"
3800,3820,"Checking Interest"
3800,3830,"Club Account Interest"
3800,3840,"Saving Certificate Interest"
3800,3890,"Other Interest Expense"
7000,7011,"Commercial Loans"
7000,7012,"Agriculture Loans"
7000,7013,"Consumer Loans"
7000,7014,"Other Member Loans"
7000,7015,"Home Equity Loans"
7000,7021,"Lines of Credit to Members—Credit Cards"
7000,7022,"Lines of Credit—Cash Advances in Process"
7000,7023,"Net Origination Fees (Costs)—Lines of Credit"
7000,7024,"Net Commitment Fees (Costs)—Lines of Credit"
7000,7031,"Net Origination Fees (Costs)"
7000,7070,"Loans—Collateral in Process of Liquidation"
7310,7310.1,"Bank account one general"
7310,7310.2,"Bank account one Pending Disbursal"
7310,7311.1,"Bank account two general"
7310,7311.2,"Bank account two Pending Disbursal"
7300,7312,"Petty Cash"
7300,7351,"Vault Cash"
7300,7352,"Teller One"
7300,7353,"Teller Two"
7300,7354,"Teller Three"
7800,7810,"Accrued Interest on Loans"
7800,7820,"Accrued Income on Investments"
7800,7830,"Accrued Credit Card Income"
7800,7840,"Accrued Late Fee Income"
7800,7890,"Other Accrued Income"
8200,8201,"Dividends Payable on Shares"
8200,8202,"Interest Payable on Savings"
8200,8203,"Interest Payable on Club Accounts"
8200,8207,"Interest Payable on Other Accounts"
8400,8410,"VAT Taxes payable"
8400,8420,"Withholding taxes payable"
8400,8490,"Other Taxes Payable"
8500,8530,"Loans Payable"
8500,8540,"Accrued Dividends Payable"
8500,8550,"Accrued Interest Payable"
8500,8590,"Other Accrued Expenses"
9000,9010,"Share Account"
9000,9020,"Savings"
9000,9030,"Club Accounts"
9000,9040,"Other Savings"
9300,9310,"Regular Reserves"
9300,9320,"Special Reserve for Losses"
9300,9330,"Other Reserves"
@@ -267,6 +267,36 @@ function create_chart_of_accounts {
local tenant="$1"
local user="$2"

create_ledgers "$ledger_file" "$tenant" "$user"
create_accounts "$accounts_file" "$tenant" "$user"
}

function create_accounts {
local accounts_file="$1"
local tenant="$2"
local user="$3"

echo ""
echo "Creating accounts..."
while IFS="," read -r parent_id id name; do
if [ "$parent_id" != "parentIdentifier" ]; then
local ledger_arr
local ledger_type

IFS=',' read -ra ledger_arr <<< $( grep $parent_id -m 1 ledgers.csv )
ledger_type=${ledger_arr[3]}
create_account "$tenant" "$user" "$parent_id" "$id" "$name" "$ledger_type"
fi
done < "$accounts_file"
}

function create_ledgers {
local ledger_file="$1"
local tenant="$2"
local user="$3"

echo ""
echo "Creating ledgers..."
while IFS="," read -r parent_id id description ledger_type show; do
if [ "$parent_id" != "parentIdentifier" ]; then
if [ -z "$parent_id" ]; then
@@ -280,6 +310,30 @@ function create_chart_of_accounts {
done < "$ledger_file"
}

function create_account {
local tenant="$1"
local user="$2"
local parent_id="$3"
local id="$4"
local name="$5"
local type="$6"

curl -X POST -H "Content-Type: application/json" -H "User: $user" -H "Authorization: ${ACCESS_TOKEN}" -H "X-Tenant-Identifier: $tenant" \
--data '{
"type": "'"$type"'",
"identifier": "'"$id"'",
"name": '"$name"',
"name": '"$name"',
"holders": [],
"signatureAuthorities": [],
"balance": 0.0,
"ledger": "'"$parent_id"'"
}' \
${ACCOUNTING_URL}/accounts
echo ""
echo "Created account $id : $name"
}

function create_ledger {
local tenant="$1"
local user="$2"
@@ -294,12 +348,6 @@ function create_ledger {
"identifier": "'"$id"'",
"name": "'"$id"'",
"description": '"$description"',
"subLedgers": [],
"totalValue": 0,
"createdOn": "",
"createdBy": "",
"lastModifiedOn": "",
"lastModifiedBy": "",
"showAccountsInChart": '$show'
}' \
${ACCOUNTING_URL}/ledgers
@@ -323,12 +371,6 @@ function update_ledger {
"name": "'"$id"'",
"description": '"$description"',
"parentLedgerIdentifier": "'"$parent_id"'",
"subLedgers": [],
"totalValue": 0,
"createdOn": "",
"createdBy": "",
"lastModifiedOn": "",
"lastModifiedBy": "",
"showAccountsInChart": '$show'
}' \
${ACCOUNTING_URL}/ledgers/${parent_id}
@@ -351,7 +393,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}
@@ -386,6 +428,6 @@ provision-app ${TENANT} $CHEQUES_MS_NAME
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"
echo "COMPLETED PROVISIONING PROCESS."

0 comments on commit 41e6f09

Please sign in to comment.