個人撰寫程式筆記

 

說明:勞基法規定

1.滿一年未滿三年有7天年假

2.滿3年未滿5年有10天年假

3.滿5年未滿10年有14天年假

4.超過10年每一年增加一天年假

5.最高年假天數為30天

變數解釋:

year_count = (到職日期~12/31)/365 (年) [(簡單說就是從你開始工作那天到今年的12/31日止的天數)/365]

year_count1= 年資(年) [你在公司的年資(無條件捨去小數點)]

years = 計算出來年假天數

Math.round(years*100)/100.00);//四捨五入後取years小數點兩位

 

 

程式碼開始:

 


 

if(year_count<1){//未滿一年
years=0;
out.print(Math.round(years));
//-----------------1~2年---------------------------------
}else if(year_count>=1 &&year_count<=2){//一到三年
years=(year_count-year_count1)*7;
years=(Math.round(years*100)/100.00);//四捨五入 取小數點兩位
out.print(years);
//-----------------2~3年---------------------------------
}else if(year_count<3){
years=7;
out.print(Math.round(years));
//-----------------3~4年---------------------------------
}else if(year_count>=3&&year_count<=4){
years=((year_count-year_count1)*3)+7;
years=(Math.round(years*100)/100.00);//四捨五入 取小數點兩位
out.print(years);
//-----------------4~5年---------------------------------
}else if(year_count<5){
years=10;
out.print(Math.round(years));
//-----------------5~6年---------------------------------
}else if(year_count>=5&&year_count<6){
years=((year_count-year_count1)*14)+10;
years=(Math.round(years*100)/100.00);//四捨五入 取小數點兩位
out.print(years);
//-----------------6~9年---------------------------------
}else if(year_count>=6&&year_count<10){
years=14;
out.print(Math.round(years));
//-----------------10~11年-------------------------------
}else if(year_count<11){
years=((year_count-year_count1))+14;
years=(Math.round(years*100)/100.00);//四捨五入 取小數點兩位
out.print(years);
//-----------------11年後---------------------------------
}else if(year_count>=11){
years=(year_count-10)+14;
if(years>30){//超過三十天為三十天
years=30;
out.print(years);
}else{
years=(Math.round(years*100)/100.00);//四捨五入 取小數點兩位
out.print(years);
}
}


 

arrow
arrow
    文章標籤
    JSP 勞基法 年假 IF
    全站熱搜

    penguin1989930 發表在 痞客邦 留言(0) 人氣()