Skip to content

Instantly share code, notes, and snippets.

@ncaq
Last active January 29, 2025 08:35
Show Gist options
  • Save ncaq/9bae92c1b4c9f51aed784dacb150c961 to your computer and use it in GitHub Desktop.
Save ncaq/9bae92c1b4c9f51aed784dacb150c961 to your computer and use it in GitHub Desktop.
テレワーク補助を計算しつつ途中式を見るためのプログラム
{-# LANGUAGE QuasiQuotes #-}
-- | テレワーク補助を計算しつつ途中式を見るためのプログラム。
-- 一回出力が証拠付きで出せれば良いだけなので、
-- 真面目に書いてない。
module Main (main) where
import Data.Maybe (fromJust)
import Data.String.Here
import Data.Time.Calendar
import Numeric
main :: IO ()
main = do
補助対象の通信費表示
補助対象の電気料金表示
補助対象の通信費表示 :: IO ()
補助対象の通信費表示 =
mapM_ (\(month, 在宅勤務日数) -> do
let 月の日数 = gregorianMonthLength year month
(計算式, 金額) = 補助対象の通信費 通信費 在宅勤務日数 (fromIntegral 月の日数)
putStrLn [i|${month}月: ${計算式} = ${showRationalAsDecimal 金額}|]
)
補助対象の月勤務情報
補助対象の電気料金表示 :: IO ()
補助対象の電気料金表示 =
mapM_ (\(month, 在宅勤務日数) -> do
let 月の日数 = gregorianMonthLength year month
電気料金 = fromIntegral $ fromJust $ lookup month 月ごとの電気料金
(計算式, 金額) = 補助対象の電気料金 電気料金 在宅勤務日数 (fromIntegral 月の日数)
putStrLn [i|${month}月: ${計算式} = ${showRationalAsDecimal 金額}|]
)
補助対象の月勤務情報
補助対象の通信費 :: Integer -> Integer -> Integer -> (String, Rational)
補助対象の通信費 月の使用料 在宅勤務日数 月の日数 =
( [i|月の使用料(${月の使用料})×在宅勤務日数(${在宅勤務日数})÷月の日数(${月の日数})÷当該機器の利用者数(${当該機器の利用者数})×0.5|]
, (fromIntegral 月の使用料 * (fromIntegral 在宅勤務日数 / fromIntegral 月の日数) / fromIntegral 当該機器の利用者数) * 0.5
)
補助対象の電気料金 :: Integer -> Integer -> Integer -> (String, Rational)
補助対象の電気料金 月の使用料 在宅勤務日数 月の日数 =
( [i|月の使用料(${月の使用料})×業務利用の部屋の床面積(${showRationalAsDecimal 業務利用の部屋の床面積})÷自宅の床面積(${showRationalAsDecimal 自宅の床面積})×在宅勤務日数(${在宅勤務日数})÷月の日数(${月の日数})×0.5|]
, (fromIntegral 月の使用料 * (業務利用の部屋の床面積 / 自宅の床面積) * (fromIntegral 在宅勤務日数 / fromIntegral 月の日数)) * 0.5
)
補助対象の月勤務情報 :: [(MonthOfYear, Integer)]
補助対象の月勤務情報 = filter (\(month, _) -> month `elem` 補助対象の月) 月ごとの勤務日数
-- | 有理数を事務担当者が許容できそうな程度の誤差の小数点数で表示する。
showRationalAsDecimal :: Rational -> String
showRationalAsDecimal r = showFFloat (Just 5) (fromRational r :: Double) ""
-- * 申請ごとに変わる値。
-- | うるう年の判定に関わる。雑にハードコーディング。
year :: Year
year = 2024
-- | 申請対象は毎回変わる。
補助対象の月 :: [MonthOfYear]
補助対象の月 = [10, 11, 12]
-- * ユーザごとに違う値。
当該機器の利用者数 :: Integer
当該機器の利用者数 = 2
-- | 固定回線なので固定金額。
通信費 :: Integer
通信費 = 4917
-- | ジョブカンの実働日数から取ってくる。
月ごとの勤務日数 :: [(MonthOfYear, Integer)]
月ごとの勤務日数 =
[ (10, 20)
, (11, 19)
, (12, 18)
]
業務利用の部屋の床面積 :: Rational
業務利用の部屋の床面積 =
-- 畳をcm^2に変換。
(* 1.824) $
8 + -- メイン部屋。
6 + -- 小部屋。
2 + -- 洗面所。
1 -- トイレ。
-- | 平方メートル。
自宅の床面積 :: Rational
自宅の床面積 = 43.50
月ごとの電気料金 :: [(MonthOfYear, Integer)]
月ごとの電気料金 =
[ (10, 12472)
, (11, 9835)
, (12, 9363)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment