Please take note that the logic below is for POC purposes and the current logic is implemented in Overdraft product logic implementation
Overdraft Postings
Open an overdraft
Send a custom instruction and send the money from the internal account DEFAULT address to the current account OVERDRAFT addressRepay an overdraft (proposed amount = overdraft amount)
2.1 Check if current account DEFAULT address balance (phase.COMMITTED + phase.PENDING_OUT) + OVERDRAFT address balance(phase.COMMITED) greater than proposed amount(phase.COMMITED + phase.PENDING_OUT)
if yes, go to the next step
if no, raise a rejected instruction
2.2 if the check is ok, firstly, it will deduce the proposed money from the DEFAULT address to the internal account DEFAULT address, and then, it goes to the rebalance process on the current account.
2.2.1 DEFAULT address amount >= proposed amount
transfer all the money from the OVERDRAFT address to the DEFAULT address
2.2.2 DEFAULT address amount < proposed amount
1) if the rebalance amount (abs(DEFAULT address amount - proposed amount))> 0, transfer the rebalance amount of money from OVERDRAFT address to DEFAULT address
2) transfer rest money from OVERDRAFT address to DEFAULT address
after that, all the money will be transferred from the OVERDRAFT address to the DEFAULT address