PageSourceSearch

https://xynergy.ai/_next/static/chunks/7840.76b610cde2b848e9.js

js xynergy.ai collected 2026-10-05 16:02:40 UTC 9,299 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7840],{7840:(e,t,s)=>{s.r(t),s.d(t,{GiftTaxPanel:()=>C,TaxCalendarPanel:()=>D});var a=s(85047),r=s(31615),n=s(82520),l=s(866),d=s(96968),i=s(21582),c=s(58552),x=s(62557),m=s(63533),o=s(24385),u=s(80746);let h=[7,3,1];function j({taxConfig:e,reminder:t,year:s,onToggle:l,onUpdateReminderDays:i,loading:c=!1}){let[p,f]=(0,r.useState)(!1),y=t?.enabled??!1,v=t?.reminderDays??[],N=new Date(s,e.startDate.month-1,e.startDate.day),g=new Date(s,e.endDate.month-1,e.endDate.day),b=async e=>{f(!0);try{await l(e)}catch(e){console.error("切換提醒失敗:",e)}finally{f(!1)}},D=async(e,t)=>{if(!c&&!p){f(!0);try{let s=t?[...v,e].sort((e,t)=>t-e):v.filter(t=>t!==e);await i(s)}catch(e){console.error("更新提醒天數失敗:",e)}finally{f(!1)}}};return(0,a.jsxs)(n.Zp,{children:[(0,a.jsx)(n.aR,{className:"pb-3",children:(0,a.jsx)("div",{className:"flex items-center justify-between",children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(x.S,{id:`tax-${e.type}-${s}`,checked:y,onCheckedChange:b,disabled:c||p}),(0,a.jsxs)("div",{children:[(0,a.jsx)(n.ZB,{className:"text-lg",children:e.name}),(0,a.jsx)(n.BT,{className:"mt-1",children:e.description})]})]})})}),(0,a.jsx)(n.Wu,{children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm",children:[(0,a.jsx)(m.A,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:"繳納期限:"}),(0,a.jsxs)("span",{className:"font-medium",children:[(0,o.GP)(N,"yyyy年MM月dd日",{locale:u.G})," - ",(0,o.GP)(g,"yyyy年MM月dd日",{locale:u.G})]})]})]}),y?(0,a.jsxs)("div",{className:"space-y-2 pt-2 border-t",children:[(0,a.jsx)(d.J,{className:"text-sm font-medium",children:"提醒設定"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-4",children:h.map(t=>(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(x.S,{id:`reminder-${e.type}-${s}-${t}`,checked:v.includes(t),onCheckedChange:e=>D(t,e),disabled:c||p}),(0,a.jsxs)(d.J,{htmlFor:`reminder-${e.type}-${s}-${t}`,className:"text-sm cursor-pointer",children:["提前",t,"天"]})]},t))}),0===v.length&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"請至少選擇一個提醒時間"})]}):(0,a.jsx)("div",{className:"pt-2 border-t",children:(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"啟用提醒後可設定提前通知時間"})})]})})]})}var p=s(41717),f=s(73521),y=s(41178),v=s(11787);function N(){let{user:e}=(0,f.A)(),{toast:t}=(0,y.dj)(),[s,l]=(0,r.useState)(!1),d=(0,p.hk)(),{reminders:i,loading:x,loadReminders:m,createReminder:o,updateReminder:u,checkReminderExists:h}=(0,c.e)({userId:e?.uid,autoLoad:!0}),N=(0,p.cG)(d),g=async(s,a)=>{if(!e?.uid)return void t({title:"錯誤",description:"請先登入",variant:"destructive"});try{let r=h(s,d),n=p.V5[s],c=N.find(e=>e.taxType===s);if(!c)throw Error("找不到稅務日期配置");if(a)if(r){let e=i.find(e=>e.taxType===s&&e.year===d);e&&(await u(e.id,{enabled:!0}),t({title:"已啟用提醒",description:`${n.name}提醒已啟用`}))}else l(!0),await o({userId:e.uid,taxType:s,taxName:n.name,year:d,startDate:c.startDate,endDate:c.endDate,enabled:!0,reminderDays:[7]}),t({title:"已啟用提醒",description:`${n.name}提醒已啟用`});else{let e=i.find(e=>e.taxType===s&&e.year===d);e&&(await u(e.id,{enabled:!1}),t({title:"已停用提醒",description:`${n.name}提醒已停用`}))}}catch(e){console.error("切換提醒失敗:",e),t({title:"錯誤",description:e.message||"操作失敗,請稍後再試",variant:"destructive"})}finally{l(!1)}},b=async(s,a)=>{if(e?.uid)try{let e=i.find(e=>e.taxType===s&&e.year===d);e&&await u(e.id,{reminderDays:a})}catch(e){console.error("更新提醒天數失敗:",e),t({title:"錯誤",description:"更新提醒設定失敗",variant:"destructive"})}},D=(0,r.useMemo)(()=>{let e=new Date;return e.setHours(23,59,59,999),(0,p.Ko)().filter(t=>{let s=p.V5[t],a=new Date(d,s.endDate.month-1,s.endDate.day);return a.setHours(23,59,59,999),a>=e}).sort((e,t)=>
1{let s=p.V5[e],a=p.V5[t],r=new Date(d,s.endDate.month-1,s.endDate.day),n=new Date(d,a.endDate.month-1,a.endDate.day);return r.getTime()-n.getTime()})},[d]);return x?(0,a.jsx)(n.Zp,{children:(0,a.jsx)(n.Wu,{className:"flex items-center justify-center py-12",children:(0,a.jsx)(v.A,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):(0,a.jsx)("div",{className:"space-y-4",children:(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)(n.aR,{children:[(0,a.jsxs)(n.ZB,{children:["稅務日曆 - ",d,"年度"]}),(0,a.jsx)(n.BT,{children:"勾選需要提醒的稅務項目,系統會在到期前通知您"})]}),(0,a.jsx)(n.Wu,{children:(0,a.jsx)("div",{className:"space-y-4",children:D.map(e=>{let t=p.V5[e],r=i.find(t=>t.taxType===e&&t.year===d);return(0,a.jsx)(j,{taxConfig:t,reminder:r,year:d,onToggle:t=>g(e,t),onUpdateReminderDays:t=>b(e,t),loading:s},`${e}-${d}`)})})})]})})}function g(e){let t=Math.max(0,e-244e4),s=0,a=0;t<=2811e4?(s=.1,a=0):t<=5621e4?(s=.15,a=1405500):(s=.2,a=4216e3);let r=Math.max(0,t*s-a);return{giftAmount:e,exemption:244e4,taxableAmount:t,taxRate:s,progressiveDifference:a,taxAmount:Math.round(r)}}var b=s(35617);function D(){return(0,a.jsx)(N,{})}let w=[1,2,3,4,5,6,8,10];function C(){let[e,t]=(0,r.useState)(""),[s,c]=(0,r.useState)(1),x=1e4*Math.max(0,Number(e)||0),m=s>0?Math.floor(x/s):0,o=(0,r.useMemo)(()=>x>0?g(x):null,[x]),u=(0,r.useMemo)(()=>x>0&&s>1?function(e,t,s){let a,r,n=e>0?g(e).taxAmount:0,{totalTax:l}=(r=(a=Array(t).fill(s).map(e=>e<=0?0:g(e).taxAmount)).reduce((e,t)=>e+t,0),{yearlyTaxes:a,totalTax:Math.round(r)});return{singleYearTax:n,multiYearTotalTax:l,multiYearSavings:Math.round(n-l)}}(x,s,m):null,[x,s,m]);return(0,a.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)(n.aR,{children:[(0,a.jsx)(n.ZB,{className:"text-base",children:"贈與稅試算"}),(0,a.jsx)(n.BT,{children:"免稅額每人每年 244 萬;稅率 10%/15%/20% 累進"})]}),(0,a.jsxs)(n.Wu,{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(d.J,{htmlFor:"gift-amount",children:"總贈與金額(萬元)"}),(0,a.jsx)(l.p,{id:"gift-amount",type:"number",min:0,value:e,onChange:e=>t(e.target.value),placeholder:"例如:1000"})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(d.J,{children:"分年贈與年數"}),(0,a.jsxs)(i.l6,{value:String(s),onValueChange:e=>c(Number(e)),children:[(0,a.jsx)(i.bq,{children:(0,a.jsx)(i.yv,{})}),(0,a.jsx)(i.gC,{children:w.map(e=>(0,a.jsxs)(i.eb,{value:String(e),children:[e," 年",e>1?`(每年約 ${(0,b.C)(Math.floor(x/e))})`:""]},e))})]})]}),o&&(0,a.jsxs)("div",{className:"space-y-1.5 rounded-lg border bg-muted/30 p-4 text-sm",children:[(0,a.jsx)(T,{label:"贈與金額",value:(0,b.C)(o.giftAmount)}),(0,a.jsx)(T,{label:"免稅額",value:`- ${(0,b.C)(o.exemption)}`}),(0,a.jsx)(T,{label:"課稅贈與淨額",value:(0,b.C)(o.taxableAmount)}),(0,a.jsx)(T,{label:"適用稅率",value:o.taxableAmount>0?`${Math.round(100*o.taxRate)}%`:"—"}),o.progressiveDifference>0&&(0,a.jsx)(T,{label:"累進差額",value:`- ${(0,b.C)(o.progressiveDifference)}`}),(0,a.jsxs)("div",{className:"mt-2 flex items-center justify-between border-t pt-2 text-base font-bold",children:[(0,a.jsx)("span",{children:"一次贈與應納稅額"}),(0,a.jsx)("span",{className:"text-red-500",children:(0,b.C)(o.taxAmount)})]})]})]})]}),(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)(n.aR,{children:[(0,a.jsx)(n.ZB,{className:"text-base",children:"單年 vs 分年比較"}),(0,a.jsx)(n.BT,{children:"分年贈與可逐年使用免稅額,通常可大幅節稅"})]}),(0,a.jsx)(n.Wu,{children:u?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"rounded-lg border p-4",children:[(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:"一次贈與(單年)"}),(0,a.jsx)("div",{className:"mt-1 text-xl font-bold",children:(0,b.C)(u.singleYearTax)})]}),(0,a.jsxs)("div",{className:"rounded-lg border p-4",children:[(0,a.jsxs)("div",{className:"text-xs text-muted-foreground",children:["分 ",s," 年贈與(每年 ",(0,b.C)(m),")"]}),(0,a.jsx)("div",{className:"mt-1 text-xl font-bold",children:(0,b.C)(u.multiYearTotalTax)})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-emerald-500/40 bg-emerald-500/8 p-4",children:[(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:"分年可節省"}),(0,a.jsx)("div",{className:"mt-1 text-xl font-bold text-emerald-600 dark:text-emerald-400",children:(0,b.C)(u.multiYearSavings)})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"*試算僅供參考,實際應納稅額以國稅局核定為準;跨年度贈與需留意每年 12/31 前完成移轉。"})]}):(0,a.jsx)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:x>0?"選擇 2 年以上可查看分年節稅比較":"輸入總贈與金額開始試算"})})]})]})}function T({label:e,value:t}){return(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e}),(0,a.jsx)("span",{className:"tabular-nums",children:t})]})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.