Simulation of late damages for child support delinquency with python

# Will there be any late damages to child support? Since child support is a monetary claim, ** late damages will occur **.

Article 419

  1. For default of obligations for the purpose of monetary payment, the amount of damages shall be determined by the statutory interest rate. However, if the contracted interest rate exceeds the statutory interest rate, the contracted interest rate shall be applied.
  2. Regarding the damage compensation set forth in the preceding paragraph, the creditor does not need to prove the damage.
  3. The debtor may not defend against the damages set forth in paragraph (1) with force majeure. https://ja.wikibooks.org/wiki/%E6%B0%91%E6%B3%95%E7%AC%AC419%E6%9D%A1

Love column "Do I have to pay child support if I don't have income? ?? 』\

image.png

Sakiri insisted that ** you can't pay without it because you pay according to your income **. You are free to make a claim, but be aware that ** your claim will not expire ** and ** you will incur late damages **. By the way, child support is usually paid monthly, so it will be a ** fixed-term benefit claim **. Let's collect the monetary claims properly! ** For children's smiles **.

How much is the statutory interest rate?

Until March 31, 2020, the maximum is 5% per year if there is no agreement. (Before revision) From April 1, 2020, the upper limit is 3% per year if there is no agreement. (After revision)

Article 404 If there is no manifestation of intention regarding a claim that should bear interest, the interest rate shall be five minutes a year. https://ja.wikibooks.org/wiki/%E6%B0%91%E6%B3%95%E7%AC%AC404%E6%9D%A1

About the law to partially revise the Civil Code (Revision of the Credit Law) http://www.moj.go.jp/MINJI/minji06_001070000.html

How to calculate?

## Organize the information you need Interest rate: 5% per year until March 31, 2020, 3% per year from April 1, 2020 Number of days in a year: Normally 365 days, leap year 366 days Starting date: The day after the payment due date Delay period: How many years and days are delayed including the starting date

Try to calculate with a calculator

Let's simulate if Sakiri did not pay child support of 30,000 yen by the end of January 2018!

① First of all, I will ask you about the situation.

image.png

(2) I will be patiently listening to you, although I will be swearing at you.

image.png

③ If you put up with what you want to say and listen to the story, you will threaten to kill your child.

As expected, this is dangerous, so I will change players. image.png

④ After finishing the call with the threatening criminal, I will go to the police the day after I spent a sleepless night with fear and anxiety that I might come to kill my child.

⑤ Time has passed ... On the 29th birthday of Sakiri, I suddenly try to calculate the late damages.

Now, let's calculate the late damages in this case.

Calculation date: May 17, 2020 Interest rate: 5% per year until March 31, 2020, 3% per year from April 1, 2020 Number of days in a year: Normally 365 days, leap year 366 days Starting date: February 1, 2018 Delay period: 2 years (February 1, 2018-January 31, 2020) and 107 days (February 1, 2020-May 17, 2020)

A little worrisome point

### 1. If the statutory interest rate changes in the middle, which of 5% and 3% will be applied? → Since the starting date is February 1, 2018, 5% is fine. (maybe) > For default of debt for the purpose of monetary payment, the amount of damages shall be determined by the statutory interest rate at the time when the debtor was liable for delay. However, if the contracted interest rate exceeds the statutory interest rate, the contracted interest rate shall be applied.

Attorney Ame no Chiharu Blog: Article 419 of the Civil Code (Special Provisions for Monetary Debt) Civil Code Amendment Study Note 64 ** http://blog.livedoor.jp/kosekeito/archives/minpou419jou.html

2. How do you calculate when a leap year is included?

① From February 1, 2018 to January 31, 2020, 30,000 yen x 0.05 x 2 years = 3000 yen (2) From February 1, 2020 to May 12, 2020, 30,000 yen x 0.05 ÷ 366 days x 107 days = 438 yen (rounded down) ③ 3000 yen + 438 yen = 3438 yen

When there is no special contract regarding leap year in the title of obligation and registration (in the case of a revolving mortgage, the contract) (1) The annual interest is calculated for the period that is calculated from the starting date and fills the year. (2) Next, the period less than a year is calculated on a daily basis. ③ Then add up ① and ②.

** Calculation of interest and damages ** https://www.courts.go.jp/okayama/saiban/tetuzuki/s11_2/index.html

Let's calculate with python!

Let's do this with python!

sakiri_kids_money_delinquent_charge_simulator.py

sakiri_kids_money_delinquent_charge_simulator.py


# coding: utf-8
import calendar
import datetime
import math
from dateutil.relativedelta import relativedelta

#Calculation date
calculation_date = datetime.date(2020, 5, 17) # Sakiri's 29th birthday

#Child support
kids_money = 30000

#Starting date
start_date = datetime.date(2018, 2, 1)

#Annual interest
#From April 1, 2020, the statutory annual interest rate is 3%
APY = 0.05 if start_date < datetime.date(2020, 4, 1) else 0.03

#Years of delay
#The relative delta is shifted by one day because it is calculated without including the specified start date.
years = relativedelta(calculation_date, start_date + datetime.timedelta(days=-1)).years

#Daily start date
prorated_start_date = (start_date + relativedelta(years=years))

#Daily days
days = (calculation_date - prorated_start_date).days + 1

#Does the leap year include leap years?
is_leap_year_calculation_date = calendar.isleap(calculation_date.year)
is_leap_year_prorated_start_date = calendar.isleap(prorated_start_date.year)
is_leap_year = is_leap_year_calculation_date or is_leap_year_prorated_start_date

#Does the prorated period span years?
is_cross_year = prorated_start_date.year != calculation_date.year

#Calculation of late damages
delinquent_charge_year = math.floor(kids_money * APY * years) #Delayed damage (year)
delinquent_charge_days = 0
prorated_days = 0
calculation_days = 0
if is_leap_year and is_cross_year:
    #There is a leap year, there is a straddle

    #Calculate the year of the prorated start date
    # 2021/1/1 - 2020/12/31 = 1
    prorated_days = (datetime.date(prorated_start_date.year + 1, 1, 1) - prorated_start_date).days
    delinquent_charge_days_prorated = math.floor(kids_money * APY / (366 if is_leap_year_prorated_start_date else 365) * prorated_days)

    #Start year of calculation date
    # 2020/1/1 - 2020/1/1 + 1 = 1
    calculation_days = (calculation_date - datetime.date(calculation_date.year, 1, 1)).days + 1
    delinquent_charge_days_calculation = math.floor(kids_money * APY / (366 if is_leap_year_calculation_date else 365) * calculation_days)

    #Delayed damages (daily)
    delinquent_charge_days = delinquent_charge_days_prorated + delinquent_charge_days_calculation
else:
    #No year crossing
    delinquent_charge_days = math.floor(kids_money * APY / (366 if is_leap_year else 365) * days)

#Delayed damages (total)
delinquent_charge = delinquent_charge_year + delinquent_charge_days

#display
print("Calculation date: " + calculation_date.strftime('%Y/%m/%d'))
print("Starting date: " + start_date.strftime('%Y/%m/%d'))
print("Annual interest: " + str(APY))
print("Daily start date: " + prorated_start_date.strftime('%Y/%m/%d'))
print("Years of delay: " + str(years))
print("Daily days: " + str(days))
print("Does the leap year include leap years?: " +("Yes" if is_leap_year else "No"))
print("Do you straddle years during the prorated period?: " +("Yes" if is_cross_year else "No"))
print("Delayed damage (year): " + str(delinquent_charge_year) + "Circle")
print("Delayed damages (daily): " + str(delinquent_charge_days) + "Circle")
print("Delayed damages (total): " + str(delinquent_charge) + "Circle")

if is_leap_year and is_cross_year:
    print("==Breakdown==")
    print("Number of days on the prorated start date: " + str(prorated_days))
    print("A leap year with a prorated start date?: " +("Yes" if is_leap_year_prorated_start_date else "No"))
    print("Delayed damages for the year of the prorated start date: " + str(delinquent_charge_days_prorated) + "Circle")
    print("Number of days of calculation date: " + str(calculation_days))
    print("Is the calculation date a leap year?: " +("Yes" if is_leap_year_calculation_date else "No"))
    print("Delayed damages for the year of calculation date: " + str(delinquent_charge_days_calculation) + "Circle")
    print("==========")

Let's do it!

https://paiza.io/projects/k33PBLmUxXW2Zyg-UYvMRg

Calculation date: 2020/05/17
Starting date: 2018/02/01
Annual interest: 0.05
Daily start date: 2020/02/01
Years of delay: 2
Daily days: 107
Does the leap year include leap years?:Yes
Do you straddle years during the prorated period?:No
Delayed damage (year):3000 yen
Delayed damages (daily):438 yen
Delayed damages (total):3438 yen

The rest is OK if you make it a function and turn it around! !!

sakiri_kids_money_delinquent_charge_simulator_custom.py

sakiri_kids_money_delinquent_charge_simulator_custom.py


# coding: utf-8
import calendar
import datetime
import math
from dateutil.relativedelta import relativedelta

def sakiri_delinquent_charge(calculation_date, kids_money, start_date, print_enabled):
    #Annual interest
    #From April 1, 2020, the statutory annual interest rate is 3%
    APY = 0.05 if start_date < datetime.date(2020, 4, 1) else 0.03

    #Years of delay
    #The relative delta is shifted by one day because it is calculated without including the specified start date.
    years = relativedelta(calculation_date, start_date + datetime.timedelta(days=-1)).years

    #Daily start date
    prorated_start_date = (start_date + relativedelta(years=years))

    #Daily days
    days = (calculation_date - prorated_start_date).days + 1

    #Does the leap year include leap years?
    is_leap_year_calculation_date = calendar.isleap(calculation_date.year)
    is_leap_year_prorated_start_date = calendar.isleap(prorated_start_date.year)
    is_leap_year = is_leap_year_calculation_date or is_leap_year_prorated_start_date

    #Does the prorated period span years?
    is_cross_year = prorated_start_date.year != calculation_date.year

    #Calculation of late damages
    delinquent_charge_year = math.floor(kids_money * APY * years) #Delayed damage (year)
    delinquent_charge_days = 0
    prorated_days = 0
    calculation_days = 0
    if is_leap_year and is_cross_year:
        #There is a leap year, there is a straddle

        #Calculate the year of the prorated start date
        # 2021/1/1 - 2020/12/31 = 1
        prorated_days = (datetime.date(prorated_start_date.year + 1, 1, 1) - prorated_start_date).days
        delinquent_charge_days_prorated = math.floor(kids_money * APY / (366 if is_leap_year_prorated_start_date else 365) * prorated_days)

        #Start year of calculation date
        # 2020/1/1 - 2020/1/1 + 1 = 1
        calculation_days = (calculation_date - datetime.date(calculation_date.year, 1, 1)).days + 1
        delinquent_charge_days_calculation = math.floor(kids_money * APY / (366 if is_leap_year_calculation_date else 365) * calculation_days)

        #Delayed damages (daily)
        delinquent_charge_days = delinquent_charge_days_prorated + delinquent_charge_days_calculation
    else:
        #No year crossing
        delinquent_charge_days = math.floor(kids_money * APY / (366 if is_leap_year else 365) * days)

    #Delayed damages (total)
    delinquent_charge = delinquent_charge_year + delinquent_charge_days

    #display
    if print_enabled :
        print("************************************************************")
        title_month = (next_month + relativedelta(months=-1)).strftime('%Y year%m month')
        print(title_month + "Calculate the delay damage of child support for the minute ...")
        print("Calculation date: " + calculation_date.strftime('%Y/%m/%d'))
        print("Starting date: " + start_date.strftime('%Y/%m/%d'))
        print("Annual interest: " + str(APY))
        print("Daily start date: " + prorated_start_date.strftime('%Y/%m/%d'))
        print("Years of delay: " + str(years))
        print("Daily days: " + str(days))
        print("Does the leap year include leap years?: " +("Yes" if is_leap_year else "No"))
        print("Do you straddle years during the prorated period?: " +("Yes" if is_cross_year else "No"))
        print("Delayed damage (year): " + str(delinquent_charge_year) + "Circle")
        print("Delayed damages (daily): " + str(delinquent_charge_days) + "Circle")
        print("Delayed damages (total): " + str(delinquent_charge) + "Circle")

        if is_leap_year and is_cross_year:
            print("==Breakdown==")
            print("Number of days on the prorated start date: " + str(prorated_days))
            print("A leap year with a prorated start date?: " +("Yes" if is_leap_year_prorated_start_date else "No"))
            print("Delayed damages for the year of the prorated start date: " + str(delinquent_charge_days_prorated) + "Circle")
            print("Number of days of calculation date: " + str(calculation_days))
            print("Is the calculation date a leap year?: " +("Yes" if is_leap_year_calculation_date else "No"))
            print("Delayed damages for the year of calculation date: " + str(delinquent_charge_days_calculation) + "Circle")
            print("==========")

    return delinquent_charge



#Calculation date
calculation_date = datetime.date(2020, 5, 17) # Sakiri's 29th birthday
#Child support
kids_money = 30000
#Starting date
start_date = datetime.date(2018, 2, 1)

total = 0
next_month = start_date
array = []
while True:
    # print_Show details if enabled is set to True
    delinquent_charge = sakiri_delinquent_charge(calculation_date, kids_money, next_month, print_enabled=False)
    total += delinquent_charge
    title_month = (next_month + relativedelta(months=-1)).strftime('%Y year%m month')
    array.append({'key':title_month, 'value':delinquent_charge})
    next_month = next_month + relativedelta(months=1)
    if next_month > calculation_date:
        break

#display
print("************************************************************")

print("Total late damages: " + str(total) + "Circle")

print("<List of monthly late damages>")
for data in array:
    print(data['key'], data['value'],'Circle')

print("************************************************************")

Let's do it! !!

https://paiza.io/projects/mItcWZUwE8EpUfIl74VotQ?language=python3

************************************************************
Total late damages:49027 yen
<List of monthly late damages>
January 2018 3438 yen
February 2018 3319 yen
March 2018 3192 yen
April 2018 3069 yen
May 2018 2944 yen
June 2018 2821 yen
July 2018 2693 yen
August 2018 2566 yen
September 2018 2443 yen
October 2018 2315 yen
November 2018 2192 yen
December 2018 2065 yen
January 2019 1938 yen
February 2019 1819 yen
March 2019 1692 yen
April 2019 1569 yen
May 2019 1444 yen
June 2019 1321 yen
July 2019 1193 yen
August 2019 1066 yen
September 2019 943 yen
October 2019 815 yen
November 2019 692 yen
December 2019 565 yen
January 2020 438 yen
February 2020 319 yen
March 2020 115 yen
April 2020 41 yen
************************************************************

You can claim late damages! You did it! Tae-chan!

image.png

Task

In business, float is worth the death toll. Please refer to the site below and upgrade to use the Decimal module to calculate precisely!

[Python] Accurately calculate monetary numbers including decimals (using decimal module) --YoheiM .NET https://www.yoheim.net/blog.php?q=20170805

I will not match the answers.

Recommended Posts

Simulation of late damages for child support delinquency with python
Summary of tools for operating Windows GUI with Python
Support for Python 2.7 runtime on AWS Lambda (as of 2020.1)
About Fabric's support for Python 3
Create a child account for connect with Stripe in Python
[For beginners] Summary of standard input in Python (with explanation)
First neuron simulation with NEURON + Python
Summary of Hash (Dictionary) operation support for Ruby and Python
Presentation Support System with Python3
I tried a stochastic simulation of a bingo game with Python
Turn an array of strings with a for statement (Python3)
I made a lot of files for RDP connection with Python
The story of making a standard driver for db with python.
I tried to fix "I tried stochastic simulation of bingo game with Python"
[Let's play with Python] Aiming for automatic sentence generation ~ Completion of automatic sentence generation ~
Getting Started with Python for PHPer-Classes
Getting Started with Python Basics of Python
Life game with Python! (Conway's Game of Life)
10 functions of "language with battery" python
4th night of loop with for
Try frequency control simulation with Python
Implementation of Dijkstra's algorithm with python
Introductory table of contents for python3
Coexistence of Python2 and 3 with CircleCI (1.0)
Getting Started with Python for PHPer-Functions
Record of Python introduction for newcomers
Basic study of OpenCV with Python
Useful for everyday life !? Semi-automation of COSPA's strongest design of experiments with Python
I measured the speed of list comprehension, for and while with python2.7.
Explanation of creating an application for displaying images and drawing with Python
Basics of binarized image processing with Python
[Examples of improving Python] Learning Python with Codecademy
INSERT into MySQL with Python [For beginners]
WEB scraping with Python (for personal notes)
Manually ssh registration for coreserver with python
Memo to ask for KPI with python
Amplify images for machine learning with python
Execute Python script with cron of TS-220
Algorithm learned with Python 8th: Evaluation of algorithm
Tips for dealing with binaries in Python
Summary of various for statements in Python
Clogged with python update of GCP console ①
Easy introduction of speech recognition with Python
Tips for using python + caffe with TSUBAME
[Shakyo] Encounter with Python for machine learning
Process multiple lists with for in Python
[Python / PyRoom Acoustics] Room acoustic simulation with Python
Getting Started with Python for PHPer-Super Basics
UnicodeEncodeError struggle with standard output of python3
The third night of the loop with for
Pandas of the beginner, by the beginner, for the beginner [Python]
Debug for mysql connection with python mysql.connector
1. Statistics learned with Python 1-3. Calculation of various statistics (statistics)
[Python] Read images with OpenCV (for beginners)
Drawing with Matrix-Reinventor of Python Image Processing-
Recommendation of Altair! Data visualization with Python
Summary of useful techniques for Python Scrapy
WebApi creation with Python (CRUD creation) For beginners
The second night of the loop with for
Preparation for scraping with python [Chocolate flavor]
Comparison of matrix transpose speeds with Python