<?php

namespace objects;

use classes\db;
use classes\object_property;
use classes\xlvask;
use Exception;
use helpers\xlvask_customer;
use helpers\xlvask_vehicle;
use traits\db_object_t;

class xlvask_usage_log_wash_items_o extends db
{
    use db_object_t;

    public object_property $WashItemId;
    public object_property $ExternalProductId;
    public object_property $ExternalProductName;
    public object_property $OriginalProductName;
    public object_property $Unit;
    public object_property $UnitPrice;
    public object_property $Count;
    public object_property $Discount;
    public object_property $PriceExVat;
    public object_property $Vat;
    public object_property $PriceIncVat;
    public object_property $xlvask_usage_log_id; // Assuming this is a foreign key to the usage log

    public function structure(): void
    {
        $this->setTable('xlvask_usage_log_wash_items');
    }

    /**
     * Add a new XL Vask usage log wash item
     * @param array $data The properties
     * @returns void
     * @throws Exception If the object was not created successfully
     */
    public function add(array $data): void
    {
        $tmp_id = self::add_object($data);
        $this->id = $tmp_id;
        self::getObjectProperties();
        self::objectChanged();
    }

    public function getObjectProperties(): void
    {
        $this->WashItemId = new object_property($this->table, $this->id, 'WashItemId', 'string', false);
        $this->ExternalProductId = new object_property($this->table, $this->id, 'ExternalProductId', 'string', false);
        $this->ExternalProductName = new object_property($this->table, $this->id, 'ExternalProductName', 'string', false);
        $this->OriginalProductName = new object_property($this->table, $this->id, 'OriginalProductName', 'string', false);
        $this->Unit = new object_property($this->table, $this->id, 'Unit', 'string', false);
        $this->UnitPrice = new object_property($this->table, $this->id, 'UnitPrice', 'string', false);
        $this->Count = new object_property($this->table, $this->id, 'Count', 'string', false);
        $this->Discount = new object_property($this->table, $this->id, 'Discount', 'string', false);
        $this->PriceExVat = new object_property($this->table, $this->id, 'PriceExVat', 'string', false);
        $this->Vat = new object_property($this->table, $this->id, 'Vat', 'string', false);
        $this->PriceIncVat = new object_property($this->table, $this->id, 'PriceIncVat', 'string', false);
        $this->xlvask_usage_log_id = new object_property($this->table, $this->id, 'xlvask_usage_log_id', 'int', false);
    }

    public function objectChanged(): void
    {
        //TODO: Add cache invalidation
    }
}