package ru.soune.nocopy.entity.payout;

import jakarta.persistence.Column;
import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import lombok.*;

@Entity
@DiscriminatorValue("BANK_TRANSFER")
@NoArgsConstructor
@AllArgsConstructor
@Getter @Setter
public class BankTransferPayoutMethod extends PayoutMethod {

    @Column(name = "bank_name")
    private String bankName;

    @Column(name = "bic")
    private String bic;

    @Column(name = "correspondent_account")
    private String correspondentAccount;

    @Column(name = "account_number")
    private String accountNumber;

    @Column(name = "account_holder")
    private String accountHolder;

    @Column(name = "inn")
    private String inn;

    @Column(name = "kpp")
    private String kpp;

    @Override
    public String getDisplayName() {
        return String.format("Tax %s in %s", getMaskedAccount(), bankName);
    }

    @Override
    public String getMaskedDetails() {
        return getMaskedAccount();
    }

    private String getMaskedAccount() {
        if (accountNumber == null || accountNumber.length() < 4) return "";
        return "..." + accountNumber.substring(accountNumber.length() - 4);
    }
}
