ふるさと納税で 21,000 円の米を手に入れた場合どうなるのか

「ふるさと納税はやっただけ得する。」と ユーチューバーが言っていたので計算してみる。

米5kg 21,000円というのがあった。

もともとは大体3割くらいの値段の商品らしい。


21,000 x 0.3 = 6,300

税金を計算してみる。

1.所得税からの控除:(ふるさと納税額-2000円)×「所得税の税率」(確定申告の場合)
2.住民税からの控除(基本分):(ふるさと納税額-2000円)×10%
3.住民税からの控除(特例分):(ふるさと納税額-2000円)×(100%-10%-所得税の税率)

👉 31歳の会社員。友人に「6万円ふるさと納税した」と言ったら、「年収高いな!」と言われました。ふるさと納税の金額は言わないほうがいいですか?(ファイナンシャルフィールド) - Yahoo!ニュース


(21,000 - 2,000) x 0.3 ‎ = 5,700
(21,000 - 2,000) x 0.1 ‎ = 1,900
(21,000 - 2,000) x (1 - 0.1 - 0.3) ‎ = 11,400
-------------------------------------------
  5,700 + 1,900 + 11,400 ‎ = 19,000

となり、税金の控除金額は 19,000 円増える。

ここで、同等の米が Amazon で売られているか確認。


👉 Amazon.co.jp: by Amazon【精米】 北海道産 ななつぼし 5kg 農薬節減米 (Happy Belly) 令和6年産 : 食品・飲料・お酒

4,550円。

よって、

4,550 円の米が 2,000 円で買える。

ということか。

あれ、単純に、


ふるさと納税金額 - 2,000 円

が節税できるということで良かったのか。

 

🤔 まとめ

しかし、問題点も考えておく。

- 届くのがいつかわからないし、遅い。
- アマゾンふるさと納税でも最短10日(平均1ヶ月)以上かかる。
- 確定申告が面倒。

うーん、どんなものを選んだらいいのかな。


この操作を完了する権限がありません [OR-CAC-07]

これなんなのか。

聞いてみました。


スルーかな。

仕方ないので関連ポストを探す。


【Kotlin】Android アプリ 課金実装時の ProductDetails や Purchase の内容

公式ドキュメントの解読には骨が折れる。

詳細どんなものが含まれているのか。

Timber ですが、純正 Log でもいけるので置き換えてどうぞ。

👉 JakeWharton/timber: A logger with a small, extensible API which provides utility on top of Android's normal Log class.


Jetpack Compose で Activity を取得する

なんとなくまだ古くさい感じはありますが。


val context = LocalContext.current


fun Context.getActivityOrNull(): Activity? {
    var context = this
    while (context is ContextWrapper) {
        if (context is Activity) return context
        context = context.baseContext
    }    
    return null
}


fun Context.findActivity(): Activity {
    var context = this
    while (context is ContextWrapper) {
        if (context is Activity) return context
        context = context.baseContext
    }
    throw IllegalStateException("Permissions should be called in the context of an Activity")
}

👉 android - How to get activity in compose - Stack Overflow


android.intent.action.MY_PACKAGE_REPLACED をBorodcastReceiver で反応させるテスト

Debug でなく Run ボタンでいけてたような気がするが
セキュリティの絡みか、今では反応がない。

なので、

コマンドラインで adb から。


❯ adb shell am broadcast -a android.intent.action.MY_PACKAGE_REPLACED
Broadcasting: Intent { act=android.intent.action.MY_PACKAGE_REPLACED flg=0x400000 }

Exception occurred while executing 'broadcast':
java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.MY_PACKAGE_REPLACED from pid=6153, uid=2000

ダメですか。

またセキュリティですか。

 

🤔 解決法

一度、ビルドして、 apk をインストールしたらいけた。

Go to Build -> Build APK, and note the location that the .apk is stored.

Then, run in terminal:

adb install -r debugapp.apk

This will trigger the MY_PACKAGE_REPLACED intent, since newer Android SDKs only allow the system to broadcast it.

👉 Android: Broadcast ACTION_MY_PACKAGE_REPLACED never received - Stack Overflow

-r」いるんかね ? いらなくね ?

 

🤔 まとめ

今後以下でやろう。


❯ ./gradlew assembleDebug  
                         
> Configure project :app
BUILD SUCCESSFUL in 59s
42 actionable tasks: 21 executed, 21 up-to-date

❯ find . -name "*.apk" | fzf | xargs adb install

Performing Streamed Install
Success

❯ adb shell am start -a android.intent.action.MAIN -n YOUR_PACKAGE/.TARGET_ACTIVITY 

Starting: Intent { act=android.intent.action.MAIN cmp=YOUR_PACKAGE/.TARGET_ACTIVITY }

当然、バージョン番号は上げておかなければなりません。

👉 junegunn/fzf: :cherry_blossom: A command-line fuzzy finder