export type Json =
  | string
  | number
  | boolean
  | null
  | { [key: string]: Json | undefined }
  | Json[]

export type Database = {
  // Allows to automatically instantiate createClient with right options
  // instead of createClient<Database, { PostgrestVersion: 'XX' }>(URL, KEY)
  __InternalSupabase: {
    PostgrestVersion: "14.5"
  }
  public: {
    Tables: {
      activity_log: {
        Row: {
          action: string
          created_at: string
          details: Json | null
          entity_id: string
          entity_type: string
          id: string
          ip_address: string | null
          user_id: string
        }
        Insert: {
          action: string
          created_at?: string
          details?: Json | null
          entity_id?: string
          entity_type?: string
          id?: string
          ip_address?: string | null
          user_id: string
        }
        Update: {
          action?: string
          created_at?: string
          details?: Json | null
          entity_id?: string
          entity_type?: string
          id?: string
          ip_address?: string | null
          user_id?: string
        }
        Relationships: []
      }
      app_update_banners: {
        Row: {
          auto_hide_seconds: number | null
          bg_color: string
          created_at: string
          force_update: boolean
          id: string
          image_url: string | null
          is_active: boolean
          link_label: string | null
          link_label_bn: string | null
          link_url: string | null
          message: string
          message_bn: string
          text_color: string
          title: string
          title_bn: string
          updated_at: string
          version: string
        }
        Insert: {
          auto_hide_seconds?: number | null
          bg_color?: string
          created_at?: string
          force_update?: boolean
          id?: string
          image_url?: string | null
          is_active?: boolean
          link_label?: string | null
          link_label_bn?: string | null
          link_url?: string | null
          message?: string
          message_bn?: string
          text_color?: string
          title?: string
          title_bn?: string
          updated_at?: string
          version: string
        }
        Update: {
          auto_hide_seconds?: number | null
          bg_color?: string
          created_at?: string
          force_update?: boolean
          id?: string
          image_url?: string | null
          is_active?: boolean
          link_label?: string | null
          link_label_bn?: string | null
          link_url?: string | null
          message?: string
          message_bn?: string
          text_color?: string
          title?: string
          title_bn?: string
          updated_at?: string
          version?: string
        }
        Relationships: []
      }
      backups: {
        Row: {
          created_at: string
          created_by: string | null
          error_message: string | null
          file_name: string
          id: string
          size_bytes: number
          status: string
          tables_included: Json | null
          type: string
        }
        Insert: {
          created_at?: string
          created_by?: string | null
          error_message?: string | null
          file_name?: string
          id?: string
          size_bytes?: number
          status?: string
          tables_included?: Json | null
          type?: string
        }
        Update: {
          created_at?: string
          created_by?: string | null
          error_message?: string | null
          file_name?: string
          id?: string
          size_bytes?: number
          status?: string
          tables_included?: Json | null
          type?: string
        }
        Relationships: []
      }
      branches: {
        Row: {
          address: string | null
          code: string | null
          created_at: string
          deleted_at: string | null
          email: string | null
          id: string
          manager_name: string | null
          mobile: string | null
          name: string
          status: string
          updated_at: string
        }
        Insert: {
          address?: string | null
          code?: string | null
          created_at?: string
          deleted_at?: string | null
          email?: string | null
          id?: string
          manager_name?: string | null
          mobile?: string | null
          name: string
          status?: string
          updated_at?: string
        }
        Update: {
          address?: string | null
          code?: string | null
          created_at?: string
          deleted_at?: string | null
          email?: string | null
          id?: string
          manager_name?: string | null
          mobile?: string | null
          name?: string
          status?: string
          updated_at?: string
        }
        Relationships: []
      }
      brands: {
        Row: {
          created_at: string
          deleted_at: string | null
          description: string | null
          id: string
          logo: string | null
          name: string
          status: string
          updated_at: string
        }
        Insert: {
          created_at?: string
          deleted_at?: string | null
          description?: string | null
          id?: string
          logo?: string | null
          name: string
          status?: string
          updated_at?: string
        }
        Update: {
          created_at?: string
          deleted_at?: string | null
          description?: string | null
          id?: string
          logo?: string | null
          name?: string
          status?: string
          updated_at?: string
        }
        Relationships: []
      }
      business_settings: {
        Row: {
          id: string
          setting_key: string
          setting_value: string
          updated_at: string
          updated_by: string | null
        }
        Insert: {
          id?: string
          setting_key: string
          setting_value?: string
          updated_at?: string
          updated_by?: string | null
        }
        Update: {
          id?: string
          setting_key?: string
          setting_value?: string
          updated_at?: string
          updated_by?: string | null
        }
        Relationships: []
      }
      categories: {
        Row: {
          code: string | null
          created_at: string
          deleted_at: string | null
          id: string
          name: string
          name_bn: string
          status: string
          updated_at: string
        }
        Insert: {
          code?: string | null
          created_at?: string
          deleted_at?: string | null
          id?: string
          name: string
          name_bn: string
          status?: string
          updated_at?: string
        }
        Update: {
          code?: string | null
          created_at?: string
          deleted_at?: string | null
          id?: string
          name?: string
          name_bn?: string
          status?: string
          updated_at?: string
        }
        Relationships: []
      }
      commission_payout_schedule: {
        Row: {
          auto_enabled: boolean
          created_at: string
          day_of_month: number
          day_of_week: number
          frequency: string
          id: string
          last_run_at: string | null
          min_payout_amount: number
          next_run_at: string | null
          updated_at: string
          updated_by: string | null
        }
        Insert: {
          auto_enabled?: boolean
          created_at?: string
          day_of_month?: number
          day_of_week?: number
          frequency?: string
          id?: string
          last_run_at?: string | null
          min_payout_amount?: number
          next_run_at?: string | null
          updated_at?: string
          updated_by?: string | null
        }
        Update: {
          auto_enabled?: boolean
          created_at?: string
          day_of_month?: number
          day_of_week?: number
          frequency?: string
          id?: string
          last_run_at?: string | null
          min_payout_amount?: number
          next_run_at?: string | null
          updated_at?: string
          updated_by?: string | null
        }
        Relationships: []
      }
      commission_rules: {
        Row: {
          category_id: string | null
          commission_type: string
          commission_value: number
          created_at: string
          created_by: string | null
          ends_at: string | null
          id: string
          is_active: boolean
          level: number
          max_sale_amount: number | null
          min_sale_amount: number
          name: string
          note: string | null
          priority: number
          product_id: string | null
          starts_at: string | null
          updated_at: string
        }
        Insert: {
          category_id?: string | null
          commission_type?: string
          commission_value?: number
          created_at?: string
          created_by?: string | null
          ends_at?: string | null
          id?: string
          is_active?: boolean
          level?: number
          max_sale_amount?: number | null
          min_sale_amount?: number
          name: string
          note?: string | null
          priority?: number
          product_id?: string | null
          starts_at?: string | null
          updated_at?: string
        }
        Update: {
          category_id?: string | null
          commission_type?: string
          commission_value?: number
          created_at?: string
          created_by?: string | null
          ends_at?: string | null
          id?: string
          is_active?: boolean
          level?: number
          max_sale_amount?: number | null
          min_sale_amount?: number
          name?: string
          note?: string | null
          priority?: number
          product_id?: string | null
          starts_at?: string | null
          updated_at?: string
        }
        Relationships: []
      }
      commissions: {
        Row: {
          amount: number
          commission_rate: number
          commission_type: string
          created_at: string
          customer_id: string
          id: string
          referred_customer_id: string
          sale_id: string
          status: string
          updated_at: string
        }
        Insert: {
          amount?: number
          commission_rate?: number
          commission_type?: string
          created_at?: string
          customer_id: string
          id?: string
          referred_customer_id: string
          sale_id?: string
          status?: string
          updated_at?: string
        }
        Update: {
          amount?: number
          commission_rate?: number
          commission_type?: string
          created_at?: string
          customer_id?: string
          id?: string
          referred_customer_id?: string
          sale_id?: string
          status?: string
          updated_at?: string
        }
        Relationships: []
      }
      custom_roles: {
        Row: {
          created_at: string
          description: string | null
          id: string
          name: string
          status: string
          updated_at: string
        }
        Insert: {
          created_at?: string
          description?: string | null
          id?: string
          name: string
          status?: string
          updated_at?: string
        }
        Update: {
          created_at?: string
          description?: string | null
          id?: string
          name?: string
          status?: string
          updated_at?: string
        }
        Relationships: []
      }
      customer_due_adjustments: {
        Row: {
          amount: number
          created_at: string
          created_by: string | null
          customer_id: string
          id: string
          invoice_id: string | null
          note: string | null
        }
        Insert: {
          amount?: number
          created_at?: string
          created_by?: string | null
          customer_id: string
          id?: string
          invoice_id?: string | null
          note?: string | null
        }
        Update: {
          amount?: number
          created_at?: string
          created_by?: string | null
          customer_id?: string
          id?: string
          invoice_id?: string | null
          note?: string | null
        }
        Relationships: []
      }
      customer_segment_logs: {
        Row: {
          changed_by: string | null
          created_at: string
          customer_id: string
          id: string
          new_segment: string
          old_segment: string | null
          reason: string
          updated_at: string
        }
        Insert: {
          changed_by?: string | null
          created_at?: string
          customer_id: string
          id?: string
          new_segment: string
          old_segment?: string | null
          reason?: string
          updated_at?: string
        }
        Update: {
          changed_by?: string | null
          created_at?: string
          customer_id?: string
          id?: string
          new_segment?: string
          old_segment?: string | null
          reason?: string
          updated_at?: string
        }
        Relationships: []
      }
      customer_transactions: {
        Row: {
          amount: number
          branch_id: string | null
          created_at: string
          customer_id: string
          id: string
          method: string
          note: string | null
          reference_id: string | null
          type: string
        }
        Insert: {
          amount?: number
          branch_id?: string | null
          created_at?: string
          customer_id: string
          id?: string
          method?: string
          note?: string | null
          reference_id?: string | null
          type?: string
        }
        Update: {
          amount?: number
          branch_id?: string | null
          created_at?: string
          customer_id?: string
          id?: string
          method?: string
          note?: string | null
          reference_id?: string | null
          type?: string
        }
        Relationships: [
          {
            foreignKeyName: "customer_transactions_customer_id_fkey"
            columns: ["customer_id"]
            isOneToOne: false
            referencedRelation: "customers"
            referencedColumns: ["id"]
          },
        ]
      }
      customers: {
        Row: {
          address: string | null
          created_at: string
          current_balance: number
          customer_type: string
          deleted_at: string | null
          email: string | null
          id: string
          image_url: string | null
          mobile: string
          name: string
          name_bn: string
          opening_balance: number
          portal_enabled: boolean
          portal_last_login_at: string | null
          portal_password_hash: string | null
          reference_customer_id: string | null
          reference_mobile: string | null
          status: string
          total_due: number
          updated_at: string
        }
        Insert: {
          address?: string | null
          created_at?: string
          current_balance?: number
          customer_type?: string
          deleted_at?: string | null
          email?: string | null
          id?: string
          image_url?: string | null
          mobile: string
          name: string
          name_bn?: string
          opening_balance?: number
          portal_enabled?: boolean
          portal_last_login_at?: string | null
          portal_password_hash?: string | null
          reference_customer_id?: string | null
          reference_mobile?: string | null
          status?: string
          total_due?: number
          updated_at?: string
        }
        Update: {
          address?: string | null
          created_at?: string
          current_balance?: number
          customer_type?: string
          deleted_at?: string | null
          email?: string | null
          id?: string
          image_url?: string | null
          mobile?: string
          name?: string
          name_bn?: string
          opening_balance?: number
          portal_enabled?: boolean
          portal_last_login_at?: string | null
          portal_password_hash?: string | null
          reference_customer_id?: string | null
          reference_mobile?: string | null
          status?: string
          total_due?: number
          updated_at?: string
        }
        Relationships: []
      }
      daily_cash_closings: {
        Row: {
          bank_deposit: number
          branch_id: string | null
          cash_sales: number
          cashier_id: string | null
          closed_at: string | null
          closed_by: string | null
          closing_cash: number
          closing_date: string
          created_at: string
          difference: number
          due_collection: number
          expected_cash: number
          expense_amount: number
          id: string
          is_locked: boolean
          note: string
          opening_cash: number
          reopened_at: string | null
          reopened_by: string | null
          shift: string
          supplier_payment: number
          total_sales: number
          updated_at: string
          withdraw_amount: number
        }
        Insert: {
          bank_deposit?: number
          branch_id?: string | null
          cash_sales?: number
          cashier_id?: string | null
          closed_at?: string | null
          closed_by?: string | null
          closing_cash?: number
          closing_date?: string
          created_at?: string
          difference?: number
          due_collection?: number
          expected_cash?: number
          expense_amount?: number
          id?: string
          is_locked?: boolean
          note?: string
          opening_cash?: number
          reopened_at?: string | null
          reopened_by?: string | null
          shift?: string
          supplier_payment?: number
          total_sales?: number
          updated_at?: string
          withdraw_amount?: number
        }
        Update: {
          bank_deposit?: number
          branch_id?: string | null
          cash_sales?: number
          cashier_id?: string | null
          closed_at?: string | null
          closed_by?: string | null
          closing_cash?: number
          closing_date?: string
          created_at?: string
          difference?: number
          due_collection?: number
          expected_cash?: number
          expense_amount?: number
          id?: string
          is_locked?: boolean
          note?: string
          opening_cash?: number
          reopened_at?: string | null
          reopened_by?: string | null
          shift?: string
          supplier_payment?: number
          total_sales?: number
          updated_at?: string
          withdraw_amount?: number
        }
        Relationships: []
      }
      damage_stock: {
        Row: {
          created_at: string
          id: string
          note: string | null
          product_id: string
          quantity: number
          reference_id: string | null
          source: string
        }
        Insert: {
          created_at?: string
          id?: string
          note?: string | null
          product_id: string
          quantity?: number
          reference_id?: string | null
          source?: string
        }
        Update: {
          created_at?: string
          id?: string
          note?: string | null
          product_id?: string
          quantity?: number
          reference_id?: string | null
          source?: string
        }
        Relationships: [
          {
            foreignKeyName: "damage_stock_product_id_fkey"
            columns: ["product_id"]
            isOneToOne: false
            referencedRelation: "products"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "damage_stock_product_id_fkey"
            columns: ["product_id"]
            isOneToOne: false
            referencedRelation: "products_cost"
            referencedColumns: ["id"]
          },
        ]
      }
      departments: {
        Row: {
          created_at: string
          deleted_at: string | null
          description: string
          id: string
          name: string
          name_bn: string
          status: string
          updated_at: string
        }
        Insert: {
          created_at?: string
          deleted_at?: string | null
          description?: string
          id?: string
          name: string
          name_bn?: string
          status?: string
          updated_at?: string
        }
        Update: {
          created_at?: string
          deleted_at?: string | null
          description?: string
          id?: string
          name?: string
          name_bn?: string
          status?: string
          updated_at?: string
        }
        Relationships: []
      }
      expenses: {
        Row: {
          amount: number
          branch_id: string | null
          category: string
          category_id: string | null
          created_at: string
          created_by: string | null
          expense_date: string
          id: string
          note: string | null
          payment_method: string
          updated_at: string
        }
        Insert: {
          amount?: number
          branch_id?: string | null
          category?: string
          category_id?: string | null
          created_at?: string
          created_by?: string | null
          expense_date?: string
          id?: string
          note?: string | null
          payment_method?: string
          updated_at?: string
        }
        Update: {
          amount?: number
          branch_id?: string | null
          category?: string
          category_id?: string | null
          created_at?: string
          created_by?: string | null
          expense_date?: string
          id?: string
          note?: string | null
          payment_method?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "expenses_category_id_fkey"
            columns: ["category_id"]
            isOneToOne: false
            referencedRelation: "transaction_categories"
            referencedColumns: ["id"]
          },
        ]
      }
      godown_stocks: {
        Row: {
          godown_id: string
          id: string
          product_id: string
          quantity: number
          updated_at: string
        }
        Insert: {
          godown_id: string
          id?: string
          product_id: string
          quantity?: number
          updated_at?: string
        }
        Update: {
          godown_id?: string
          id?: string
          product_id?: string
          quantity?: number
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "godown_stocks_godown_id_fkey"
            columns: ["godown_id"]
            isOneToOne: false
            referencedRelation: "godowns"
            referencedColumns: ["id"]
          },
        ]
      }
      godowns: {
        Row: {
          address: string | null
          branch_id: string | null
          code: string | null
          created_at: string
          id: string
          manager_name: string | null
          mobile: string | null
          name: string
          status: string
          updated_at: string
        }
        Insert: {
          address?: string | null
          branch_id?: string | null
          code?: string | null
          created_at?: string
          id?: string
          manager_name?: string | null
          mobile?: string | null
          name: string
          status?: string
          updated_at?: string
        }
        Update: {
          address?: string | null
          branch_id?: string | null
          code?: string | null
          created_at?: string
          id?: string
          manager_name?: string | null
          mobile?: string | null
          name?: string
          status?: string
          updated_at?: string
        }
        Relationships: []
      }
      incomes: {
        Row: {
          amount: number
          branch_id: string | null
          category_id: string | null
          created_at: string
          created_by: string | null
          id: string
          income_date: string
          note: string | null
          payment_method: string
          source: string
          updated_at: string
        }
        Insert: {
          amount?: number
          branch_id?: string | null
          category_id?: string | null
          created_at?: string
          created_by?: string | null
          id?: string
          income_date?: string
          note?: string | null
          payment_method?: string
          source?: string
          updated_at?: string
        }
        Update: {
          amount?: number
          branch_id?: string | null
          category_id?: string | null
          created_at?: string
          created_by?: string | null
          id?: string
          income_date?: string
          note?: string | null
          payment_method?: string
          source?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "incomes_category_id_fkey"
            columns: ["category_id"]
            isOneToOne: false
            referencedRelation: "transaction_categories"
            referencedColumns: ["id"]
          },
        ]
      }
      pending_referrals: {
        Row: {
          created_at: string
          id: string
          matched_at: string | null
          matched_customer_id: string | null
          mobile: string
          note: string | null
          referrer_id: string
          status: string
        }
        Insert: {
          created_at?: string
          id?: string
          matched_at?: string | null
          matched_customer_id?: string | null
          mobile: string
          note?: string | null
          referrer_id: string
          status?: string
        }
        Update: {
          created_at?: string
          id?: string
          matched_at?: string | null
          matched_customer_id?: string | null
          mobile?: string
          note?: string | null
          referrer_id?: string
          status?: string
        }
        Relationships: [
          {
            foreignKeyName: "pending_referrals_matched_customer_id_fkey"
            columns: ["matched_customer_id"]
            isOneToOne: false
            referencedRelation: "customers"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "pending_referrals_referrer_id_fkey"
            columns: ["referrer_id"]
            isOneToOne: false
            referencedRelation: "customers"
            referencedColumns: ["id"]
          },
        ]
      }
      permissions: {
        Row: {
          created_at: string
          description: string | null
          id: string
          module: string
          name: string
        }
        Insert: {
          created_at?: string
          description?: string | null
          id?: string
          module: string
          name: string
        }
        Update: {
          created_at?: string
          description?: string | null
          id?: string
          module?: string
          name?: string
        }
        Relationships: []
      }
      product_prices: {
        Row: {
          created_at: string
          id: string
          is_active: boolean
          label: string | null
          min_qty: number
          price: number
          price_type: string
          product_id: string
          updated_at: string
        }
        Insert: {
          created_at?: string
          id?: string
          is_active?: boolean
          label?: string | null
          min_qty?: number
          price?: number
          price_type?: string
          product_id: string
          updated_at?: string
        }
        Update: {
          created_at?: string
          id?: string
          is_active?: boolean
          label?: string | null
          min_qty?: number
          price?: number
          price_type?: string
          product_id?: string
          updated_at?: string
        }
        Relationships: []
      }
      product_pricing: {
        Row: {
          barcode: string | null
          conversion_factor: number
          created_at: string
          id: string
          is_active: boolean
          is_base_unit: boolean
          min_qty: number
          offer_end: string | null
          offer_percent: number | null
          offer_price: number | null
          offer_start: string | null
          price_type: string
          product_id: string
          purchase_price: number
          regular_price: number
          unit_name: string
          unit_name_bn: string
          updated_at: string
        }
        Insert: {
          barcode?: string | null
          conversion_factor?: number
          created_at?: string
          id?: string
          is_active?: boolean
          is_base_unit?: boolean
          min_qty?: number
          offer_end?: string | null
          offer_percent?: number | null
          offer_price?: number | null
          offer_start?: string | null
          price_type?: string
          product_id: string
          purchase_price?: number
          regular_price?: number
          unit_name?: string
          unit_name_bn?: string
          updated_at?: string
        }
        Update: {
          barcode?: string | null
          conversion_factor?: number
          created_at?: string
          id?: string
          is_active?: boolean
          is_base_unit?: boolean
          min_qty?: number
          offer_end?: string | null
          offer_percent?: number | null
          offer_price?: number | null
          offer_start?: string | null
          price_type?: string
          product_id?: string
          purchase_price?: number
          regular_price?: number
          unit_name?: string
          unit_name_bn?: string
          updated_at?: string
        }
        Relationships: []
      }
      product_types: {
        Row: {
          created_at: string
          deleted_at: string | null
          icon: string
          id: string
          name: string
          name_bn: string
          status: string
          updated_at: string
        }
        Insert: {
          created_at?: string
          deleted_at?: string | null
          icon?: string
          id?: string
          name: string
          name_bn?: string
          status?: string
          updated_at?: string
        }
        Update: {
          created_at?: string
          deleted_at?: string | null
          icon?: string
          id?: string
          name?: string
          name_bn?: string
          status?: string
          updated_at?: string
        }
        Relationships: []
      }
      product_units: {
        Row: {
          barcode: string | null
          conversion_factor: number
          created_at: string
          id: string
          is_active: boolean
          price: number
          product_id: string
          purchase_price: number
          retail_price: number
          unit_name: string
          unit_name_bn: string
          updated_at: string
          wholesale_price: number
        }
        Insert: {
          barcode?: string | null
          conversion_factor?: number
          created_at?: string
          id?: string
          is_active?: boolean
          price?: number
          product_id: string
          purchase_price?: number
          retail_price?: number
          unit_name?: string
          unit_name_bn?: string
          updated_at?: string
          wholesale_price?: number
        }
        Update: {
          barcode?: string | null
          conversion_factor?: number
          created_at?: string
          id?: string
          is_active?: boolean
          price?: number
          product_id?: string
          purchase_price?: number
          retail_price?: number
          unit_name?: string
          unit_name_bn?: string
          updated_at?: string
          wholesale_price?: number
        }
        Relationships: []
      }
      products: {
        Row: {
          barcode: string | null
          branch_id: string | null
          brand_id: string | null
          category_id: string | null
          created_at: string
          created_by: string | null
          godown_id: string | null
          id: string
          image_url: string | null
          is_deleted: boolean
          name: string
          name_bn: string
          product_type: string
          product_type_id: string | null
          purchase_price: number
          retail_price: number
          sku: string
          stock_quantity: number
          subcategory_id: string | null
          unit: string
          updated_at: string
          wholesale_price: number
        }
        Insert: {
          barcode?: string | null
          branch_id?: string | null
          brand_id?: string | null
          category_id?: string | null
          created_at?: string
          created_by?: string | null
          godown_id?: string | null
          id?: string
          image_url?: string | null
          is_deleted?: boolean
          name: string
          name_bn?: string
          product_type?: string
          product_type_id?: string | null
          purchase_price?: number
          retail_price?: number
          sku: string
          stock_quantity?: number
          subcategory_id?: string | null
          unit?: string
          updated_at?: string
          wholesale_price?: number
        }
        Update: {
          barcode?: string | null
          branch_id?: string | null
          brand_id?: string | null
          category_id?: string | null
          created_at?: string
          created_by?: string | null
          godown_id?: string | null
          id?: string
          image_url?: string | null
          is_deleted?: boolean
          name?: string
          name_bn?: string
          product_type?: string
          product_type_id?: string | null
          purchase_price?: number
          retail_price?: number
          sku?: string
          stock_quantity?: number
          subcategory_id?: string | null
          unit?: string
          updated_at?: string
          wholesale_price?: number
        }
        Relationships: [
          {
            foreignKeyName: "products_branch_id_fkey"
            columns: ["branch_id"]
            isOneToOne: false
            referencedRelation: "branches"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "products_brand_id_fkey"
            columns: ["brand_id"]
            isOneToOne: false
            referencedRelation: "brands"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "products_category_id_fkey"
            columns: ["category_id"]
            isOneToOne: false
            referencedRelation: "categories"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "products_product_type_id_fkey"
            columns: ["product_type_id"]
            isOneToOne: false
            referencedRelation: "product_types"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "products_subcategory_id_fkey"
            columns: ["subcategory_id"]
            isOneToOne: false
            referencedRelation: "subcategories"
            referencedColumns: ["id"]
          },
        ]
      }
      profiles: {
        Row: {
          branch_id: string | null
          created_at: string
          custom_role_id: string | null
          full_name: string | null
          id: string
          last_login: string | null
          mobile: string | null
          role: string | null
          status: string
          updated_at: string
          username: string | null
        }
        Insert: {
          branch_id?: string | null
          created_at?: string
          custom_role_id?: string | null
          full_name?: string | null
          id: string
          last_login?: string | null
          mobile?: string | null
          role?: string | null
          status?: string
          updated_at?: string
          username?: string | null
        }
        Update: {
          branch_id?: string | null
          created_at?: string
          custom_role_id?: string | null
          full_name?: string | null
          id?: string
          last_login?: string | null
          mobile?: string | null
          role?: string | null
          status?: string
          updated_at?: string
          username?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "profiles_branch_id_fkey"
            columns: ["branch_id"]
            isOneToOne: false
            referencedRelation: "branches"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "profiles_custom_role_id_fkey"
            columns: ["custom_role_id"]
            isOneToOne: false
            referencedRelation: "custom_roles"
            referencedColumns: ["id"]
          },
        ]
      }
      purchase_items: {
        Row: {
          created_at: string
          id: string
          product_id: string
          purchase_id: string
          purchase_price: number
          quantity: number
          total: number
        }
        Insert: {
          created_at?: string
          id?: string
          product_id: string
          purchase_id: string
          purchase_price?: number
          quantity?: number
          total?: number
        }
        Update: {
          created_at?: string
          id?: string
          product_id?: string
          purchase_id?: string
          purchase_price?: number
          quantity?: number
          total?: number
        }
        Relationships: [
          {
            foreignKeyName: "purchase_items_purchase_id_fkey"
            columns: ["purchase_id"]
            isOneToOne: false
            referencedRelation: "purchases"
            referencedColumns: ["id"]
          },
        ]
      }
      purchases: {
        Row: {
          created_at: string
          created_by: string | null
          discount: number
          due_amount: number
          id: string
          invoice_no: string
          labor_cost: number
          note: string | null
          paid_amount: number
          payment_method: string
          purchase_date: string
          status: string
          supplier_id: string
          total_amount: number
          transport_cost: number
          updated_at: string
        }
        Insert: {
          created_at?: string
          created_by?: string | null
          discount?: number
          due_amount?: number
          id?: string
          invoice_no?: string
          labor_cost?: number
          note?: string | null
          paid_amount?: number
          payment_method?: string
          purchase_date?: string
          status?: string
          supplier_id: string
          total_amount?: number
          transport_cost?: number
          updated_at?: string
        }
        Update: {
          created_at?: string
          created_by?: string | null
          discount?: number
          due_amount?: number
          id?: string
          invoice_no?: string
          labor_cost?: number
          note?: string | null
          paid_amount?: number
          payment_method?: string
          purchase_date?: string
          status?: string
          supplier_id?: string
          total_amount?: number
          transport_cost?: number
          updated_at?: string
        }
        Relationships: []
      }
      quotation_items: {
        Row: {
          created_at: string
          id: string
          image_url: string | null
          line_total: number
          product_id: string
          product_name: string
          product_name_bn: string
          quantity: number
          quotation_id: string
          unit: string
          unit_price: number
        }
        Insert: {
          created_at?: string
          id?: string
          image_url?: string | null
          line_total?: number
          product_id: string
          product_name?: string
          product_name_bn?: string
          quantity?: number
          quotation_id: string
          unit?: string
          unit_price?: number
        }
        Update: {
          created_at?: string
          id?: string
          image_url?: string | null
          line_total?: number
          product_id?: string
          product_name?: string
          product_name_bn?: string
          quantity?: number
          quotation_id?: string
          unit?: string
          unit_price?: number
        }
        Relationships: [
          {
            foreignKeyName: "quotation_items_quotation_id_fkey"
            columns: ["quotation_id"]
            isOneToOne: false
            referencedRelation: "quotations"
            referencedColumns: ["id"]
          },
        ]
      }
      quotations: {
        Row: {
          created_at: string
          customer_id: string
          for_self: boolean
          id: string
          notes: string | null
          quote_no: string | null
          referral_customer_id: string | null
          referral_mobile: string | null
          referral_name: string | null
          reviewed_at: string | null
          reviewed_by: string | null
          status: string
          total_amount: number
          updated_at: string
        }
        Insert: {
          created_at?: string
          customer_id: string
          for_self?: boolean
          id?: string
          notes?: string | null
          quote_no?: string | null
          referral_customer_id?: string | null
          referral_mobile?: string | null
          referral_name?: string | null
          reviewed_at?: string | null
          reviewed_by?: string | null
          status?: string
          total_amount?: number
          updated_at?: string
        }
        Update: {
          created_at?: string
          customer_id?: string
          for_self?: boolean
          id?: string
          notes?: string | null
          quote_no?: string | null
          referral_customer_id?: string | null
          referral_mobile?: string | null
          referral_name?: string | null
          reviewed_at?: string | null
          reviewed_by?: string | null
          status?: string
          total_amount?: number
          updated_at?: string
        }
        Relationships: []
      }
      referral_wallets: {
        Row: {
          adjusted_amount: number
          balance: number
          created_at: string
          customer_id: string
          id: string
          paid_amount: number
          pending_balance: number
          total_commission: number
          updated_at: string
        }
        Insert: {
          adjusted_amount?: number
          balance?: number
          created_at?: string
          customer_id: string
          id?: string
          paid_amount?: number
          pending_balance?: number
          total_commission?: number
          updated_at?: string
        }
        Update: {
          adjusted_amount?: number
          balance?: number
          created_at?: string
          customer_id?: string
          id?: string
          paid_amount?: number
          pending_balance?: number
          total_commission?: number
          updated_at?: string
        }
        Relationships: []
      }
      refunds: {
        Row: {
          amount: number
          created_at: string
          customer_id: string
          id: string
          note: string | null
          payment_method: string
          processed_by: string | null
          return_id: string | null
          status: string
        }
        Insert: {
          amount?: number
          created_at?: string
          customer_id: string
          id?: string
          note?: string | null
          payment_method?: string
          processed_by?: string | null
          return_id?: string | null
          status?: string
        }
        Update: {
          amount?: number
          created_at?: string
          customer_id?: string
          id?: string
          note?: string | null
          payment_method?: string
          processed_by?: string | null
          return_id?: string | null
          status?: string
        }
        Relationships: [
          {
            foreignKeyName: "refunds_customer_id_fkey"
            columns: ["customer_id"]
            isOneToOne: false
            referencedRelation: "customers"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "refunds_return_id_fkey"
            columns: ["return_id"]
            isOneToOne: false
            referencedRelation: "sales_returns"
            referencedColumns: ["id"]
          },
        ]
      }
      role_permissions: {
        Row: {
          created_at: string
          id: string
          permission_id: string
          role_id: string
        }
        Insert: {
          created_at?: string
          id?: string
          permission_id: string
          role_id: string
        }
        Update: {
          created_at?: string
          id?: string
          permission_id?: string
          role_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "role_permissions_permission_id_fkey"
            columns: ["permission_id"]
            isOneToOne: false
            referencedRelation: "permissions"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "role_permissions_role_id_fkey"
            columns: ["role_id"]
            isOneToOne: false
            referencedRelation: "custom_roles"
            referencedColumns: ["id"]
          },
        ]
      }
      sale_edit_logs: {
        Row: {
          changed_fields: string[]
          created_at: string
          edited_by: string | null
          id: string
          new_data: Json
          old_data: Json
          sale_id: string
        }
        Insert: {
          changed_fields?: string[]
          created_at?: string
          edited_by?: string | null
          id?: string
          new_data?: Json
          old_data?: Json
          sale_id: string
        }
        Update: {
          changed_fields?: string[]
          created_at?: string
          edited_by?: string | null
          id?: string
          new_data?: Json
          old_data?: Json
          sale_id?: string
        }
        Relationships: []
      }
      sale_items: {
        Row: {
          barcode: string
          created_at: string
          id: string
          name: string
          name_bn: string
          product_id: string | null
          quantity: number
          sale_id: string
          total: number
          unit: string
          unit_discount: number
          unit_price: number
        }
        Insert: {
          barcode?: string
          created_at?: string
          id?: string
          name?: string
          name_bn?: string
          product_id?: string | null
          quantity?: number
          sale_id: string
          total?: number
          unit?: string
          unit_discount?: number
          unit_price?: number
        }
        Update: {
          barcode?: string
          created_at?: string
          id?: string
          name?: string
          name_bn?: string
          product_id?: string | null
          quantity?: number
          sale_id?: string
          total?: number
          unit?: string
          unit_discount?: number
          unit_price?: number
        }
        Relationships: [
          {
            foreignKeyName: "sale_items_product_id_fkey"
            columns: ["product_id"]
            isOneToOne: false
            referencedRelation: "products"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "sale_items_product_id_fkey"
            columns: ["product_id"]
            isOneToOne: false
            referencedRelation: "products_cost"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "sale_items_sale_id_fkey"
            columns: ["sale_id"]
            isOneToOne: false
            referencedRelation: "sales"
            referencedColumns: ["id"]
          },
        ]
      }
      sale_status_logs: {
        Row: {
          change_type: string
          changed_by: string | null
          created_at: string
          id: string
          new_value: string | null
          note: string | null
          old_value: string | null
          sale_id: string
        }
        Insert: {
          change_type?: string
          changed_by?: string | null
          created_at?: string
          id?: string
          new_value?: string | null
          note?: string | null
          old_value?: string | null
          sale_id: string
        }
        Update: {
          change_type?: string
          changed_by?: string | null
          created_at?: string
          id?: string
          new_value?: string | null
          note?: string | null
          old_value?: string | null
          sale_id?: string
        }
        Relationships: []
      }
      sale_status_transitions: {
        Row: {
          allowed_to: string[]
          from_status: string
          updated_at: string
          updated_by: string | null
        }
        Insert: {
          allowed_to?: string[]
          from_status: string
          updated_at?: string
          updated_by?: string | null
        }
        Update: {
          allowed_to?: string[]
          from_status?: string
          updated_at?: string
          updated_by?: string | null
        }
        Relationships: []
      }
      sales: {
        Row: {
          branch_id: string | null
          completed_at: string | null
          created_at: string
          created_by: string | null
          customer_address: string
          customer_id: string | null
          customer_mobile: string
          customer_name: string
          delivery_status: string
          discount: number
          due_amount: number
          edit_count: number
          edited_at: string | null
          edited_by: string | null
          expense: number
          id: string
          invoice_no: string
          is_edited: boolean
          note: string
          paid_amount: number
          payment_method: string
          sale_date: string
          sale_man: string
          sale_status: string
          subtotal: number
          total_amount: number
          updated_at: string
        }
        Insert: {
          branch_id?: string | null
          completed_at?: string | null
          created_at?: string
          created_by?: string | null
          customer_address?: string
          customer_id?: string | null
          customer_mobile?: string
          customer_name?: string
          delivery_status?: string
          discount?: number
          due_amount?: number
          edit_count?: number
          edited_at?: string | null
          edited_by?: string | null
          expense?: number
          id?: string
          invoice_no: string
          is_edited?: boolean
          note?: string
          paid_amount?: number
          payment_method?: string
          sale_date?: string
          sale_man?: string
          sale_status?: string
          subtotal?: number
          total_amount?: number
          updated_at?: string
        }
        Update: {
          branch_id?: string | null
          completed_at?: string | null
          created_at?: string
          created_by?: string | null
          customer_address?: string
          customer_id?: string | null
          customer_mobile?: string
          customer_name?: string
          delivery_status?: string
          discount?: number
          due_amount?: number
          edit_count?: number
          edited_at?: string | null
          edited_by?: string | null
          expense?: number
          id?: string
          invoice_no?: string
          is_edited?: boolean
          note?: string
          paid_amount?: number
          payment_method?: string
          sale_date?: string
          sale_man?: string
          sale_status?: string
          subtotal?: number
          total_amount?: number
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "sales_branch_id_fkey"
            columns: ["branch_id"]
            isOneToOne: false
            referencedRelation: "branches"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "sales_customer_id_fkey"
            columns: ["customer_id"]
            isOneToOne: false
            referencedRelation: "customers"
            referencedColumns: ["id"]
          },
        ]
      }
      sales_order_deliveries: {
        Row: {
          created_at: string
          delivered_at: string
          delivered_by: string | null
          delivered_qty: number
          id: string
          note: string | null
          sales_order_id: string
          sales_order_item_id: string
        }
        Insert: {
          created_at?: string
          delivered_at?: string
          delivered_by?: string | null
          delivered_qty?: number
          id?: string
          note?: string | null
          sales_order_id: string
          sales_order_item_id: string
        }
        Update: {
          created_at?: string
          delivered_at?: string
          delivered_by?: string | null
          delivered_qty?: number
          id?: string
          note?: string | null
          sales_order_id?: string
          sales_order_item_id?: string
        }
        Relationships: []
      }
      sales_order_items: {
        Row: {
          created_at: string
          id: string
          price: number
          product_id: string
          quantity: number
          sales_order_id: string
          total: number
        }
        Insert: {
          created_at?: string
          id?: string
          price?: number
          product_id: string
          quantity?: number
          sales_order_id: string
          total?: number
        }
        Update: {
          created_at?: string
          id?: string
          price?: number
          product_id?: string
          quantity?: number
          sales_order_id?: string
          total?: number
        }
        Relationships: [
          {
            foreignKeyName: "sales_order_items_sales_order_id_fkey"
            columns: ["sales_order_id"]
            isOneToOne: false
            referencedRelation: "sales_orders"
            referencedColumns: ["id"]
          },
        ]
      }
      sales_order_status_log: {
        Row: {
          change_type: string
          changed_by: string | null
          created_at: string
          id: string
          new_value: string | null
          note: string | null
          old_value: string | null
          sales_order_id: string
        }
        Insert: {
          change_type: string
          changed_by?: string | null
          created_at?: string
          id?: string
          new_value?: string | null
          note?: string | null
          old_value?: string | null
          sales_order_id: string
        }
        Update: {
          change_type?: string
          changed_by?: string | null
          created_at?: string
          id?: string
          new_value?: string | null
          note?: string | null
          old_value?: string | null
          sales_order_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "sales_order_status_log_sales_order_id_fkey"
            columns: ["sales_order_id"]
            isOneToOne: false
            referencedRelation: "sales_orders"
            referencedColumns: ["id"]
          },
        ]
      }
      sales_orders: {
        Row: {
          approved_at: string | null
          approved_by: string | null
          bill_status: string
          branch_id: string | null
          cancelled_at: string | null
          cancelled_reason: string | null
          created_at: string
          created_by: string | null
          customer_id: string | null
          delivered_at: string | null
          delivery_date: string | null
          delivery_notes: string | null
          discount: number
          due_amount: number
          id: string
          note: string | null
          order_date: string
          order_no: string
          paid_amount: number
          payment_method: string
          payment_status: string
          sale_status: string
          status: string
          stock_deducted: boolean
          total_amount: number
          updated_at: string
        }
        Insert: {
          approved_at?: string | null
          approved_by?: string | null
          bill_status?: string
          branch_id?: string | null
          cancelled_at?: string | null
          cancelled_reason?: string | null
          created_at?: string
          created_by?: string | null
          customer_id?: string | null
          delivered_at?: string | null
          delivery_date?: string | null
          delivery_notes?: string | null
          discount?: number
          due_amount?: number
          id?: string
          note?: string | null
          order_date?: string
          order_no?: string
          paid_amount?: number
          payment_method?: string
          payment_status?: string
          sale_status?: string
          status?: string
          stock_deducted?: boolean
          total_amount?: number
          updated_at?: string
        }
        Update: {
          approved_at?: string | null
          approved_by?: string | null
          bill_status?: string
          branch_id?: string | null
          cancelled_at?: string | null
          cancelled_reason?: string | null
          created_at?: string
          created_by?: string | null
          customer_id?: string | null
          delivered_at?: string | null
          delivery_date?: string | null
          delivery_notes?: string | null
          discount?: number
          due_amount?: number
          id?: string
          note?: string | null
          order_date?: string
          order_no?: string
          paid_amount?: number
          payment_method?: string
          payment_status?: string
          sale_status?: string
          status?: string
          stock_deducted?: boolean
          total_amount?: number
          updated_at?: string
        }
        Relationships: []
      }
      sales_returns: {
        Row: {
          created_at: string
          customer_id: string | null
          id: string
          invoice_id: string
          processed_by: string | null
          product_id: string
          quantity: number
          reason: string | null
          refund_amount: number
          replacement_product_id: string | null
          return_type: string
          status: string
          updated_at: string
        }
        Insert: {
          created_at?: string
          customer_id?: string | null
          id?: string
          invoice_id?: string
          processed_by?: string | null
          product_id: string
          quantity?: number
          reason?: string | null
          refund_amount?: number
          replacement_product_id?: string | null
          return_type?: string
          status?: string
          updated_at?: string
        }
        Update: {
          created_at?: string
          customer_id?: string | null
          id?: string
          invoice_id?: string
          processed_by?: string | null
          product_id?: string
          quantity?: number
          reason?: string | null
          refund_amount?: number
          replacement_product_id?: string | null
          return_type?: string
          status?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "sales_returns_customer_id_fkey"
            columns: ["customer_id"]
            isOneToOne: false
            referencedRelation: "customers"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "sales_returns_product_id_fkey"
            columns: ["product_id"]
            isOneToOne: false
            referencedRelation: "products"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "sales_returns_product_id_fkey"
            columns: ["product_id"]
            isOneToOne: false
            referencedRelation: "products_cost"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "sales_returns_replacement_product_id_fkey"
            columns: ["replacement_product_id"]
            isOneToOne: false
            referencedRelation: "products"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "sales_returns_replacement_product_id_fkey"
            columns: ["replacement_product_id"]
            isOneToOne: false
            referencedRelation: "products_cost"
            referencedColumns: ["id"]
          },
        ]
      }
      sms_logs: {
        Row: {
          created_at: string
          created_by: string | null
          customer_id: string | null
          error_message: string | null
          id: string
          message: string
          phone: string
          provider: string
          provider_response: Json | null
          reference_id: string | null
          sent_at: string | null
          status: string
          type: string
        }
        Insert: {
          created_at?: string
          created_by?: string | null
          customer_id?: string | null
          error_message?: string | null
          id?: string
          message: string
          phone: string
          provider?: string
          provider_response?: Json | null
          reference_id?: string | null
          sent_at?: string | null
          status?: string
          type?: string
        }
        Update: {
          created_at?: string
          created_by?: string | null
          customer_id?: string | null
          error_message?: string | null
          id?: string
          message?: string
          phone?: string
          provider?: string
          provider_response?: Json | null
          reference_id?: string | null
          sent_at?: string | null
          status?: string
          type?: string
        }
        Relationships: []
      }
      sms_settings: {
        Row: {
          api_secret: string
          api_token: string
          auto_delivery_enabled: boolean
          auto_due_enabled: boolean
          auto_invoice_enabled: boolean
          auto_payment_enabled: boolean
          base_url: string
          created_at: string
          delivery_template: string
          due_min_amount: number
          due_template: string
          id: string
          invoice_template: string
          payment_template: string
          provider: string
          sender_id: string
          sms_enabled: boolean
          updated_at: string
        }
        Insert: {
          api_secret?: string
          api_token?: string
          auto_delivery_enabled?: boolean
          auto_due_enabled?: boolean
          auto_invoice_enabled?: boolean
          auto_payment_enabled?: boolean
          base_url?: string
          created_at?: string
          delivery_template?: string
          due_min_amount?: number
          due_template?: string
          id?: string
          invoice_template?: string
          payment_template?: string
          provider?: string
          sender_id?: string
          sms_enabled?: boolean
          updated_at?: string
        }
        Update: {
          api_secret?: string
          api_token?: string
          auto_delivery_enabled?: boolean
          auto_due_enabled?: boolean
          auto_invoice_enabled?: boolean
          auto_payment_enabled?: boolean
          base_url?: string
          created_at?: string
          delivery_template?: string
          due_min_amount?: number
          due_template?: string
          id?: string
          invoice_template?: string
          payment_template?: string
          provider?: string
          sender_id?: string
          sms_enabled?: boolean
          updated_at?: string
        }
        Relationships: []
      }
      staff: {
        Row: {
          address: string
          branch_id: string | null
          commission_rate: number
          created_at: string
          created_by: string | null
          deleted_at: string | null
          department_id: string | null
          designation: string
          email: string
          id: string
          joining_date: string | null
          mobile: string
          name: string
          nid: string
          note: string
          photo_url: string
          role: string
          salary: number
          staff_id: string | null
          status: string
          updated_at: string
          username: string | null
        }
        Insert: {
          address?: string
          branch_id?: string | null
          commission_rate?: number
          created_at?: string
          created_by?: string | null
          deleted_at?: string | null
          department_id?: string | null
          designation?: string
          email?: string
          id?: string
          joining_date?: string | null
          mobile?: string
          name: string
          nid?: string
          note?: string
          photo_url?: string
          role?: string
          salary?: number
          staff_id?: string | null
          status?: string
          updated_at?: string
          username?: string | null
        }
        Update: {
          address?: string
          branch_id?: string | null
          commission_rate?: number
          created_at?: string
          created_by?: string | null
          deleted_at?: string | null
          department_id?: string | null
          designation?: string
          email?: string
          id?: string
          joining_date?: string | null
          mobile?: string
          name?: string
          nid?: string
          note?: string
          photo_url?: string
          role?: string
          salary?: number
          staff_id?: string | null
          status?: string
          updated_at?: string
          username?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "staff_department_id_fkey"
            columns: ["department_id"]
            isOneToOne: false
            referencedRelation: "departments"
            referencedColumns: ["id"]
          },
        ]
      }
      staff_attendance: {
        Row: {
          check_in: string | null
          check_out: string | null
          created_at: string
          created_by: string | null
          date: string
          id: string
          late_minutes: number
          note: string
          staff_id: string
          status: string
          updated_at: string
        }
        Insert: {
          check_in?: string | null
          check_out?: string | null
          created_at?: string
          created_by?: string | null
          date?: string
          id?: string
          late_minutes?: number
          note?: string
          staff_id: string
          status?: string
          updated_at?: string
        }
        Update: {
          check_in?: string | null
          check_out?: string | null
          created_at?: string
          created_by?: string | null
          date?: string
          id?: string
          late_minutes?: number
          note?: string
          staff_id?: string
          status?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "staff_attendance_staff_id_fkey"
            columns: ["staff_id"]
            isOneToOne: false
            referencedRelation: "staff"
            referencedColumns: ["id"]
          },
        ]
      }
      staff_payroll: {
        Row: {
          advance: number
          basic_salary: number
          bonus: number
          commission: number
          created_at: string
          created_by: string | null
          deduction: number
          id: string
          month: string
          net_payable: number
          note: string
          paid_amount: number
          payment_date: string | null
          staff_id: string
          status: string
          updated_at: string
        }
        Insert: {
          advance?: number
          basic_salary?: number
          bonus?: number
          commission?: number
          created_at?: string
          created_by?: string | null
          deduction?: number
          id?: string
          month: string
          net_payable?: number
          note?: string
          paid_amount?: number
          payment_date?: string | null
          staff_id: string
          status?: string
          updated_at?: string
        }
        Update: {
          advance?: number
          basic_salary?: number
          bonus?: number
          commission?: number
          created_at?: string
          created_by?: string | null
          deduction?: number
          id?: string
          month?: string
          net_payable?: number
          note?: string
          paid_amount?: number
          payment_date?: string | null
          staff_id?: string
          status?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "staff_payroll_staff_id_fkey"
            columns: ["staff_id"]
            isOneToOne: false
            referencedRelation: "staff"
            referencedColumns: ["id"]
          },
        ]
      }
      staff_salary_payments: {
        Row: {
          basic_salary: number
          bonus: number
          created_at: string
          created_by: string | null
          deduction: number
          id: string
          net_amount: number
          note: string
          paid_date: string | null
          pay_month: number
          pay_year: number
          payment_method: string
          staff_id: string
          status: string
          updated_at: string
        }
        Insert: {
          basic_salary?: number
          bonus?: number
          created_at?: string
          created_by?: string | null
          deduction?: number
          id?: string
          net_amount?: number
          note?: string
          paid_date?: string | null
          pay_month: number
          pay_year: number
          payment_method?: string
          staff_id: string
          status?: string
          updated_at?: string
        }
        Update: {
          basic_salary?: number
          bonus?: number
          created_at?: string
          created_by?: string | null
          deduction?: number
          id?: string
          net_amount?: number
          note?: string
          paid_date?: string | null
          pay_month?: number
          pay_year?: number
          payment_method?: string
          staff_id?: string
          status?: string
          updated_at?: string
        }
        Relationships: []
      }
      stock_adjustments: {
        Row: {
          adjusted_by: string | null
          created_at: string
          id: string
          product_id: string
          quantity_change: number
          reason: string | null
        }
        Insert: {
          adjusted_by?: string | null
          created_at?: string
          id?: string
          product_id: string
          quantity_change: number
          reason?: string | null
        }
        Update: {
          adjusted_by?: string | null
          created_at?: string
          id?: string
          product_id?: string
          quantity_change?: number
          reason?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "stock_adjustments_product_id_fkey"
            columns: ["product_id"]
            isOneToOne: false
            referencedRelation: "products"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "stock_adjustments_product_id_fkey"
            columns: ["product_id"]
            isOneToOne: false
            referencedRelation: "products_cost"
            referencedColumns: ["id"]
          },
        ]
      }
      stock_batches: {
        Row: {
          created_at: string
          id: string
          product_id: string
          purchase_id: string | null
          purchase_price: number
          quantity: number
          remaining_qty: number
        }
        Insert: {
          created_at?: string
          id?: string
          product_id: string
          purchase_id?: string | null
          purchase_price?: number
          quantity?: number
          remaining_qty?: number
        }
        Update: {
          created_at?: string
          id?: string
          product_id?: string
          purchase_id?: string | null
          purchase_price?: number
          quantity?: number
          remaining_qty?: number
        }
        Relationships: [
          {
            foreignKeyName: "stock_batches_purchase_id_fkey"
            columns: ["purchase_id"]
            isOneToOne: false
            referencedRelation: "purchases"
            referencedColumns: ["id"]
          },
        ]
      }
      stock_transfers: {
        Row: {
          created_at: string
          from_godown_id: string
          id: string
          note: string | null
          product_id: string
          quantity: number
          status: string
          to_godown_id: string
          transfer_date: string
          transferred_by: string | null
        }
        Insert: {
          created_at?: string
          from_godown_id: string
          id?: string
          note?: string | null
          product_id: string
          quantity?: number
          status?: string
          to_godown_id: string
          transfer_date?: string
          transferred_by?: string | null
        }
        Update: {
          created_at?: string
          from_godown_id?: string
          id?: string
          note?: string | null
          product_id?: string
          quantity?: number
          status?: string
          to_godown_id?: string
          transfer_date?: string
          transferred_by?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "stock_transfers_from_godown_id_fkey"
            columns: ["from_godown_id"]
            isOneToOne: false
            referencedRelation: "godowns"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "stock_transfers_to_godown_id_fkey"
            columns: ["to_godown_id"]
            isOneToOne: false
            referencedRelation: "godowns"
            referencedColumns: ["id"]
          },
        ]
      }
      subcategories: {
        Row: {
          category_id: string
          created_at: string
          deleted_at: string | null
          id: string
          name: string
          name_bn: string
          status: string
          updated_at: string
        }
        Insert: {
          category_id: string
          created_at?: string
          deleted_at?: string | null
          id?: string
          name: string
          name_bn: string
          status?: string
          updated_at?: string
        }
        Update: {
          category_id?: string
          created_at?: string
          deleted_at?: string | null
          id?: string
          name?: string
          name_bn?: string
          status?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "subcategories_category_id_fkey"
            columns: ["category_id"]
            isOneToOne: false
            referencedRelation: "categories"
            referencedColumns: ["id"]
          },
        ]
      }
      supplier_transactions: {
        Row: {
          amount: number
          created_at: string
          id: string
          method: string
          note: string | null
          reference_id: string | null
          supplier_id: string
          type: string
        }
        Insert: {
          amount?: number
          created_at?: string
          id?: string
          method?: string
          note?: string | null
          reference_id?: string | null
          supplier_id: string
          type?: string
        }
        Update: {
          amount?: number
          created_at?: string
          id?: string
          method?: string
          note?: string | null
          reference_id?: string | null
          supplier_id?: string
          type?: string
        }
        Relationships: [
          {
            foreignKeyName: "supplier_transactions_supplier_id_fkey"
            columns: ["supplier_id"]
            isOneToOne: false
            referencedRelation: "suppliers"
            referencedColumns: ["id"]
          },
        ]
      }
      suppliers: {
        Row: {
          address: string | null
          company_name: string | null
          created_at: string
          current_due: number
          email: string | null
          id: string
          is_deleted: boolean
          mobile: string
          name: string
          opening_balance: number
          status: string
          total_paid: number
          total_purchase: number
          updated_at: string
        }
        Insert: {
          address?: string | null
          company_name?: string | null
          created_at?: string
          current_due?: number
          email?: string | null
          id?: string
          is_deleted?: boolean
          mobile: string
          name: string
          opening_balance?: number
          status?: string
          total_paid?: number
          total_purchase?: number
          updated_at?: string
        }
        Update: {
          address?: string | null
          company_name?: string | null
          created_at?: string
          current_due?: number
          email?: string | null
          id?: string
          is_deleted?: boolean
          mobile?: string
          name?: string
          opening_balance?: number
          status?: string
          total_paid?: number
          total_purchase?: number
          updated_at?: string
        }
        Relationships: []
      }
      transaction_categories: {
        Row: {
          color: string
          created_at: string
          created_by: string | null
          deleted_at: string | null
          description: string
          icon: string
          id: string
          is_default: boolean
          name: string
          name_bn: string
          status: string
          type: string
          updated_at: string
        }
        Insert: {
          color?: string
          created_at?: string
          created_by?: string | null
          deleted_at?: string | null
          description?: string
          icon?: string
          id?: string
          is_default?: boolean
          name: string
          name_bn?: string
          status?: string
          type: string
          updated_at?: string
        }
        Update: {
          color?: string
          created_at?: string
          created_by?: string | null
          deleted_at?: string | null
          description?: string
          icon?: string
          id?: string
          is_default?: boolean
          name?: string
          name_bn?: string
          status?: string
          type?: string
          updated_at?: string
        }
        Relationships: []
      }
      transfer_items: {
        Row: {
          created_at: string
          id: string
          product_id: string
          quantity: number
          transfer_id: string
          unit: string
        }
        Insert: {
          created_at?: string
          id?: string
          product_id: string
          quantity?: number
          transfer_id: string
          unit?: string
        }
        Update: {
          created_at?: string
          id?: string
          product_id?: string
          quantity?: number
          transfer_id?: string
          unit?: string
        }
        Relationships: [
          {
            foreignKeyName: "transfer_items_transfer_id_fkey"
            columns: ["transfer_id"]
            isOneToOne: false
            referencedRelation: "transfers"
            referencedColumns: ["id"]
          },
        ]
      }
      transfers: {
        Row: {
          approved_at: string | null
          approved_by: string | null
          created_at: string
          created_by: string | null
          from_godown_id: string
          id: string
          note: string | null
          status: string
          to_godown_id: string
          total_items: number
          transfer_date: string
          transfer_no: string
          updated_at: string
        }
        Insert: {
          approved_at?: string | null
          approved_by?: string | null
          created_at?: string
          created_by?: string | null
          from_godown_id: string
          id?: string
          note?: string | null
          status?: string
          to_godown_id: string
          total_items?: number
          transfer_date?: string
          transfer_no?: string
          updated_at?: string
        }
        Update: {
          approved_at?: string | null
          approved_by?: string | null
          created_at?: string
          created_by?: string | null
          from_godown_id?: string
          id?: string
          note?: string | null
          status?: string
          to_godown_id?: string
          total_items?: number
          transfer_date?: string
          transfer_no?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "transfers_from_godown_id_fkey"
            columns: ["from_godown_id"]
            isOneToOne: false
            referencedRelation: "godowns"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "transfers_to_godown_id_fkey"
            columns: ["to_godown_id"]
            isOneToOne: false
            referencedRelation: "godowns"
            referencedColumns: ["id"]
          },
        ]
      }
      units: {
        Row: {
          created_at: string
          deleted_at: string | null
          id: string
          name: string
          name_bn: string
          short_code: string | null
          status: string
          updated_at: string
        }
        Insert: {
          created_at?: string
          deleted_at?: string | null
          id?: string
          name: string
          name_bn?: string
          short_code?: string | null
          status?: string
          updated_at?: string
        }
        Update: {
          created_at?: string
          deleted_at?: string | null
          id?: string
          name?: string
          name_bn?: string
          short_code?: string | null
          status?: string
          updated_at?: string
        }
        Relationships: []
      }
      user_permission_overrides: {
        Row: {
          created_at: string
          granted: boolean
          id: string
          permission_id: string
          user_id: string
        }
        Insert: {
          created_at?: string
          granted?: boolean
          id?: string
          permission_id: string
          user_id: string
        }
        Update: {
          created_at?: string
          granted?: boolean
          id?: string
          permission_id?: string
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "user_permission_overrides_permission_id_fkey"
            columns: ["permission_id"]
            isOneToOne: false
            referencedRelation: "permissions"
            referencedColumns: ["id"]
          },
        ]
      }
      user_roles: {
        Row: {
          created_at: string
          id: string
          role: Database["public"]["Enums"]["app_role"]
          user_id: string
        }
        Insert: {
          created_at?: string
          id?: string
          role: Database["public"]["Enums"]["app_role"]
          user_id: string
        }
        Update: {
          created_at?: string
          id?: string
          role?: Database["public"]["Enums"]["app_role"]
          user_id?: string
        }
        Relationships: []
      }
      wallet_transaction_audit: {
        Row: {
          action: string
          created_at: string
          customer_id: string
          id: string
          new_data: Json | null
          performed_by: string | null
          previous_data: Json | null
          transaction_id: string
        }
        Insert: {
          action: string
          created_at?: string
          customer_id: string
          id?: string
          new_data?: Json | null
          performed_by?: string | null
          previous_data?: Json | null
          transaction_id: string
        }
        Update: {
          action?: string
          created_at?: string
          customer_id?: string
          id?: string
          new_data?: Json | null
          performed_by?: string | null
          previous_data?: Json | null
          transaction_id?: string
        }
        Relationships: []
      }
      wallet_transactions: {
        Row: {
          amount: number
          balance_after: number
          created_at: string
          created_by: string | null
          customer_id: string
          deleted_at: string | null
          deleted_by: string | null
          id: string
          note: string | null
          reference_id: string | null
          transaction_date: string
          type: string
          updated_at: string
          updated_by: string | null
        }
        Insert: {
          amount?: number
          balance_after?: number
          created_at?: string
          created_by?: string | null
          customer_id: string
          deleted_at?: string | null
          deleted_by?: string | null
          id?: string
          note?: string | null
          reference_id?: string | null
          transaction_date?: string
          type?: string
          updated_at?: string
          updated_by?: string | null
        }
        Update: {
          amount?: number
          balance_after?: number
          created_at?: string
          created_by?: string | null
          customer_id?: string
          deleted_at?: string | null
          deleted_by?: string | null
          id?: string
          note?: string | null
          reference_id?: string | null
          transaction_date?: string
          type?: string
          updated_at?: string
          updated_by?: string | null
        }
        Relationships: []
      }
      withdrawal_action_logs: {
        Row: {
          action: string
          created_at: string
          id: string
          new_status: string
          note: string | null
          old_status: string | null
          processed_at: string
          processed_by: string | null
          withdrawal_id: string
        }
        Insert: {
          action: string
          created_at?: string
          id?: string
          new_status: string
          note?: string | null
          old_status?: string | null
          processed_at?: string
          processed_by?: string | null
          withdrawal_id: string
        }
        Update: {
          action?: string
          created_at?: string
          id?: string
          new_status?: string
          note?: string | null
          old_status?: string | null
          processed_at?: string
          processed_by?: string | null
          withdrawal_id?: string
        }
        Relationships: []
      }
      withdrawal_requests: {
        Row: {
          account_number: string
          amount: number
          created_at: string
          customer_id: string
          id: string
          method: string
          note: string | null
          processed_at: string | null
          processed_by: string | null
          status: string
          updated_at: string
        }
        Insert: {
          account_number?: string
          amount?: number
          created_at?: string
          customer_id: string
          id?: string
          method?: string
          note?: string | null
          processed_at?: string | null
          processed_by?: string | null
          status?: string
          updated_at?: string
        }
        Update: {
          account_number?: string
          amount?: number
          created_at?: string
          customer_id?: string
          id?: string
          method?: string
          note?: string | null
          processed_at?: string | null
          processed_by?: string | null
          status?: string
          updated_at?: string
        }
        Relationships: []
      }
    }
    Views: {
      product_pricing_cost: {
        Row: {
          id: string | null
          product_id: string | null
          purchase_price: number | null
        }
        Insert: {
          id?: string | null
          product_id?: string | null
          purchase_price?: number | null
        }
        Update: {
          id?: string | null
          product_id?: string | null
          purchase_price?: number | null
        }
        Relationships: []
      }
      product_units_cost: {
        Row: {
          id: string | null
          product_id: string | null
          purchase_price: number | null
        }
        Insert: {
          id?: string | null
          product_id?: string | null
          purchase_price?: number | null
        }
        Update: {
          id?: string | null
          product_id?: string | null
          purchase_price?: number | null
        }
        Relationships: []
      }
      products_cost: {
        Row: {
          id: string | null
          purchase_price: number | null
        }
        Insert: {
          id?: string | null
          purchase_price?: number | null
        }
        Update: {
          id?: string | null
          purchase_price?: number | null
        }
        Relationships: []
      }
    }
    Functions: {
      get_customer_order_stats: {
        Args: { _customer_id: string }
        Returns: Json
      }
      get_user_branch_id: { Args: { _user_id: string }; Returns: string }
      has_permission: {
        Args: { _permission: string; _user_id: string }
        Returns: boolean
      }
      has_role: {
        Args: {
          _role: Database["public"]["Enums"]["app_role"]
          _user_id: string
        }
        Returns: boolean
      }
      is_staff: { Args: { _user_id: string }; Returns: boolean }
      next_invoice_no: { Args: never; Returns: string }
      portal_transfer_wallet_balance: {
        Args: { p_amount: number; p_recipient_id: string; p_sender_id: string }
        Returns: {
          recipient_new_balance: number
          sender_new_balance: number
        }[]
      }
      recalc_referral_wallet: {
        Args: { _customer_id: string }
        Returns: undefined
      }
      verify_referral_autobinding: { Args: never; Returns: Json }
    }
    Enums: {
      app_role: "admin" | "staff" | "user"
    }
    CompositeTypes: {
      [_ in never]: never
    }
  }
}

type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">

type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">]

export type Tables<
  DefaultSchemaTableNameOrOptions extends
    | keyof (DefaultSchema["Tables"] & DefaultSchema["Views"])
    | { schema: keyof DatabaseWithoutInternals },
  TableName extends DefaultSchemaTableNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
        DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])
    : never = never,
> = DefaultSchemaTableNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
      DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
      Row: infer R
    }
    ? R
    : never
  : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] &
        DefaultSchema["Views"])
    ? (DefaultSchema["Tables"] &
        DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends {
        Row: infer R
      }
      ? R
      : never
    : never

export type TablesInsert<
  DefaultSchemaTableNameOrOptions extends
    | keyof DefaultSchema["Tables"]
    | { schema: keyof DatabaseWithoutInternals },
  TableName extends DefaultSchemaTableNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
    : never = never,
> = DefaultSchemaTableNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
      Insert: infer I
    }
    ? I
    : never
  : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
    ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
        Insert: infer I
      }
      ? I
      : never
    : never

export type TablesUpdate<
  DefaultSchemaTableNameOrOptions extends
    | keyof DefaultSchema["Tables"]
    | { schema: keyof DatabaseWithoutInternals },
  TableName extends DefaultSchemaTableNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
    : never = never,
> = DefaultSchemaTableNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
      Update: infer U
    }
    ? U
    : never
  : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
    ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
        Update: infer U
      }
      ? U
      : never
    : never

export type Enums<
  DefaultSchemaEnumNameOrOptions extends
    | keyof DefaultSchema["Enums"]
    | { schema: keyof DatabaseWithoutInternals },
  EnumName extends DefaultSchemaEnumNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"]
    : never = never,
> = DefaultSchemaEnumNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName]
  : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"]
    ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions]
    : never

export type CompositeTypes<
  PublicCompositeTypeNameOrOptions extends
    | keyof DefaultSchema["CompositeTypes"]
    | { schema: keyof DatabaseWithoutInternals },
  CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
    : never = never,
> = PublicCompositeTypeNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName]
  : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"]
    ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions]
    : never

export const Constants = {
  public: {
    Enums: {
      app_role: ["admin", "staff", "user"],
    },
  },
} as const
