import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.entity';
import {
  TransactionPaymentType,
  TransactionType,
  TransactionUserType,
} from '../../constants';
import { STATUS } from 'src/core/strings/constants/base.constants';
import { TransactionItemEntity } from './transaction-item.entity';
import { TransactionTaxEntity } from './transaction-tax.entity';

export interface TransactionEntity extends BaseStatusEntity {
  // general info
  is_recap_transaction: boolean;
  type: TransactionType;
  invoice_code: string;
  creator_counter_no: number; // nomor pos transaksi dibuat
  creator_counter_name: string; // name pos transaksi dibuat

  // season data
  season_period_id: string;
  season_period_name: string;
  season_period_type_id: string;
  season_period_type_name: string;

  // customer info
  customer_category_id: string;
  customer_category_name: string;
  customer_type: TransactionUserType;
  customer_name: string;
  customer_phone: string;
  customer_email: string;
  customer_description: string;
  no_of_group: number;

  booking_date: Date; // tnaggal untuk booking
  booking_date_before: Date; // tnaggal untuk booking
  settlement_date: Date; // tanggal status berubah menjadi settlement
  invoice_date: Date; // tanggal invoice terkirim

  // discount data
  discount_code_id: string;
  discount_code: string;
  discount_percentage: number;
  discount_value: number;

  // payment data
  payment_type: TransactionPaymentType;
  payment_type_counter: TransactionPaymentType;
  payment_type_method_id: string;
  payment_type_method_name: string;
  payment_type_method_number: string;
  payment_type_method_qr: string;
  payment_card_information: string;
  payment_code_reference: string;
  payment_code: string;
  payment_midtrans_token: string;
  payment_midtrans_url: string;
  payment_date: Date;
  payment_date_bank: Date;

  // calculation data
  payment_sub_total: number; // total invoice tanpa discount
  payment_discount_total: number; // total discount
  payment_total: number; // total invoice
  payment_total_pay: number; // total pembayaran user
  payment_change: number; // total kembalian

  // share and profit data
  payment_total_share: number; // total share untuk para tenant
  payment_total_tax: number; // total untuk tax
  payment_total_profit: number; // total untuk profit perusahan
  payment_total_dpp: number;
  profit_share_formula: string;
  sales_price_formula: string;

  // mdr data
  reconciliation_mdr: number;
  reconciliation_status: STATUS;
  reconciliation_confirm_date: string;
  reconciliation_confirm_by: string;
  payment_total_net_profit: number; // net pendapatan

  // sending data
  sending_invoice_at: number;
  sending_invoice_status: STATUS;
  sending_qr_at: number;
  sending_qr_status: STATUS;

  parent_id?: string;

  calendar_id?: string;
  calendar_link?: string;

  items: TransactionItemEntity[];
  taxes?: TransactionTaxEntity[];
}
