Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,50 +1,42 @@
import uuid from 'uuid';
import permissions from '../../../support/dictionary/permissions';
import FiscalYears from '../../../support/fragments/finance/fiscalYears/fiscalYears';
import Funds from '../../../support/fragments/finance/funds/funds';
import Ledgers from '../../../support/fragments/finance/ledgers/ledgers';
import Invoices from '../../../support/fragments/invoices/invoices';
import OrderLines from '../../../support/fragments/orders/orderLines';
import Orders from '../../../support/fragments/orders/orders';
import NewOrganization from '../../../support/fragments/organizations/newOrganization';
import Organizations from '../../../support/fragments/organizations/organizations';
import TopMenu from '../../../support/fragments/topMenu';
import Users from '../../../support/fragments/users/users';
import getRandomPostfix from '../../../support/utils/stringTools';
import Budgets from '../../../support/fragments/finance/budgets/budgets';
import {
ACQUISITION_METHOD_NAMES_IN_PROFILE,
INVOICE_STATUSES,
LOCATION_NAMES,
ORDER_STATUSES,
} from '../../../support/constants';
import BasicOrderLine from '../../../support/fragments/orders/basicOrderLine';
import Permissions from '../../../support/dictionary/permissions';
import {
BudgetDetails,
Budgets,
FiscalYears,
Funds,
Ledgers,
} from '../../../support/fragments/finance';
import FinanceHelp from '../../../support/fragments/finance/financeHelper';
import BudgetDetails from '../../../support/fragments/finance/budgets/budgetDetails';
import Invoices from '../../../support/fragments/invoices/invoices';
import { BasicOrderLine, OrderLines, Orders } from '../../../support/fragments/orders';
import { NewOrganization, Organizations } from '../../../support/fragments/organizations';
import TopMenu from '../../../support/fragments/topMenu';
import Users from '../../../support/fragments/users/users';

describe('Finance', () => {
describe('Funds', () => {
const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear };
const defaultLedger = {
const fiscalYear = { ...FiscalYears.defaultUiFiscalYear };
const ledger = {
...Ledgers.defaultUiLedger,
restrictEncumbrance: false,
restrictExpenditures: false,
};
const firstFund = { ...Funds.defaultUiFund };
const secondFund = {
name: `autotest_fund2_${getRandomPostfix()}`,
code: getRandomPostfix(),
externalAccountNo: getRandomPostfix(),
fundStatus: 'Active',
description: `This is fund created by E2E test automation script_${getRandomPostfix()}`,
};
const firstOrder = {
const fund = { ...Funds.defaultUiFund };
const order = {
id: uuid(),
vendor: '',
orderType: 'One-Time',
approved: true,
reEncumber: true,
};
const firstBudget = {
const budget = {
...Budgets.getDefaultBudget(),
allocated: 1000,
allowableEncumbrance: 100,
Expand All @@ -58,90 +50,102 @@ describe('Finance', () => {

before(() => {
cy.getAdminToken();
// create first Fiscal Year and prepere 2 Funds for Rollover
FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => {
firstFiscalYear.id = firstFiscalYearResponse.id;
firstBudget.fiscalYearId = firstFiscalYearResponse.id;
defaultLedger.fiscalYearOneId = firstFiscalYear.id;
Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => {
defaultLedger.id = ledgerResponse.id;
firstFund.ledgerId = defaultLedger.id;
secondFund.ledgerId = defaultLedger.id;

Funds.createViaApi(firstFund).then((fundResponse) => {
firstFund.id = fundResponse.fund.id;
firstBudget.fundId = fundResponse.fund.id;
Budgets.createViaApi(firstBudget);
FiscalYears.createViaApi(fiscalYear).then((fiscalYearResponse) => {
fiscalYear.id = fiscalYearResponse.id;
budget.fiscalYearId = fiscalYearResponse.id;
ledger.fiscalYearOneId = fiscalYear.id;
Ledgers.createViaApi(ledger).then((ledgerResponse) => {
ledger.id = ledgerResponse.id;
fund.ledgerId = ledger.id;

cy.getLocations({ limit: 1 }).then((res) => {
location = res;
Funds.createViaApi(fund).then((fundResponse) => {
fund.id = fundResponse.fund.id;
budget.fundId = fundResponse.fund.id;
Budgets.createViaApi(budget).then(() => {
Budgets.batchProcessTransactions({
transactionsToCreate: [
{
amount: 500,
currency: 'USD',
fiscalYearId: fiscalYear.id,
fromFundId: fund.id,
id: uuid(),
source: 'User',
transactionType: 'Allocation',
},
],
});
cy.getLocations({ query: `name="${LOCATION_NAMES.MAIN_LIBRARY_UI}"` }).then((res) => {
location = res;

cy.getDefaultMaterialType().then((mtype) => {
cy.getAcquisitionMethodsApi({
query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`,
}).then((params) => {
// Prepare 2 Open Orders for Rollover
Organizations.createOrganizationViaApi(organization).then(
(responseOrganizations) => {
organization.id = responseOrganizations;
firstOrder.vendor = organization.id;
const firstOrderLine = {
...BasicOrderLine.defaultOrderLine,
cost: {
listUnitPrice: 1000,
currency: 'USD',
discountType: 'percentage',
quantityPhysical: 1,
poLineEstimatedPrice: 1000,
},
fundDistribution: [
{ code: firstFund.code, fundId: firstFund.id, value: 100 },
],
locations: [{ locationId: location.id, quantity: 1, quantityPhysical: 1 }],
acquisitionMethod: params.body.acquisitionMethods[0].id,
physical: {
createInventory: 'Instance, Holding, Item',
materialType: mtype.id,
materialSupplier: responseOrganizations,
volumes: [],
},
};
cy.getDefaultMaterialType().then((mtype) => {
cy.getAcquisitionMethodsApi({
query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`,
}).then((params) => {
Organizations.createOrganizationViaApi(organization).then(
(responseOrganizations) => {
organization.id = responseOrganizations;
order.vendor = organization.id;
const firstOrderLine = {
...BasicOrderLine.defaultOrderLine,
cost: {
listUnitPrice: 1000,
currency: 'USD',
discountType: 'percentage',
quantityPhysical: 1,
poLineEstimatedPrice: 1000,
},
fundDistribution: [{ code: fund.code, fundId: fund.id, value: 100 }],
locations: [
{ locationId: location.id, quantity: 1, quantityPhysical: 1 },
],
acquisitionMethod: params.body.acquisitionMethods[0].id,
physical: {
createInventory: 'Instance, Holding, Item',
materialType: mtype.id,
materialSupplier: responseOrganizations,
volumes: [],
},
};

Invoices.createInvoiceWithInvoiceLineViaApi({
vendorId: organization.id,
fiscalYearId: firstFiscalYear.id,
fundDistributions: firstOrderLine.fundDistribution,
accountingCode: organization.erpCode,
releaseEncumbrance: true,
subTotal: -100,
}).then((invoiceRescponse) => {
firstInvoice = invoiceRescponse;
Invoices.createInvoiceWithInvoiceLineViaApi({
vendorId: organization.id,
fiscalYearId: fiscalYear.id,
fundDistributions: firstOrderLine.fundDistribution,
accountingCode: organization.erpCode,
releaseEncumbrance: true,
subTotal: -100,
}).then((invoiceRescponse) => {
firstInvoice = invoiceRescponse;

Invoices.changeInvoiceStatusViaApi({
invoice: firstInvoice,
status: INVOICE_STATUSES.APPROVED,
});
Orders.createOrderViaApi(firstOrder).then((firstOrderResponse) => {
firstOrder.id = firstOrderResponse.id;
firstOrderLine.purchaseOrderId = firstOrderResponse.id;
Invoices.changeInvoiceStatusViaApi({
invoice: firstInvoice,
status: INVOICE_STATUSES.APPROVED,
});
Orders.createOrderViaApi(order).then((firstOrderResponse) => {
order.id = firstOrderResponse.id;
firstOrderLine.purchaseOrderId = firstOrderResponse.id;

OrderLines.createOrderLineViaApi(firstOrderLine);
Orders.updateOrderViaApi({
...firstOrderResponse,
workflowStatus: ORDER_STATUSES.OPEN,
OrderLines.createOrderLineViaApi(firstOrderLine);
Orders.updateOrderViaApi({
...firstOrderResponse,
workflowStatus: ORDER_STATUSES.OPEN,
});
});
});
});
},
);
},
);
});
});
});
});
});
});
});
cy.createTempUser([permissions.uiFinanceViewFundAndBudget.gui]).then((userProperties) => {

cy.createTempUser([Permissions.uiFinanceViewFundAndBudget.gui]).then((userProperties) => {
user = userProperties;

cy.login(userProperties.username, userProperties.password, {
path: TopMenu.fundPath,
waiter: Funds.waitLoading,
Expand All @@ -158,8 +162,8 @@ describe('Finance', () => {
'C496150 Correct "Financial summary" values when encumbered amount exceeds available amount (thunderjet)',
{ tags: ['criticalPath', 'thunderjet', 'C496150'] },
() => {
FinanceHelp.searchByName(firstFund.name);
Funds.selectFund(firstFund.name);
FinanceHelp.searchByName(fund.name);
Funds.selectFund(fund.name);
Funds.selectBudgetDetails();
BudgetDetails.checkBudgetDetails({
summary: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import InventoryInstance from '../../../support/fragments/inventory/inventoryIns
import Users from '../../../support/fragments/users/users';

describe('Inventory', () => {
describe('Search in inventory', () => {
describe('Search in Inventory', () => {
describe('Correct page title inventory search', () => {
const randomPostfix = getRandomPostfix();
const testData = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import InventoryInstances from '../../../support/fragments/inventory/inventoryIn
import InventorySearchAndFilter from '../../../support/fragments/inventory/inventorySearchAndFilter';

describe('Inventory', () => {
describe('Search In Inventory', () => {
describe('Search in Inventory', () => {
const testData = {
instanceTitle: `C366119 autoTestInstanceTitle${getRandomPostfix()}`,
barcode: uuid(),
Expand Down
Loading
Loading