| import { Form } from '../../e2elib/lib/src/pageobjects/form.component'; | 
| import { ListBase } from '../../libappbase/listbase'; | 
| import { ListRow } from '../../e2elib/lib/src/pageobjects/list/listrow.component'; | 
| import { DialogInventoryCost } from '../dialogs/dialog.inventorycost'; | 
| import { asyncEvery } from '../../libappbase/utils'; | 
| import { CheckboxBase } from '../../libappbase/checkboxbase'; | 
| import { QContextMenu } from '../../e2elib/lib/api/pageobjects/qcontextmenu.component'; | 
|   | 
| /** | 
|  * Inventory Cost PISP form. | 
|  */ | 
| export class FormInventoryCosts extends Form { | 
|   public lstAccountCosts = new ListAccountCosts(); | 
|   public cbFilterByAccounts = new CheckboxBase('cbFilterByAccounts'); | 
|   | 
|   public constructor() { | 
|     super('FormInventoryCosts'); | 
|   } | 
|   | 
|   /** | 
|    * Toggle filter by account on or off | 
|    * | 
|    * @param isToggleOn Indicate to toggle on or off | 
|    */ | 
|   public async toggleFilterByAccount(isToggleOn: boolean): Promise<void> { | 
|     await this.cbFilterByAccounts.toggle(isToggleOn); | 
|   } | 
| } | 
|   | 
| /** | 
|  * Inventory PISP list in Inventory Cost PISP form. | 
|  */ | 
| export class ListAccountCosts extends ListBase { | 
|   public dlgInventoryCost = new DialogInventoryCost(); | 
|   public cmMenu = new QContextMenu('lsContextMenuAccCosts'); | 
|   | 
|   public constructor() { | 
|     super('lsAccountCosts'); | 
|   } | 
|   | 
|   /** | 
|    * Get inventory cost in list by product name | 
|    * | 
|    * @param product Product name | 
|    * @returns ListRow that match the product name | 
|    */ | 
|   public async getInventoryCostByName(product: string): Promise<ListRow> { | 
|     return this.getRowByValue([{ columnID: ListColumnAccountCosts.Product, value: product }]); | 
|   } | 
|   | 
|   /** | 
|    * Open create inventory cost dialog by context menu, field in value and confirm the dialog | 
|    * | 
|    * @param account Account field value | 
|    * @param costDriver Cost driver field value | 
|    * @param product Product field value | 
|    * @param stockingPoint Stocking point field value | 
|    * @param startDate Start date field value | 
|    * @param cost Cost field value | 
|    * @returns Boolean indicates whether the create action is successful or not | 
|    */ | 
|   public async createNewInventoryCost(account: string, costDriver: string, product: string, stockingPoint: string, startDate: Date, cost: number): Promise<boolean> { | 
|     await this.rightClick(undefined, this.cmMenu, 'MenuCreate'); | 
|     await this.dlgInventoryCost.waitUntilPresent(); | 
|     await this.dlgInventoryCost.updateDialog(account, costDriver, product, stockingPoint, startDate, cost); | 
|     return this.dlgInventoryCost.closeDialog(); | 
|   } | 
|   | 
|   /** | 
|    * Verify if all rows has correct value in the column | 
|    * | 
|    * @param rows ListRows to verify | 
|    * @param columnName Name of the column to verify | 
|    * @param value Expected value of the column | 
|    */ | 
|   public async matchColumnValueFromRows(rows: ListRow[], columnName: string, value: string): Promise<boolean> { | 
|     const cellValues = await this.getCellValueFromRow(columnName, rows); | 
|     const result = await asyncEvery(cellValues, async (cellValue: string) => Promise.resolve(cellValue === value)); | 
|     return result; | 
|   } | 
|   | 
|   /** | 
|    * Find inventory cost by value from the list | 
|    * | 
|    * @param product Product column value | 
|    * @param stockingPoint Stocking point column value | 
|    * @param account Account column value | 
|    * @param costDriver Cost driver column value | 
|    * @param cost Cost column value | 
|    */ | 
|   public async findInventoryCost(product: string, stockingPoint: string, account: string, costDriver: string, cost: number): Promise<ListRow | undefined> { | 
|     const result = await this.getRowByValue([ | 
|       { columnID: ListColumnAccountCosts.Product, value: product }, | 
|       { columnID: ListColumnAccountCosts.StockingPoint, value: stockingPoint }, | 
|       { columnID: ListColumnAccountCosts.Account, value: account }, | 
|       { columnID: ListColumnAccountCosts.CostDriver, value: costDriver }, | 
|       { columnID: ListColumnAccountCosts.Cost, value: cost.toString() }, | 
|     ]).catch(() => undefined); | 
|   | 
|     return result; | 
|   } | 
| } | 
|   | 
| export enum ListColumnAccountCosts { | 
|   Product = 'Product', | 
|   StockingPoint = 'Stocking point', | 
|   Account = 'Account', | 
|   CostDriver = 'Cost driver', | 
|   Cost = 'Cost', | 
| } |