Calculation of the spread

zhaozj2021-02-16  49

In the general database design, customers generally cannot retain customers daily funds, generally only retain fund increases, but because interest points are changed daily, the interest intensity of interest points is also interest accumulation of funds change, calcicybye Differential can not simply adopt interest integrations in the increment table.

Start thinking about the daily spread:

Round (A.Balance * Enterprise Integration / 360, 2) - Round (A.Balance * Personal Interest Rate / 360, 2)

But the personal interest rate is actually different, so many times the personal interest rate can not be used directly, and the interest calculation is directly adopted.

Round ((a.interest_acc - coalesce (B.INTEREST_ACC, 0.00)) * Corporate Interest Rate / 360, 2) - (A.pending_INTEREST - Coalesce (B.pending_INTEREST, 0.00)))

A is the balance sheet on the same day, B is the previous trading day balance sheet

But the above algorithm is still a problem, if there is a surprise, it will be troublesome.

Case when a.interest_acc <= b.INTEREST_ACC THEN ROUND (a.interest_acc * Enterprise Integration / 360, 2 )-a.pending_INTEREST

Else Round ((a.interest_acc - coalesce (b.interest_acc, 0.00)) * Enterprise Interest Rate / 360, 2) - (A.pending_INTEREST - Coalesce (B.pending_INTEREST, 0.00)))

This is only valid for all, there is no way to partially.

转载请注明原文地址:https://www.9cbs.com/read-18316.html

New Post(0)