Last active
April 25, 2023 07:35
-
-
Save ncaq/9bae92c1b4c9f51aed784dacb150c961 to your computer and use it in GitHub Desktop.
テレワーク補助を計算しつつ途中式を見るためのプログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | テレワーク補助を計算しつつ途中式を見るためのプログラム。 | |
-- 一回出力が証拠付きで出せれば良いだけなので、 | |
-- 真面目に書いてません。 | |
module Main (main) where | |
import qualified Data.List as L | |
import Data.Maybe (fromJust) | |
import Data.Ratio | |
data MonthWork | |
= MonthWork | |
{ monthWork在宅勤務日数 :: Integer | |
, monthWork月の日数 :: Integer | |
} | |
deriving (Eq, Ord, Read, Show) | |
main :: IO () | |
main = do | |
補助対象の通信費 <- 補助対象の通信費全体 | |
putStrLn $ "補助対象の通信費:\t" <> show (fromRational 補助対象の通信費) | |
補助対象の電気料金 <- 補助対象の電気料金全体 | |
putStrLn $ "補助対象の電気料金:\t" <> show (fromRational 補助対象の電気料金) | |
補助対象の通信費全体 :: IO Rational | |
補助対象の通信費全体 = sum <$> | |
mapM (\(month, MonthWork { monthWork在宅勤務日数 = 在宅勤務日数, monthWork月の日数 = 月の日数 }) -> do | |
let 金額 = 補助対象の通信費 通信費 (fromIntegral 在宅勤務日数) (fromIntegral 月の日数) | |
putStrLn $ L.intercalate ",\t" | |
[ "月:\t" <> show month | |
, "月の使用料:\t" <> show 通信費 | |
, "在宅勤務日数:\t" <> show 在宅勤務日数 | |
, "月の日数:\t" <> show 月の日数 | |
, "当該機器の利用者数:\t" <> show 当該機器の利用者数 | |
, "金額:\t" <> show ((fromRational :: Rational -> Double) 金額) | |
] | |
return 金額) | |
補助対象の月勤務情報 | |
補助対象の電気料金全体 :: IO Rational | |
補助対象の電気料金全体 = sum <$> | |
mapM (\(month, MonthWork { monthWork在宅勤務日数 = 在宅勤務日数, monthWork月の日数 = 月の日数 }) -> do | |
let 電気料金 = fromIntegral $ fromJust $ lookup month 月ごとの電気料金 | |
金額 = 補助対象の電気料金 電気料金 (fromIntegral 在宅勤務日数) (fromIntegral 月の日数) | |
putStrLn $ L.intercalate ",\t" | |
[ "月:\t" <> show month | |
, "月の使用料:\t" <> show 電気料金 | |
, "業務利用の部屋の床面積:\t" <> show 業務利用の部屋の床面積 | |
, "自宅の床面積:\t" <> show 自宅の床面積 | |
, "在宅勤務日数:\t" <> show 在宅勤務日数 | |
, "月の日数:\t" <> show 月の日数 | |
, "金額:\t" <> show ((fromRational :: Rational -> Double) 金額) | |
] | |
return 金額) | |
補助対象の月勤務情報 | |
補助対象の通信費 :: Rational -> Rational -> Rational -> Rational | |
補助対象の通信費 月の使用料 在宅勤務日数 月の日数 = | |
(月の使用料 * (在宅勤務日数 / 月の日数) / fromIntegral 当該機器の利用者数) * 0.5 | |
補助対象の電気料金 :: Rational -> Rational -> Rational -> Rational | |
補助対象の電気料金 月の使用料 在宅勤務日数 月の日数 = | |
(月の使用料 * (業務利用の部屋の床面積 / 自宅の床面積) * (在宅勤務日数 / 月の日数)) * 0.5 | |
補助対象の月勤務情報 :: [(Integer, MonthWork)] | |
補助対象の月勤務情報 = filter (\(month, _) -> month `elem` 補助対象の月) 月ごとの勤務日数情報 | |
月ごとの勤務日数情報 :: [(Integer, MonthWork)] | |
月ごとの勤務日数情報 = | |
(\(month, 勤務日数) -> (month, MonthWork (fromIntegral 勤務日数) (fromIntegral $ fromJust $ lookup month 月ごとの日数))) <$> | |
月ごとの勤務日数 | |
-- | 真面目なプログラムならライブラリを使って求めますが、 | |
-- 今回はやっつけなので雑。 | |
月ごとの日数 :: [(Integer, Integer)] | |
月ごとの日数 = | |
[ ( 1, 31) | |
, ( 2, 28) -- 2022年なので非閏年とハードコーディング | |
, ( 3, 31) | |
, ( 4, 30) | |
, ( 5, 31) | |
, ( 6, 30) | |
, ( 7, 31) | |
, ( 8, 31) | |
, ( 9, 30) | |
, (10, 31) | |
, (11, 30) | |
, (12, 31) | |
] | |
-- | 申請対象は毎回変わります。 | |
補助対象の月 :: [Integer] | |
補助対象の月 = [11, 12, 1, 2, 3] | |
-- * ここからユーザごとに違う値。 | |
当該機器の利用者数 :: Integer | |
当該機器の利用者数 = 3 | |
-- | 固定回線なので固定金額。 | |
通信費 :: Rational | |
通信費 = 1298880 / 82 / 12 | |
-- | ジョブカンの実働日数からとってきています。 | |
月ごとの勤務日数 :: [(Integer, Integer)] | |
月ごとの勤務日数 = | |
[ (11, 19) | |
, (12, 18) | |
, ( 1, 18) | |
, ( 2, 20) | |
, ( 3, 22) | |
] | |
業務利用の部屋の床面積 :: Rational | |
業務利用の部屋の床面積 = | |
-- 畳をcm^2に変換。 | |
(* 1.824) $ | |
12.8 + -- メイン部屋。 | |
5 + -- 小部屋。 | |
4.3 + -- 台所。 | |
2 + -- 洗面所。 | |
1 -- トイレ。 | |
-- | 平方メートル。 | |
自宅の床面積 :: Rational | |
自宅の床面積 = 96.5 | |
月ごとの電気料金 :: [(Integer, Integer)] | |
月ごとの電気料金 = | |
[ (11, 20251) | |
, (12, 26145) | |
, ( 1, 21685) | |
, ( 2, 18699) | |
, ( 3, 17570) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment