import { Injectable } from "@angular/core";

import { Api } from "../api/api";
import { AbstractBase } from "./abstractbase";

@Injectable()
export class Base extends AbstractBase
{
  public get api(): Api
  {
    return this.apiSvc;
  }

  public saveLabelSetting(params: any)
  {
    return this.api.post('v1/paramTypes/saveLabelSetting', params);
  }

  public saveLookupData(params: any)
  {
    return this.api.post('v1/paramTypes/saveLookupData', params);
  }

  public deleteLookupData(lookupId: number)
  {
    const params: any = { lookupId: lookupId };
    return this.api.post('v1/paramTypes/deleteLookupData', params);
  }

  public getFixedAssetProduct(inventoryTypeId: number, productCode: string)
  {
    const params: any = { inventoryTypeId: inventoryTypeId, productCode: productCode };
    return this.api.post('v1/paramTypes/getProductByCode', params);
  }

  public getFixedAssetsProducts(inventoryTypeId: number, criteria: string)
  {
    const params: any = { inventoryTypeId: inventoryTypeId, criteria: criteria };
    return this.api.post('v1/paramTypes/getProducts', params);
  }

  public getFASpareParts(criteria: string)
  {
    const params: any = { inventoryTypeId: 4, criteria: criteria };
    return this.api.post('v1/paramTypes/getFASpareParts', params);
  }

  public getFixedAssetsProductsExt(invTypeIds: number[], criteria: string, materialOnly: boolean)
  {
    const params: any = { inventoryTypeIds: invTypeIds, criteria: criteria, materialOnly: materialOnly };
    return this.api.post('v1/paramTypes/getProductsExt', params);
  }

  public getProductsStock(storeId: number, stockOf: number, haveStockOnly: boolean, invTypeIds: number[], materialOnly: boolean, criteria: string)
  {
    const params: any = { storeId: storeId, stockOf: stockOf, haveStockOnly: haveStockOnly, inventoryTypeIds: invTypeIds, materialOnly: materialOnly, criteria: criteria };
    return this.api.post('v1/paramTypes/getProductsStock', params);
  }

  public getCustTranTypes(typeOfTran: number)
  {
    const params: any = { tranType: 1, typeOfTran: typeOfTran };
    return this.api.post('v1/paramTypes/getSalesTxnTypes', params);
  }

  public getStockTranTypes(typeOfTran: number)
  {
    const params: any = { tranType: 2, typeOfTran: typeOfTran };
    return this.api.post('v1/paramTypes/getSalesTxnTypes', params);
  }
}
