diff --git a/src/entities/transaction/ui/all-transaction-part-cancel.tsx b/src/entities/transaction/ui/all-transaction-part-cancel.tsx index 85994eb..a03fd72 100644 --- a/src/entities/transaction/ui/all-transaction-part-cancel.tsx +++ b/src/entities/transaction/ui/all-transaction-part-cancel.tsx @@ -191,21 +191,27 @@ export const AllTransactionPartCancel = ({ > -
  • - ·  {t('transaction.fields.totalCancelAmount')} - - ) => onChangeToTotalCancelAmount(parseInt(e.target.value)) } - > - -
  • +
    +
    + +
    + ) => onChangeToTotalCancelAmount(parseInt(e.target.value)) } + > +
    +
    +
    { !!isCompoundTax &&
    @@ -306,7 +312,10 @@ export const AllTransactionPartCancel = ({
    } -
    +
    { - const { t } = useTranslation(); - const location = useLocation(); - const userInfo = useStore.getState().UserStore.userInfo; - const userMid = useStore.getState().UserStore.mid; - const tid = location.state.tid; - const serviceCode = location.state.serviceCode; - - useSetHeaderTitle(t('transaction.cancelTitle')); - useSetHeaderType(HeaderType.RightClose); - useSetFooterMode(false); - - // all or part - const [tabAction, setTabAction] = useState(CancelTabKeys.All); - const [debtPreventionCancelDisplayInfo, setDebtPreventionCancelDisplayInfo] = useState(null); - const [debtPreventionCancelRequestInfo, setDebtPreventionCancelRequestInfo] = useState(null); - const [goodsVat, setGoodsVat] = useState(null); - const [isCompoundTax, setIsCompoundTax] = useState(false); - const [isConditionalVatAutoCalcMerchant, setIsConditionalVatAutoCalcMerchant] = useState(false); - const [isNpg, setIsNpg] = useState(false); - const [isVatAutoCalcMerchant, setIsVatAutoCalcMerchant] = useState(false); - const [isVatDisplayed, setIsVatDisplayed] = useState(false); - const [partCancelCl, setPartCancelCl] = useState(false); - const [remainAmount, setRemainAmount] = useState(0); - const [serviceAmount, setServiceAmount] = useState(null); - const [supplyAmount, setSupplyAmount] = useState(null); - const [taxFreeAmount, setTaxFreeAmount] = useState(null); - const [vatAutoCalcSummary, setVatAutoCalcSummary] = useState(0); - const [totalCancelAmount, setTotalCancelAmount] = useState(0); - const [cancelPassword, setCancelPassword] = useState(''); - const [cancelSupplyAmount, setCancelSupplyAmount] = useState(0); - const [cancelGoodsVat, setCancelGoodsVat] = useState(0); - const [cancelTaxFreeAmount, setCancelTaxFreeAmount] = useState(0); - const [cancelServiceAmount, setCancelServiceAmount] = useState(0); - - const [requestSuccess, setRequestSuccess] = useState(true); - - const [bankCode, setBankCode] = useState(''); - const [accountNo, setAccountNo] = useState(''); - const [accountHolder, setAccountHolder] = useState(''); - - const [cancelPreventBondOn, setCancelPreventBondOn] = useState(false); - - const { mutateAsync: transactionCancel } = useAllTransactioCancleMutation(); - const { mutateAsync: allTransactionCancelInfo } = useAllTransactioCancleInfoMutation(); - - const callCancelInfo = () => { - let params: AllTransactionCancelInfoParams = { - serviceCode: serviceCode, - tid: tid, - mid: userMid - }; - allTransactionCancelInfo(params).then((rs: AllTransactionCancelInfoResponse) => { - if(rs.debtPreventionCancelDisplayInfo !== null){ - setCancelPreventBondOn(true); - } - else{ - setDebtPreventionCancelDisplayInfo(rs.debtPreventionCancelDisplayInfo); - setDebtPreventionCancelRequestInfo(rs.debtPreventionCancelRequestInfo); - setGoodsVat(rs.goodsVat); - setIsCompoundTax(rs.isCompoundTax); - setIsConditionalVatAutoCalcMerchant(rs.isConditionalVatAutoCalcMerchant); - setIsNpg(rs.isNpg); - setIsVatAutoCalcMerchant(rs.isVatAutoCalcMerchant); - setIsVatDisplayed(rs.isVatDisplayed); - setPartCancelCl(rs.partCancelCl); - setRemainAmount(rs.remainAmount); - setServiceAmount(rs.serviceAmount); - setSupplyAmount(rs.supplyAmount); - setTaxFreeAmount(rs.taxFreeAmount); - setVatAutoCalcSummary(rs.vatAutoCalcSummary); - - if(!partCancelCl){ - setTotalCancelAmount(rs.remainAmount); - } - else{ - setTotalCancelAmount(0); - } - } - - // partCancelCl == true ==> 부분취소 버튼 활성화 - // isCompoundTax == true ==> 부분취소의 복합과세 노출 - // debtPreventionCancelDisplayInfo != null => 입금 후 취소 페이지 노출 - // [취소신청]버튼 클릭시 - // debtPreventionCancelDisplayInfo.isCancel == true => 취소api호출 - // debtPreventionCancelRequestInfo 이 값 통쨰로 변조없이 그대로 api에 전달 - // debtPreventionCancelDisplayInfo.isCancel == false => 얼럿만 띄우고 취소요청하면안됨 - - - }).catch((e: any) => { - if(e.response?.data?.error?.message){ - snackBar(e.response?.data?.error?.message); - return; - } - }); - }; - - const callTransactionCancel = () => { - if(debtPreventionCancelDisplayInfo?.isCancel === false){ - snackBar('취소요청이 불가능 합니다.'); - } - else{ - let transactionCancelParams: AllTransactionCancelParams = { - tid: tid, - cancelAmount: totalCancelAmount || 0, - cancelPassword: cancelPassword, - bankCode: bankCode, - accountNo: accountNo, - accountHolder: accountHolder, - supplyAmount: (!!partCancelCl)? cancelSupplyAmount: (supplyAmount || 0), - goodsVatAmount: (!!partCancelCl)? cancelGoodsVat: (goodsVat || 0), - taxFreeAmount: (!!partCancelCl)? cancelTaxFreeAmount: (taxFreeAmount || 0), - serviceAmount: (!!partCancelCl)? cancelServiceAmount: (serviceAmount || 0), - clientIp: userInfo.clientAddressIP, - partCancelCl: partCancelCl, - isNpg: isNpg, - serviceCode: serviceCode - }; - transactionCancel(transactionCancelParams).then((rs: AllTransactionCancelResponse) => { - console.log(rs); - setRequestSuccess(true); - }).catch((e: any) => { - setRequestSuccess(false); - if(e.response?.data?.error?.message){ - snackBar(e.response?.data?.error?.message); - return; - } - }); - } - - }; - useEffect(() => { - callCancelInfo(); - }, []); - - const onClickToChangeTab = (tab: CancelTabKeys) => { - setTabAction(tab); - }; - return ( - <> -
    -
    -
    -
    - - { !!partCancelCl && - - } -
    -
    - { (tabAction === CancelTabKeys.All) && - - } - { !!partCancelCl && (tabAction === CancelTabKeys.Part) && - - } -
    -
    - -
    -
    -
    -
    - { !!cancelPreventBondOn && - - } - - ); -};