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

export interface ISaleInvoiceFullRawResponse {
  id: string;
  code: string;
  total_amount: string;
  invoice_date: string;
  consumer_account: ConsumerAccount;
  pos: Pos;
  payments: Payment[];
  items: Item[];
  created_at: string;
  notes?: string;
  customer?: Customer;
  unknown_customer?: UnknownCustomer;
  status: IEnumTranslate<TspProviderResponseStatus>;
}

export interface ISaleInvoiceFullResponse extends ISaleInvoiceFullRawResponse {}

interface Item {
  id: string;
  good_id: string;
  service_id: null;
  quantity: string;
  measure_unit_code: string;
  measure_unit_text: string;
  sku_code: string;
  unit_price: string;
  discount: string;
  total_amount: string;
  notes?: string;
  payload: Payload;
  good_snapshot: Goodsnapshot;
  good: GoodSummary;
}
interface GoodSummary {
  name: string;
  barcode?: string;
  image_url?: string;
  category: Category;
}

interface Category {
  id: string;
  name: string;
  description?: string;
  image_url?: string;
  is_default_guild_good: boolean;
  guild_id: string;
  created_at: string;
  updated_at: string;
}

interface Goodsnapshot {
  good: Good;
}

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

interface MeasureUnit {
  id: string;
  code: string;
  name: string;
}

interface Sku {
  id: string;
  VAT: string;
  code: string;
  name: string;
}

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

interface Payment {
  amount: string;
  payment_method: string;
}

interface Customer {
  id: string;
  type: string;
  legal?: CustomerLegal;
  individual?: CustomerIndividual;
}

interface CustomerIndividual {
  first_name: string;
  last_name: string;
  national_id: string;
  postal_code: string;
  economic_code: string;
}

interface CustomerLegal {
  company_name: string;
  registration_number: string;
  postal_code: string;
  economic_code: string;
}

interface Pos extends ISummary {
  complex: Complex;
}

interface Complex extends ISummary {
  business_activity: ISummary;
}

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

interface UnknownCustomer {
  name?: string;
  national_code?: string;
}
