import { Maybe } from '@/core';
import ISummary from '@/core/models/summary';
import { IEnumTranslate } from '@/shared/models/enum_translate.type';

export interface IPublicSaleInvoicesRawResponse {
  id: string;
  code: string;
  invoice_date: string;
  invoice_number: string;
  total_amount: string;
  pos: Pos;
  consumer_account: ConsumerAccount;
  payments: Payments[];
  type: IEnumTranslate;
  status: IEnumTranslate;
  customer: Maybe<Customer>;
  unknown_customer: Maybe<Record<string, unknown>>;
  items: InvoiceItem[];
  notes?: string;
}

export interface IPublicSaleInvoicesResponse extends IPublicSaleInvoicesRawResponse {}

interface ConsumerAccount {
  role: string;
  account: Account;
}

interface Account {
  username: string;
}

interface Pos extends ISummary {
  complex: Complex;
}

interface Complex extends ISummary {
  business_activity: BA;
}

interface BA extends ISummary {
  guild: ISummary;
}

interface Payments {
  amount: string;
  paid_at?: string;
  payment_method: string;
}

interface Customer {
  type: string;
  individual: Individual;
  legal: Legal;
}

interface Individual {
  first_name: string;
  last_name: string;
  national_code: string;
  mobile_number: string;
}

interface Legal {
  company_name: string;
  economic_code: string;
  registration_number: string;
}

interface InvoiceItem {
  good_snapshot: GoodSnapshot;
  measure_unit_text: string;
  quantity: string;
  total_amount: string;
  unit_price: string;
  discount: string;
  payload: InvoiceItemPayload;
  sku_code: string;
  sku_vat: string;
  notes: Maybe<string>;
}

interface InvoiceItemPayload {
  karat: string;
  wages: number;
  profit: number;
  commission: number;
}

interface GoodSnapshot {
  good: Good;
}

interface Good {
  id: string;
  sku: Sku;
  name: string;
  barcode: Maybe<string>;
  category: ISummary;
  image_url: string;
  local_sku: Maybe<string>;
  measure_unit: MeasureUnit;
  pricing_model: string;
  base_sale_price: string;
}

interface MeasureUnit extends ISummary {
  code: string;
}

interface Sku extends ISummary {
  VAT: string;
  code: string;
}
