<?php

/**
 * @deprecated This model is retired. Use \App\Models\MainAccount for GL accounts.
 */
namespace App\Models;

use Illuminate\Support\Facades\DB;

class GeneralLedger extends MainAccount
{
    public static function editAccountTypes($id, $type, $accCode, $accName)
    {
        return DB::update("UPDATE `main_accounts` SET `account_type` = ?, `code` = ?, `account_name` = ? WHERE `id` = ?", [$type, $accCode, $accName, $id]);
    }

    public static function deleteAccountTypes($id)
    {
        return DB::delete("DELETE FROM `account_types` WHERE `id` = ?", [$id]);
    }

    public static function editMainAccount($id, $type, $code, $financialCategory, $accountName)
    {
        return DB::update(
            "UPDATE main_accounts SET account_type = ?, code = ?, financial_category = ?, account_name = ? WHERE id = ?",
            [$type, $code, $financialCategory, $accountName, $id]
        );
    }

    public static function deleteMainAccount($id)
    {
        return DB::delete("DELETE FROM main_accounts WHERE id = ?", [$id]);
    }

    public static function editSubAccount($id, $accountCode, $accountName, $code, $subName, $parentId)
    {
        return DB::update(
            "UPDATE sub_accounts SET account_code = ?, sub_code = ?, code = ?, sub_name = ?, parent_id = ? WHERE id = ?",
            [$accountCode, $accountName, $code, $subName, $parentId, $id]
        );
    }

    public static function deleteSubAccount($id)
    {
        return DB::delete("DELETE FROM `sub_accounts` WHERE `id` = ?", [$id]);
    }
}
