FINERACT-706: Interoperation Mojaloop integration 1.0.1

This commit is contained in:
Marti
2019-05-07 14:57:28 +02:00
parent 57b73034a5
commit 2f22da0e6c
76 changed files with 5178 additions and 48 deletions
@@ -47,11 +47,12 @@
org.apache.fineract.infrastructure.*,
org.apache.fineract.scheduledjobs.*,
org.apache.fineract.organisation.*,
org.apache.fineract.interoperation.*,
org.apache.fineract.portfolio.loanaccount.*,
org.apache.fineract.portfolio.savingsaccount.*,
org.apache.fineract.portfolio.*,
org.apache.fineract.useradministration.*,
org.apache.fineract.mix.*,
org.apache.fineract.mix.*,
org.apache.fineract.notification.*,
org.apache.fineract.template.*,
org.apache.fineract.template.service.*,
@@ -86,8 +87,9 @@
<jpa:repositories base-package="org.apache.fineract.adhocquery.domain" />
<jpa:repositories base-package="org.apache.fineract.notification.domain"/>
<jpa:repositories base-package="org.apache.fineract.infrastructure.campaigns.email.domain"/>
<jpa:repositories base-package="org.apache.fineract.interoperation.domain"/>
<import resource="infrastructure.xml" />
<import resource="securityContext.xml" />
@@ -103,6 +105,4 @@
<import resource="spmContext.xml"/>
<import resource="swagger.xml"/>
</beans>
@@ -0,0 +1,83 @@
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
-- software distributed under the License is distributed on an
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- KIND, either express or implied. See the License for the
-- specific language governing permissions and limitations
-- under the License.
--
DROP TABLE IF EXISTS `interop_identifier`;
CREATE TABLE `interop_identifier` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`account_id` BIGINT(20) NOT NULL,
`type` VARCHAR(32) NOT NULL,
`a_value` VARCHAR(128) NOT NULL,
`sub_value_or_type` VARCHAR(128) NULL,
`created_by` VARCHAR(32) NOT NULL,
`created_on` TIMESTAMP NOT NULL,
`modified_by` VARCHAR(32) NULL,
`modified_on` TIMESTAMP NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `uk_interop_identifier_account` (`account_id`, `type`),
UNIQUE INDEX `uk_interop_identifier_value` (`type`, `a_value`, `sub_value_or_type`),
INDEX `fk_interop_identifier_account` (`account_id`),
CONSTRAINT `fk_interop_identifier_account` FOREIGN KEY (`account_id`) REFERENCES `m_savings_account` (`id`)
)
COLLATE = 'utf8_general_ci'
ENGINE = InnoDB;
-- user+roles
SET @interop_username = 'interopUser';
INSERT INTO `m_appuser`
VALUES (NULL, 0, 1, NULL, @interop_username, 'Interop', 'User', '5787039480429368bf94732aacc771cd0a3ea02bcf504ffe1185ab94213bc63a',
'email@email.com', b'0', b'1', b'1', b'1', b'1', CURDATE(), 0, b'0');
INSERT INTO `m_appuser_role` VALUES ((SELECT id FROM m_appuser WHERE username = @interop_username), 1);
-- Interoperation permissions
INSERT INTO m_permission (grouping, code, entity_name, action_name, can_maker_checker)
VALUES ('interop', 'READ_INTERID', 'INTERID', 'READ', 0);
INSERT INTO m_permission (grouping, code, entity_name, action_name, can_maker_checker)
VALUES ('interop', 'READ_INTERREQUEST', 'INTERREQUEST', 'READ', 0);
INSERT INTO m_permission (grouping, code, entity_name, action_name, can_maker_checker)
VALUES ('interop', 'READ_INTERQUOTE', 'INTERQUOTE', 'READ', 0);
INSERT INTO m_permission (grouping, code, entity_name, action_name, can_maker_checker)
VALUES ('interop', 'READ_INTERTRANSFER', 'INTERTRANSFER', 'READ', 0);
INSERT INTO m_permission (grouping, code, entity_name, action_name, can_maker_checker)
VALUES ('interop', 'PREPARE_INTERTRANSFER', 'INTERTRANSFER', 'PREPARE', 0);
INSERT INTO m_permission (grouping, code, entity_name, action_name, can_maker_checker)
VALUES ('interop', 'CREATE_INTERID', 'INTERID', 'CREATE', 0);
INSERT INTO m_permission (grouping, code, entity_name, action_name, can_maker_checker)
VALUES ('interop', 'CREATE_INTERREQUEST', 'INTERREQUEST', 'CREATE', 0);
INSERT INTO m_permission (grouping, code, entity_name, action_name, can_maker_checker)
VALUES ('interop', 'CREATE_INTERQUOTE', 'INTERQUOTE', 'CREATE', 0);
INSERT INTO m_permission (grouping, code, entity_name, action_name, can_maker_checker)
VALUES ('interop', 'CREATE_INTERTRANSFER', 'INTERTRANSFER', 'CREATE', 0);
INSERT INTO m_permission (grouping, code, entity_name, action_name, can_maker_checker)
VALUES ('interop', 'DELETE_INTERID', 'INTERID', 'DELETE', 0);
INSERT IGNORE INTO m_code (code_name, is_system_defined) VALUES ('PaymentType', 1);
SET @code_id = -1;
SELECT id INTO @code_id FROM m_code WHERE code_name = 'PaymentType';
INSERT IGNORE INTO m_code_value (code_id, code_value, order_position) VALUES (@code_id, 'Money Transfer', 1);
INSERT IGNORE INTO m_payment_type (value, description, order_position) VALUES ('Money Transfer', 'Money Transfer', 1);
@@ -67,6 +67,11 @@ CREATE TABLE `tenants` (
LOCK TABLES `tenants` WRITE;
/*!40000 ALTER TABLE `tenants` DISABLE KEYS */;
INSERT INTO `tenants` VALUES (1,'default','Default Demo Tenant','mifostenant-default','Asia/Kolkata',NULL,NULL,NULL,NULL,'localhost','3306','root','mysql',1);
-- Add tenants to support interoperation multi-tenancy
-- INSERT INTO `tenants` VALUES (2,'tn01','Buffalo','tn01','Africa/Bujumbura',NULL,NULL,NULL,NULL,'localhost','3306','root','mysql',1);
-- INSERT INTO `tenants` VALUES (3,'tn02','Lion','tn02','Africa/Bujumbura',NULL,NULL,NULL,NULL,'localhost','3306','root','mysql',1);
-- INSERT INTO `tenants` VALUES (4,'tn03','Rhino','tn03','Africa/Bujumbura',NULL,NULL,NULL,NULL,'localhost','3306','root','mysql',1);
-- INSERT INTO `tenants` VALUES (5,'tn04','Elephant','tn04','Africa/Bujumbura',NULL,NULL,NULL,NULL,'localhost','3306','root','mysql',1);
/*!40000 ALTER TABLE `tenants` ENABLE KEYS */;
UNLOCK TABLES;
@@ -0,0 +1,200 @@
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
-- software distributed under the License is distributed on an
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- KIND, either express or implied. See the License for the
-- specific language governing permissions and limitations
-- under the License.
--
-- To use: Change saving_account_no before every run!
-- !both tn03, tn04 tenants
-- saving product, account
SET @last_saving_prod_id = -1;
SELECT COALESCE(max(id), 1) into @last_saving_prod_id from m_savings_product;
SET @saving_prod_name = concat('Saving Product', @last_saving_prod_id);
INSERT INTO `m_savings_product`
(`name`, `short_name`, `description`, `deposit_type_enum`, `currency_code`, `currency_digits`,
`currency_multiplesof`, `nominal_annual_interest_rate`, `interest_compounding_period_enum`,
`interest_posting_period_enum`, `interest_calculation_type_enum`, `interest_calculation_days_in_year_type_enum`,
`min_required_opening_balance`, `accounting_type`, `withdrawal_fee_amount`, `withdrawal_fee_type_enum`,
`withdrawal_fee_for_transfer`, `allow_overdraft`, `min_required_balance`, `enforce_min_required_balance`,
`min_balance_for_interest_calculation`, `withhold_tax`, `tax_group_id`, `is_dormancy_tracking_active`)
VALUES (@saving_prod_name, concat('SP', @last_saving_prod_id), 'Saving Product', 100, 'TZS', 2, NULL, 0.000000, 1,
4, 1, 360, NULL, 2, NULL, NULL, 0, 0, 0.000000, 1, NULL, 0, NULL, 0);
SET @saving_prod_id = -1;
SELECT id INTO @saving_prod_id FROM m_savings_product WHERE name = @saving_prod_name;
-- interop_identifier
-- charge, mapping
-- gl_account, mappings
-- ASSET-1, LIABILITY-2, EQUITY-3, INCOME-4, EXPENSE-5
SET @payment_type_id = -1;
SELECT id INTO @payment_type_id FROM m_payment_type WHERE value = 'Money Transfer';
SET @saving_gl_name = 'Interoperation Saving';
INSERT INTO `acc_gl_account` (`name`, `parent_id`, `hierarchy`, `gl_code`, `disabled`, `manual_journal_entries_allowed`, `account_usage`, `classification_enum`, `description`)
VALUES (@saving_gl_name, NULL, NULL, 'Interop_Saving', 0, 1, 1, 1, 'Interoperation Saving Asset'); -- account_usage: DETAIL, classification_enum: ASSET
INSERT INTO `acc_product_mapping` (`gl_account_id`, `product_id`, `product_type`, `payment_type`, `charge_id`, `financial_account_type`)
VALUES ((SELECT id FROM acc_gl_account WHERE name = @saving_gl_name), @saving_prod_id, 2, @payment_type_id, NULL, 1); -- product_type: SAVING, financial_account_type: ASSET
SET @nostro_gl_name = 'Interoperation NOSTRO';
INSERT INTO `acc_gl_account` (`name`, `parent_id`, `hierarchy`, `gl_code`, `disabled`, `manual_journal_entries_allowed`, `account_usage`, `classification_enum`, `description`)
VALUES (@nostro_gl_name, NULL, NULL, 'Interop_Nostro', 0, 0, 1, 2, 'Interoperation NOSTRO Liability'); -- account_usage: DETAIL, classification_enum: LIABILITY
INSERT INTO `acc_product_mapping` (`gl_account_id`, `product_id`, `product_type`, `payment_type`, `charge_id`, `financial_account_type`)
VALUES ((SELECT id FROM acc_gl_account WHERE name = @nostro_gl_name), @saving_prod_id, 2, NULL, NULL, 2); -- product_type: SAVING, financial_account_type: LIABILITY
SET @fee_gl_name = 'Interoperation Fee';
INSERT INTO `acc_gl_account` (`name`, `parent_id`, `hierarchy`, `gl_code`, `disabled`, `manual_journal_entries_allowed`, `account_usage`, `classification_enum`, `description`)
VALUES (@fee_gl_name, NULL, NULL, 'Interop_Fee', 0, 0, 1, 4, 'Interoperation Fee Income'); -- account_usage: DETAIL, classification_enum: INCOME
SET @fee_gl_id = -1;
SELECT id INTO @fee_gl_id FROM acc_gl_account WHERE name = @fee_gl_name;
INSERT INTO `acc_product_mapping` (`gl_account_id`, `product_id`, `product_type`, `payment_type`, `charge_id`, `financial_account_type`)
VALUES (@fee_gl_id, @saving_prod_id, 2, NULL, NULL, 4); -- product_type: SAVING, financial_account_type: INCOME
SET @charge_name = 'Interoperation Withdraw Fee';
INSERT INTO `m_charge`
(`name`,`currency_code`,`charge_applies_to_enum`,`charge_time_enum`,`charge_calculation_enum`,`charge_payment_mode_enum`,
`amount`,`fee_on_day`,`fee_interval`,`fee_on_month`,`is_penalty`,`is_active`,`is_deleted`,`min_cap`,`max_cap`,`fee_frequency`,
`income_or_liability_account_id`,`tax_group_id`)
VALUES (@charge_name, 'TZS', 2, 5, 1, NULL, 1.000000, NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL, @fee_gl_id, NULL);
-- loan product
/*
SET @last_ext_id = -1;
SELECT COALESCE(max(external_id), 1) INTO @last_ext_id FROM m_product_loan;
INSERT INTO `m_product_loan`
VALUES
(CONCAT('IP', @last_product_id), 'EUR', 2, 1, 50000.000000, NULL, NULL, NULL, concat('Interoperation Customer Product', @last_product_id),
'Demo Interoperation Product', NULL, b'0', b'0', 1.000000, 1.000000, NULL, NULL, 3, 1.000000, 0, 1, 1, 1, 2, 1200, NULL,
NULL, NULL, NULL, NULL, 1, 1, 3, @last_ext_id + 1, 0, 0,ADDDATE(curdate(),-100),ADDDATE(curdate(),100), 0, 0, NULL, NULL,
NULL, 1, 30, 0, 0, 0.00, 0, 1, 0, 0, 0);
SET @product_id = -1;
SELECT id INTO @product_id FROM m_product_loan WHERE name = concat('Interoperation Customer Product', @last_product_id);
-- charge, mapping
INSERT INTO `m_charge` VALUES (
NULL, concat('Loan Withdraw Fee_', @product_id), 'TZS', 1, 2,
1, 0, 1.000000, NULL, NULL,
NULL, 0, 1, 0, NULL,
NULL, NULL, NULL, NULL);
INSERT INTO `m_product_loan_charge` VALUES
(@product_id, (SELECT id
FROM m_charge
WHERE name = concat('Loan Withdraw Fee_', @product_id)));
-- gl_account, mappings
-- ASSET-1, LIABILITY-2, EQUITY-3, INCOME-4, EXPENSE-5
SET @liab_acc_name = concat('Loan Payable Liability_', @product_id);
INSERT INTO `acc_gl_account` VALUES (
NULL, @liab_acc_name, NULL, NULL, concat('0360009420', @product_id),
0, 1, 1, 1, NULL, 'Loan Payable Liability');
INSERT INTO `acc_product_mapping` VALUES (
NULL,
(SELECT id
FROM acc_gl_account
WHERE name = @liab_acc_name),
@product_id,
NULL, NULL, NULL, 2);
SET @nostro_acc_name = concat('Loan NOSTRO_', @product_id);
INSERT INTO `acc_gl_account` VALUES (
NULL, @nostro_acc_name, NULL, NULL, concat('0360009421', @product_id),
0, 1, 1, 1, NULL, 'Loan NOSTRO');
INSERT INTO `acc_product_mapping` VALUES (
NULL,
(SELECT id
FROM acc_gl_account
WHERE name = @nostro_acc_name),
@product_id,
NULL, NULL, NULL, 1);
SET @cash_acc_name = concat('Loan Product Cash_', @product_id);
INSERT INTO `acc_gl_account` VALUES (
NULL, @cash_acc_name, NULL, NULL, concat('0360009422', @product_id),
0, 1, 1, 1, NULL, 'Loan Product Cash');
INSERT INTO `acc_product_mapping` VALUES (
NULL,
(SELECT id
FROM acc_gl_account
WHERE name = @cash_acc_name),
@product_id,
NULL, NULL, NULL, 1);
SET @expen_acc_name = concat('Loan Product Expenses_', @product_id);
INSERT INTO `acc_gl_account` VALUES (
NULL, @expen_acc_name, NULL, NULL, concat('0360009423', @product_id),
0, 1, 1, 1, NULL, 'Loan Product Expenses');
INSERT INTO `acc_product_mapping` VALUES (
NULL,
(SELECT id
FROM acc_gl_account
WHERE name = @expen_acc_name),
@product_id,
NULL, NULL, NULL, 5);
SET @accrue_acc_name = concat('Loan Product Accrue Liability_', @product_id);
INSERT INTO `acc_gl_account` VALUES (
NULL, @accrue_acc_name, NULL, NULL, concat('0360009424', @product_id),
0, 1, 1, 1, NULL, 'Loan Product Accrue Liability');
INSERT INTO `acc_product_mapping` VALUES (
NULL,
(SELECT id
FROM acc_gl_account
WHERE name = @accrue_acc_name),
@product_id,
NULL, NULL, NULL, 2);
SET @equ_acc_name = concat('Loan Product Equity_', @product_id);
INSERT INTO `acc_gl_account` VALUES (
NULL, @equ_acc_name, NULL, NULL, concat('0360009425', @product_id),
0, 1, 1, 1, NULL, 'Loan Product Equity');
INSERT INTO `acc_product_mapping` VALUES (
NULL,
(SELECT id
FROM acc_gl_account
WHERE name = @equ_acc_name),
@product_id,
NULL, NULL, NULL, 3);
SET @feer_acc_name = concat('Loan Product Fees Revenue_', @product_id);
INSERT INTO `acc_gl_account` VALUES (
NULL, @feer_acc_name, NULL, NULL, concat('0360009426', @product_id),
0, 1, 1, 1, NULL, 'Loan Product Fees Revenue');
INSERT INTO `acc_product_mapping` VALUES (
NULL,
(SELECT id
FROM acc_gl_account
WHERE name = @feer_acc_name),
@product_id,
NULL, NULL, NULL, 4);*/
@@ -0,0 +1,83 @@
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
-- software distributed under the License is distributed on an
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- KIND, either express or implied. See the License for the
-- specific language governing permissions and limitations
-- under the License.
--
-- To use: Change saving_account_no before every run!
USE `tn03`;
-- data initialization
-- user+roles
-- client
SET @saving_account_no = '9062b90de19b43989005';
INSERT INTO `m_client` (`account_no`, `external_id`, `status_enum`, `sub_status`, `activation_date`, `office_joining_date`,
`office_id`, `transfer_to_office_id`, `staff_id`, `firstname`, `middlename`, `lastname`, `fullname`,
`display_name`, `mobile_no`, `gender_cv_id`, `date_of_birth`, `image_id`, `closure_reason_cv_id`,
`closedon_date`, `updated_by`, `updated_on`, `submittedon_date`, `submittedon_userid`, `activatedon_userid`,
`closedon_userid`, `default_savings_product`, `default_savings_account`, `client_type_cv_id`, `client_classification_cv_id`,
`reject_reason_cv_id`, `rejectedon_date`, `rejectedon_userid`, `withdraw_reason_cv_id`, `withdrawn_on_date`,
`withdraw_on_userid`, `reactivated_on_date`, `reactivated_on_userid`, `legal_form_enum`, `reopened_on_date`,
`reopened_by_userid`)
VALUES (@saving_account_no, NULL, 300, NULL, ADDDATE(curdate(), -100), NULL, 1, NULL, NULL, NULL, NULL, NULL,
'InteropCustomer', 'InteropCustomer', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ADDDATE(curdate(), -100),
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL, NULL);
-- saving product, account
SET @last_saving_prod_id = -1;
SELECT COALESCE(max(id), 1) into @last_saving_prod_id from m_savings_product;
SET @saving_prod_name = concat('Saving Product', @last_saving_prod_id);
SET @saving_prod_id = -1;
SELECT id INTO @saving_prod_id FROM m_savings_product WHERE name = @saving_prod_name;
SET @client_id = -1;
SELECT id INTO @client_id FROM m_client WHERE fullname = 'InteropCustomer';
INSERT INTO `m_savings_account`
(`account_no`, `external_id`, `client_id`, `group_id`, `product_id`, `field_officer_id`, `status_enum`,
`sub_status_enum`, `account_type_enum`, `deposit_type_enum`, `submittedon_date`, `submittedon_userid`,
`approvedon_date`, `approvedon_userid`, `activatedon_date`, `activatedon_userid`,
`currency_code`, `currency_digits`, `currency_multiplesof`, `nominal_annual_interest_rate`,
`interest_compounding_period_enum`, `interest_posting_period_enum`, `interest_calculation_type_enum`,
`interest_calculation_days_in_year_type_enum`, `min_required_opening_balance`, `withdrawal_fee_for_transfer`,
`allow_overdraft`, `account_balance_derived`, `min_required_balance`, `enforce_min_required_balance`,
`version`, `withhold_tax`)
VALUES (@saving_account_no, '9062b90de19b43989005d9', @client_id, NULL, @saving_prod_id, NULL, 300, 0, 1, 100, ADDDATE(curdate(), -100),
NULL, ADDDATE(curdate(), -100), NULL, ADDDATE(curdate(), -100), NULL, 'TZS', 2, NULL, 1.000000, 1, 4, 1, -- 29. - 4
360, NULL, 1, 1, 100000000.000000, 0.000000, 1, 1, 0);
-- interop_identifier
SET @saving_acc_id = -1;
SELECT id INTO @saving_acc_id FROM m_savings_account WHERE account_no = @saving_account_no;
INSERT INTO interop_identifier (id, account_id, type, a_value, sub_value_or_type, created_by, created_on, modified_by, modified_on)
VALUES (NULL, @saving_acc_id, 'IBAN', 'IC11in02tn039062b90de19b43989005d9', NULL, 'operator', CURDATE(), 'operator',
CURDATE());
INSERT INTO interop_identifier (id, account_id, type, a_value, sub_value_or_type, created_by, created_on, modified_by, modified_on)
VALUES (NULL, @saving_acc_id, 'MSISDN', '27710203999', NULL, 'operator', CURDATE(), 'operator', CURDATE());
-- charge, mapping
-- gl_account, mappings
-- ASSET-1, LIABILITY-2, EQUITY-3, INCOME-4, EXPENSE-5
SET @charge_name = 'Interoperation Withdraw Fee';
INSERT INTO `m_savings_account_charge` (`savings_account_id`, `charge_id`, `is_penalty`, `charge_time_enum`, `charge_calculation_enum`,
`amount`, `amount_outstanding_derived`,`is_paid_derived`, `waived`, `is_active`)
VALUES (@saving_acc_id, (SELECT id FROM m_charge WHERE name = @charge_name), 0, 5, 1, 1.000000, 0.000000, 0, 0, 1);
@@ -0,0 +1,83 @@
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
-- software distributed under the License is distributed on an
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- KIND, either express or implied. See the License for the
-- specific language governing permissions and limitations
-- under the License.
--
-- To use: Change saving_account_no before every run!
USE `tn04`;
-- data initialization
-- user+roles
-- client
SET @saving_account_no = 'a6b6c10b2aaa4778ac2f';
INSERT INTO `m_client` (`account_no`, `external_id`, `status_enum`, `sub_status`, `activation_date`, `office_joining_date`,
`office_id`, `transfer_to_office_id`, `staff_id`, `firstname`, `middlename`, `lastname`, `fullname`,
`display_name`, `mobile_no`, `gender_cv_id`, `date_of_birth`, `image_id`, `closure_reason_cv_id`,
`closedon_date`, `updated_by`, `updated_on`, `submittedon_date`, `submittedon_userid`, `activatedon_userid`,
`closedon_userid`, `default_savings_product`, `default_savings_account`, `client_type_cv_id`, `client_classification_cv_id`,
`reject_reason_cv_id`, `rejectedon_date`, `rejectedon_userid`, `withdraw_reason_cv_id`, `withdrawn_on_date`,
`withdraw_on_userid`, `reactivated_on_date`, `reactivated_on_userid`, `legal_form_enum`, `reopened_on_date`,
`reopened_by_userid`)
VALUES (@saving_account_no, NULL, 300, NULL, ADDDATE(curdate(), -100), NULL, 1, NULL, NULL, NULL, NULL, NULL,
'InteropMerchant', 'InteropMerchant', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ADDDATE(curdate(), -100),
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL, NULL);
-- saving product, account
SET @last_saving_prod_id = -1;
SELECT COALESCE(max(id), 1) into @last_saving_prod_id from m_savings_product;
SET @saving_prod_name = concat('Saving Product', @last_saving_prod_id);
SET @saving_prod_id = -1;
SELECT id INTO @saving_prod_id FROM m_savings_product WHERE name = @saving_prod_name;
SET @client_id = -1;
SELECT id INTO @client_id FROM m_client WHERE fullname = 'InteropMerchant';
INSERT INTO `m_savings_account`
(`account_no`, `external_id`, `client_id`, `group_id`, `product_id`, `field_officer_id`, `status_enum`,
`sub_status_enum`, `account_type_enum`, `deposit_type_enum`, `submittedon_date`, `submittedon_userid`,
`approvedon_date`, `approvedon_userid`, `activatedon_date`, `activatedon_userid`,
`currency_code`, `currency_digits`, `currency_multiplesof`, `nominal_annual_interest_rate`,
`interest_compounding_period_enum`, `interest_posting_period_enum`, `interest_calculation_type_enum`,
`interest_calculation_days_in_year_type_enum`, `min_required_opening_balance`, `withdrawal_fee_for_transfer`,
`allow_overdraft`, `account_balance_derived`, `min_required_balance`, `enforce_min_required_balance`,
`version`, `withhold_tax`)
VALUES (@saving_account_no, 'a6b6c10b2aaa4778ac2fc9', @client_id, NULL, @saving_prod_id, NULL, 300, 0, 1, 100, ADDDATE(curdate(), -100),
NULL, ADDDATE(curdate(), -100), NULL, ADDDATE(curdate(), -100), NULL, 'TZS', 2, NULL, 1.000000, 1, 4, 1, -- 29. - 4
360, NULL, 1, 1, 100000000.000000, 0.000000, 1, 1, 0);
-- interop_identifier
SET @saving_acc_id = -1;
SELECT id INTO @saving_acc_id FROM m_savings_account WHERE account_no = @saving_account_no;
INSERT INTO interop_identifier (id, account_id, type, a_value, sub_value_or_type, created_by, created_on, modified_by, modified_on)
VALUES (NULL, @saving_acc_id, 'IBAN', 'IC11in02tn04a6b6c10b2aaa4778ac2fc9', NULL, 'operator', CURDATE(), 'operator',
CURDATE());
INSERT INTO interop_identifier (id, account_id, type, a_value, sub_value_or_type, created_by, created_on, modified_by, modified_on)
VALUES (NULL, @saving_acc_id, 'MSISDN', '27710204999', NULL, 'operator', CURDATE(), 'operator', CURDATE());
-- charge, mapping
-- gl_account, mappings
-- ASSET-1, LIABILITY-2, EQUITY-3, INCOME-4, EXPENSE-5
SET @charge_name = 'Interoperation Withdraw Fee';
INSERT INTO `m_savings_account_charge` (`savings_account_id`, `charge_id`, `is_penalty`, `charge_time_enum`, `charge_calculation_enum`,
`amount`, `amount_outstanding_derived`,`is_paid_derived`, `waived`, `is_active`)
VALUES (@saving_acc_id, (SELECT id FROM m_charge WHERE name = @charge_name), 0, 5, 1, 1.000000, 0.000000, 0, 0, 1);