import { IMAGE_ROOT } from '@/shared/constants/common'; import { snackBar } from '@/shared/lib'; import { toPng } from 'html-to-image'; import { useTranslation } from 'react-i18next'; import '@/shared/ui/assets/css/style-tax-invoice.css'; import { useEffect, useState, CSSProperties } from 'react'; import { ClipLoader, FadeLoader } from 'react-spinners'; import { NumericFormat } from 'react-number-format'; import { AmountInfo, CustomerInfo, IssueInfo, MerchantInfo, ProductInfo, TransactionInfo } from '@/entities/transaction/model/types'; import moment from 'moment'; const override: CSSProperties = { position: 'fixed', display: 'block', margin: '0 auto', top: '50%', left: '50%', }; export interface CashReceiptSampleProps { cashReceiptSampleOn: boolean; setCashReceiptSampleOn: (cashReceiptSampleOn: boolean) => void; merchantInfo?: MerchantInfo; issueInfo?: IssueInfo; amountInfo?: AmountInfo; transactionInfo?: TransactionInfo; customerInfo?: CustomerInfo; productInfo?: ProductInfo; }; export const CashReceiptSample = ({ cashReceiptSampleOn, setCashReceiptSampleOn, merchantInfo, issueInfo, amountInfo, transactionInfo, customerInfo, productInfo }: CashReceiptSampleProps) => { let [loading, setLoading] = useState(false); let [color, setColor] = useState('#0b0606'); const { t } = useTranslation(); const downloadImage = () => { const section = document.getElementById('image-section') as HTMLElement; toPng(section).then((image) => { const link = document.createElement('a'); let fileName = 'cash-receipt-' + moment().format('YYMMDDHHmmss'); link.download = fileName + '.png'; link.href = image; link.click(); snackBar(t('common.imageRequested'), function(){ onClickToClose(); }); }).finally(() => { setLoading(false); }); }; const onClickToClose = () => { setCashReceiptSampleOn(false); }; const getDateTime = () => { let date = ''; let time = ''; if(!!issueInfo?.issueDate){ date = moment(issueInfo?.issueDate).format('YYYY.MM.DD'); } if(!!issueInfo?.issueDate && !!issueInfo?.issueTime){ time = moment(issueInfo?.issueDate+' '+issueInfo?.issueTime).format('HH:mm:ss'); } if(!!date && !!time){ return date + ' | ' + time; } else{ return ''; } }; useEffect(() => { if(!!cashReceiptSampleOn){ setLoading(true); setTimeout(() => { downloadImage(); }, 300); } }, [cashReceiptSampleOn]); return ( <>
NICEPAY
현금영수증
상점정보
상호
{ merchantInfo?.merchantName }
대표자
{ merchantInfo?.representativeName }
사업자등록번호
{ merchantInfo?.businessNumber }
전화번호
{ merchantInfo?.phoneNumber }
주소
{ merchantInfo?.address }
URL
{ merchantInfo?.merchantUrl }
결제정보
총 결제금액
과세금액
부가세
면세금액
봉사료
결제수단
{ transactionInfo?.paymentMethod }
현금영수증번호
{ issueInfo?.issueNumber }
주문자
{ customerInfo?.customerName }
상품명
{ productInfo?.productName }
승인번호
{ issueInfo?.approvalNumber }
거래일시
{ getDateTime() }
용도
{ issueInfo?.purpose }
* 본 영수증은 조세특례제한법 제 126조의 3및 동법 시행령 제 121조의 3규정에 의거, 연말정산시 소득공제 혜택 부여의 목적으로 발행됩니다.
* 현금 거래 완료 건에 대한 국세청의 검증 소요기간은 2일이며 결제하신 다음날 검증이 완료된 현금영수증을 발급받을 수 있습니다.
* 현금영수증 문의 126-1-1
{ !!loading && <>
} ); };