yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
 * @file        ADSO-10087  - Accounts list shows accounts for unit costs with correct information
 * @description Create 4 new accounts and verify their correct creation
 * @author      Umar Adkhamov (umar.adkhamov@3ds.com)
 * @copyright   Dassault Systemes
 */
import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const';
import { AppMP, Demo, Scenario } from '../../../libmp/appmp';
import { DataFoodBaseAccountCostDriver, DataFoodBaseAccountName, DataFoodBaseAccountTimeUnit, DataFoodBaseAccountUoM } from '../../../libmp/data/data.account';
import { ListAccountContextMenuItem } from '../../../libmp/forms/form.account';
import { AccountCostType } from '../../../libmp/views/view.account';
 
describe('ADSO-10087  - Accounts list shows accounts for unit costs with correct information', () => {
  const appMP = AppMP.getInstance();
  const costDriverCO = DataFoodBaseAccountCostDriver.Changeover;
  const parentCostOfSales = [{ Name: DataFoodBaseAccountName.CostOfSales }];
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMP.checkToastMessage();
  });
 
  it(`Setup - ${AppMP.getDemoDataPath(Demo.Food, Scenario.Base)}`, async () => {
    await appMP.createDemoDataset(Demo.Food, Scenario.Base, false); // This test does not need wait optimizer completed before proceed
  });
 
  it(`Step 1 - Open view ${appMP.viewAccount.viewPath}.<br>
      Edit account '${AccountCostType.General}', set cost driver = ${DataFoodBaseAccountCostDriver.Fixed}, cost = 1000, time unit= ${DataFoodBaseAccountTimeUnit.Month}.<br>
      Edit account '${AccountCostType.Changeover}', set cost driver = ${costDriverCO}, cost = 100.<br>
      Create account '${AccountCostType.Maintenance}', set cost driver = Number of units, cost = 5000, time unit=${DataFoodBaseAccountTimeUnit.Year}.<br>
      Create account '${AccountCostType.Labor}', set cost driver = Staffing, cost = 40.`, async () => {
    await appMP.viewAccount.switchTo();
 
    // In Food demo, General fixed costs, Labor cost & Changeover cost already exist
    // Edit other values beside the name for these accounts
    let accountRow = await appMP.viewAccount.frmAccount.listAccount.getRow({ Name: AccountCostType.General }, parentCostOfSales);
    let [dlgAccount] = await appMP.viewAccount.frmAccount.listAccount.selectContextMenu(ListAccountContextMenuItem.Edit, accountRow);
    await dlgAccount.updateDialogValues({ CostDriver: DataFoodBaseAccountCostDriver.Fixed, Cost: '1000', TimeUnit: DataFoodBaseAccountTimeUnit.Month });
    await dlgAccount.clickOK();
 
    accountRow = await appMP.viewAccount.frmAccount.listAccount.getRow({ Name: AccountCostType.Labor }, parentCostOfSales);
    [dlgAccount] = await appMP.viewAccount.frmAccount.listAccount.selectContextMenu(ListAccountContextMenuItem.Edit, accountRow);
    await dlgAccount.updateDialogValues({ CostDriver: 'Staffing', Cost: '40' });
    await dlgAccount.clickOK();
 
    accountRow = await appMP.viewAccount.frmAccount.listAccount.getRow({ Name: AccountCostType.Changeover }, parentCostOfSales);
    [dlgAccount] = await appMP.viewAccount.frmAccount.listAccount.selectContextMenu(ListAccountContextMenuItem.Edit, accountRow);
    await dlgAccount.updateDialogValues({ CostDriver: costDriverCO, Cost: '100' });
    await dlgAccount.clickOK();
 
    // Create as not exist in Food demo
    [dlgAccount] = await appMP.viewAccount.frmAccount.listAccount.selectContextMenu(ListAccountContextMenuItem.Create);
    await dlgAccount.updateDialogValues({ Name: AccountCostType.Maintenance, ParentAccountName: DataFoodBaseAccountName.CostOfSales, CostDriver: 'Number of units', Cost: '5000', TimeUnit: DataFoodBaseAccountTimeUnit.Year });
    await dlgAccount.clickOK();
  });
 
  it(`Step 2 - Open view ${appMP.viewUnitCost.viewPath}. Verify the 4 accounts display correctly in Unit Accounts form.`, async () => {
    await appMP.viewUnitCost.switchTo();
 
    const euroMonth = DataFoodBaseAccountUoM.EuroPerMonth;
    const euroYear = DataFoodBaseAccountUoM.EuroPerYear;
    const euroDay = DataFoodBaseAccountUoM.EuroPerHour;
    const euroChangeOver = `${DataFoodBaseAccountUoM.EuroPer}${costDriverCO}`;
 
    // Verify that all the 4 unit accounts have the correct values as above
    let accountRow = await appMP.viewUnitCost.frmUnitAccount.listAccount.getRow({ Account: AccountCostType.General });
    await appMP.viewUnitCost.frmUnitAccount.listAccount.verifyRowValues(accountRow, { 'Default value': '1,000', 'Default UoM': euroMonth });
 
    accountRow = await appMP.viewUnitCost.frmUnitAccount.listAccount.getRow({ Account: AccountCostType.Maintenance });
    await appMP.viewUnitCost.frmUnitAccount.listAccount.verifyRowValues(accountRow, { 'Default value': '5,000', 'Default UoM': euroYear });
 
    accountRow = await appMP.viewUnitCost.frmUnitAccount.listAccount.getRow({ Account: AccountCostType.Labor });
    await appMP.viewUnitCost.frmUnitAccount.listAccount.verifyRowValues(accountRow, { 'Default value': '40', 'Default UoM': euroDay });
 
    accountRow = await appMP.viewUnitCost.frmUnitAccount.listAccount.getRow({ Account: AccountCostType.Changeover });
    await appMP.viewUnitCost.frmUnitAccount.listAccount.verifyRowValues(accountRow, { 'Default value': '100', 'Default UoM': euroChangeOver });
  });
});