Published on : June 10, 2020

Backend URL : https://loantap.in/wp-admin/post.php?post=758509&action=edit

Frontend URL : https://loantap.in/banking/workflow-dues-receipt

Dues Receipt Flow takes 4 Steps to complete.

Step 1

Import Dues Receipt Data

Step 2

View Dues Receipt Data

Step 3

Update Dues Receipt Data

Step 4

Workflow Completed! Download CSV

Step 1 : Import Dues Receipt Data

View Interface:
Csv Format:

Sublan_id

Entry_date

Receipt_amount

Debit_account

Txn_ref

Sublan232232

20200101

5000

Bank(Cheque)

Bank(NACH)

Bank(Deposit)        

Ref-xxxxx


Import data from CSV
Read all CSV data in array and encode in json to send submit handler

Submit Flow :

Collect posted data and decode
	[request.request_body m.json_decode=true o.set=template.data /]

define table name to store data
	[template.set table_name="marketing.dues_{unique_number}" /]   

Import CSV data in table

Query
	Create temporary table in marketing table for 72 hours validity 
	 
	CREATE TABLE [template.table_name/] (
		ID INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
		stamp TIMESTAMP,
		created_by VARCHAR(50) NULL,
		[loop.@xx template.data.0]
			[env.@xx.key/] VARCHAR(255) NULL,
		[/loop.@xx]
		service varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
		current_page varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
		message VARCHAR(255) NULL,
		status VARCHAR(50)
	) COMMENT='banking||workflow-dues-receipt';
					  
		   
	/*store table entry into db*/
	insert into delete_marketing_tables (`table_name`,`expiry_date`)
	select '[template.table_name/]',DATE_ADD(NOW(), INTERVAL 5 HOUR) from dual;
	
	/*Store table name in workflow for other activities*/
	First step Mark Completed. Reload Page 

Step 2 : View Dues Receipt Data :

Imported data will display in Manage format Columns Used in UI:
sublan_id
entry_date
receipt_amount
debit_account
txn_ref
service
status
Message

Step 3 : Post Dues Receipt Data :

Start activity queue

Service name

common_service.transaction.dues_update_v2

Edit URL

https://loantap.in/wp-admin/post.php?post=752156&action=edit

Template Name

dues_update

Update <message column> as Row activity is in process :
  

UPDATE 
	[esc.table env.@data.table/]
SET
	`message`="Row activity is in process"
	WHERE ID="[env.@data.row.ID/]";  

Validation Checks before proceed :

	
	Sublan_id is missing
		UPDATE 
			[esc.table env.@data.table/]
		SET
			`message`="Invalid Sublan ID",
			`status`="error"
		WHERE 
			ID="[env.@data.row.ID/]";  
	
	Receipt Amount is missing       
		UPDATE 
			[esc.table env.@data.table/]
		SET
			`message`="Invalid receipt_amount!",
			`status`="error"
		WHERE 
			ID="[env.@data.row.ID/]";
		
	Debit Account is missing
		UPDATE 
			[esc.table env.@data.table/]
		SET
			`message`="Invalid debit_account",
			`status`="error"
		WHERE 
			ID="[env.@data.row.ID/]"; 
	
	Txn Ref is missing 
		UPDATE 
			[esc.table env.@data.table/]
		SET
			`message`="Invalid txn_ref!",
			`status`="error"
		WHERE 
			ID="[env.@data.row.ID/]"; 

Update Message :

UPDATE 
	[esc.table env.@data.table/]
SET
	`message`="txn in-process",
	`status`="in-process"
WHERE 
	ID="[env.@data.row.ID/]"; 

Check sublan id of scheme or product :
 [sublan_manage.cud.sch_or_pd sublan_id='{@data.row.sublan_id}’ o.set=template.sch_or_pd/]

Set txn to run :

	[template.set run_txn='dues_receipt' c.cond=template.sch_or_pd c.eq='s:scheme'/]
	[template.set run_txn='pd_dues_receipt' c.cond=template.sch_or_pd c.eq='s:product'/]

	If run_txn is pd_dues_receipt
		[sublan_txn.run pd_dues_receipt 
			entry_date="{@data.row.entry_date}" 
			sublan_id="{@data.row.sublan_id}"  
			receipt_amount="{@data.row.receipt_amount}" 
			debit_account="{@data.row.debit_account}" 
			txn_ref="{@data.row.txn_ref}" 
			o.set=module.sublan_obj/] 
				
		   [sublan_eligibility.get_notification_tpl 
			  product='{module.sublan_obj.product}' 
			  notification_block='notification_principal_dues_receipt' 
			  notification_type='mail' 
			  default_tpl='principal-dues-receipt' 
			  o.set=template.mail_tpl /]
		
	If run_txn is dues_receipt
		[sublan_txn.run dues_receipt 
			entry_date="{@data.row.entry_date}" 
			sublan_id="{@data.row.sublan_id}"  
			receipt_amount="{@data.row.receipt_amount}" 
			debit_account="{@data.row.debit_account}" 
			txn_ref="{@data.row.txn_ref}" 
			o.set=module.sublan_obj/]  
		

Get Voucher No :

select 
	voucher_no 
from 
	loan_entries 
where ID=(
	SELECT 
		max(ID)
	FROM 
		`loan_entries`
	where
		txn_set='Receipt'
		and entry_set='Receipt'
		and sublan_id='[module.sublan_id/]'
		and txn_ref='[env.@data.row.txn_ref/]'
		)	

Update Message and Status :

1) On Success
	UPDATE 
                [esc.table env.@data.table/]
	SET
		`message`="[module.sublan_obj.last_txn.message/] voucher: [template.raw.scalar/]",
		`status`="[module.sublan_obj.last_txn.status/]"
	WHERE 
		ID="[env.@data.row.ID/]"; 
		
2) On Error
	UPDATE 
                [esc.table env.@data.table/]
	SET
		`message`="Critical Error, Please contact Admin: [module.sublan_obj.last_txn.message/]",
		`status`="error"
	WHERE 
		ID="[env.@data.row.ID/]";

Common Notification Logic :

[template.set mail_tpl='instalment-post' /]
[module.sublan_obj.txn.send_mail_template o.set=template.mail_tpl c.not_empty=module.sublan_obj.txn.send_mail_template/] 
	 
	[do.@tran]
		[module.sublan_obj o.set=@tran.sublan_obj /]
		[env.set @tran.default_mail_tpl='{template.mail_tpl}' /]
		[env.set @tran.notification_type='mail' /]
		[env.set @tran.notification_block='notification_instalment_post' /]
		[sublan_manage.txn-notification.main o.set=template.mail_ack/]
	[/do.@tran]

Update Marketing table after error :


UPDATE 
	[esc.table env.@data.table/]
SET
	`message`="Critical Error, Please contact Admin",
	`status`="error"
WHERE 
	ID="[env.@data.row.ID/]";