Skip to content

Commit

Permalink
[400643] Rollover based on 'Remaining'
Browse files Browse the repository at this point in the history
  • Loading branch information
dnovikau committed Nov 29, 2023
1 parent fb92784 commit f863b58
Show file tree
Hide file tree
Showing 4 changed files with 237 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
import { Permissions } from '../../../../support/dictionary';
import {
FinanceHelper,
FiscalYears,
Funds,
Budgets,
Ledgers,
LedgerRolloverInProgress,
Transactions,
TransactionDetails,
} from '../../../../support/fragments/finance';
import { NewOrganization, Organizations } from '../../../../support/fragments/organizations';
import { NewOrder, BasicOrderLine, Orders, OrderLines } from '../../../../support/fragments/orders';
import { Invoices } from '../../../../support/fragments/invoices';
import TopMenu from '../../../../support/fragments/topMenu';
import Users from '../../../../support/fragments/users/users';
import { CodeTools, StringTools } from '../../../../support/utils';
import { INVOICE_STATUSES } from '../../../../support/constants';

describe('Finance', () => {
describe('Fiscal Year Rollover', () => {
const date = new Date();
const code = CodeTools(4);
const fiscalYears = {
current: {
...FiscalYears.getDefaultFiscalYear(),
code: `${code}${StringTools.randomTwoDigitNumber()}01`,
periodStart: new Date(date.getFullYear(), 0, 1),
periodEnd: new Date(date.getFullYear(), 11, 31),
},
next: {
...FiscalYears.getDefaultFiscalYear(),
code: `${code}${StringTools.randomTwoDigitNumber()}03`,
periodStart: new Date(date.getFullYear() + 1, 0, 1),
periodEnd: new Date(date.getFullYear() + 1, 11, 31),
},
};
const ledger = { ...Ledgers.getDefaultLedger(), fiscalYearOneId: fiscalYears.current.id };
const fund = { ...Funds.getDefaultFund(), ledgerId: ledger.id };
const budget = {
...Budgets.getDefaultBudget(),
allocated: 100,
fiscalYearId: fiscalYears.current.id,
fundId: fund.id,
};
const testData = {
organization: NewOrganization.getDefaultOrganization(),
fiscalYears,
user: {},
};

before('Create test data', () => {
cy.getAdminToken().then(() => {
Object.values(fiscalYears).forEach((fiscalYear) => {
FiscalYears.createViaApi(fiscalYear);
});
Ledgers.createViaApi(ledger);
Funds.createViaApi(fund);
Budgets.createViaApi(budget);

Organizations.createOrganizationViaApi(testData.organization).then(() => {
testData.order = {
...NewOrder.getDefaultOrder({ vendorId: testData.organization.id }),
reEncumber: true,
};
testData.orderLine = BasicOrderLine.getDefaultOrderLine({
listUnitPrice: 20,
fundDistribution: [
{ code: fund.code, fundId: fund.id, value: 20, distributionType: 'amount' },
],
});

Orders.createOrderWithOrderLineViaApi(testData.order, testData.orderLine).then(
(order) => {
testData.order = order;

Orders.updateOrderViaApi({ ...testData.order, workflowStatus: 'Open' });

OrderLines.getOrderLineViaApi({ query: `poLineNumber=="*${order.poNumber}*"` }).then(
(orderLines) => {
testData.orderLine = orderLines[0];

Invoices.createInvoiceWithInvoiceLineViaApi({
vendorId: testData.organization.id,
fiscalYearId: testData.fiscalYears.current.id,
poLineId: testData.orderLine.id,
fundDistributions: testData.orderLine.fundDistribution,
accountingCode: testData.organization.erpCode,
releaseEncumbrance: true,
subTotal: 20,
}).then((invoice) => {
testData.invoice = invoice;

Invoices.changeInvoiceStatusViaApi({
invoice: testData.invoice,
status: INVOICE_STATUSES.PAID,
});
});
},
);
},
);
});
});

cy.createTempUser([
Permissions.uiFinanceExecuteFiscalYearRollover.gui,
Permissions.uiFinanceViewFiscalYear.gui,
Permissions.uiFinanceViewFundAndBudget.gui,
Permissions.uiFinanceViewLedger.gui,
]).then((userProperties) => {
testData.user = userProperties;

cy.login(testData.user.username, testData.user.password, {
path: TopMenu.ledgerPath,
waiter: Ledgers.waitForLedgerDetailsLoading,
});
});
});

after('Delete test data', () => {
cy.getAdminToken().then(() => {
Organizations.deleteOrganizationViaApi(testData.organization.id);
Users.deleteViaApi(testData.user.userId);
});
});

it(
'C400643 Rollover based on "Remaining" when order has related paid invoice (thunderjet) (TaaS)',
{ tags: ['extendedPath', 'thunderjet'] },
() => {
// Click on Ledger name link from preconditions
FinanceHelper.searchByName(ledger.name);
const LedgerDetails = Ledgers.selectLedger(ledger.name);
LedgerDetails.checkLedgeDetails({
information: [{ key: 'Current fiscal year', value: fiscalYears.current.code }],
});

// Click "Actions" button, Select "Rollover" option
const LedgerRolloverDetails = LedgerDetails.openLedgerRolloverEditForm();
LedgerRolloverDetails.checkLedgerRolloverDetails({ fiscalYear: fiscalYears.current.code });

// Fill ledger rollover fields
LedgerRolloverDetails.fillLedgerRolloverFields({
fiscalYear: fiscalYears.next.code,
rolloverBudgets: [{ checked: true }],
rolloverEncumbrance: {
ongoing: { checked: true, basedOn: 'Remaining' },
ongoingSubscription: { checked: true, basedOn: 'Remaining' },
oneTime: { checked: true, basedOn: 'Remaining' },
},
});

// Click "Rollover" button, Click "Continue" button, Click "Confirm" button
LedgerRolloverDetails.clickRolloverButton();
LedgerRolloverInProgress.checkLedgerRolloverInProgressDetails();

// Click "Close & view ledger details" button
LedgerRolloverInProgress.clickCloseAndViewLedgerButton();
LedgerDetails.checkLedgeDetails({
information: [{ key: 'Current fiscal year', value: fiscalYears.current.code }],
});

// Click **"Fund A"** record in "Fund" accordion on
const FundDetails = LedgerDetails.openFundDetails({ row: 0 });

// Click budget record in "Planned budget" accordion
const BudgetDetails = FundDetails.openPlannedBudgetDetails();
BudgetDetails.checkBudgetDetails({
information: [{ key: 'Name', value: fiscalYears.next.code }],
});

// Click "View transactions" link in "Budget information" accordion
BudgetDetails.clickViewTransactionsLink();

// Search for "Encumbrance" transaction and click on its "Transaction date" link
Transactions.selectTransaction('Encumbrance');
TransactionDetails.checkTransactionDetails({
information: [
{ key: 'Fiscal year', value: fiscalYears.next.code },
{ key: 'Amount', value: '0.00' },
{ key: 'Source', value: testData.order.poNumber },
{ key: 'Type', value: 'Encumbrance' },
{ key: 'From', value: fund.name },
{ key: 'Initial encumbrance', value: '0.00' },
{ key: 'Awaiting payment', value: '0.00' },
{ key: 'Expended', value: '0.00' },
{ key: 'Status', value: 'Unreleased' },
],
});
},
);
});
});
28 changes: 10 additions & 18 deletions cypress/support/fragments/finance/funds/fundDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
HTML,
KeyValue,
MultiColumnListCell,
MultiColumnListRow,
PaneHeader,
Section,
including,
Expand Down Expand Up @@ -50,24 +49,17 @@ export default {

return AddBudgetModal;
},
openCurrentBudgetDetails() {
cy.do(
currentBudgetSection
.find(MultiColumnListRow({ index: 0 }))
.find(MultiColumnListCell({ columnIndex: 0 }))
.click(),
);
BudgetDetails.waitLoading();

return BudgetDetails;
openCurrentBudgetDetails(index = 0) {
return this.openBudgetDetails({ index, section: currentBudgetSection });
},
openPlannedBudgetDetails(index = 0) {
return this.openBudgetDetails({ index, section: plannedBudgetSection });
},
openPreviousBudgetDetails(index = 0) {
return this.openBudgetDetails({ index, section: previousBudgetsSection });
},
openPreviousBudgetDetails() {
cy.do(
previousBudgetsSection
.find(MultiColumnListRow({ index: 0 }))
.find(MultiColumnListCell({ columnIndex: 0 }))
.click(),
);
openBudgetDetails({ index = 0, section } = {}) {
cy.do(section.find(MultiColumnListCell({ row: index, column: 'Name' })).click());
BudgetDetails.waitLoading();

return BudgetDetails;
Expand Down
2 changes: 2 additions & 0 deletions cypress/support/fragments/finance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ export { default as LedgerRolloverDetails } from './ledgers/ledgerRolloverDetail
export { default as LedgerRolloverInProgress } from './ledgers/ledgerRolloverInProgress';
export { default as LedgerRollovers } from './ledgers/ledgerRollovers';
export { default as Ledgers } from './ledgers/ledgers';
export { default as Transactions } from './transactions/transactions';
export { default as TransactionDetails } from './transactions/transactionDetails';
export { default as Transfers } from './transfer/transfers';
export { default as FinanceHelper } from './financeHelper';
45 changes: 31 additions & 14 deletions cypress/support/fragments/finance/ledgers/ledgerRolloverDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,38 @@ export default {
});
},
setRolloverEncumbranceFields(rolloverEncumbrance) {
if (rolloverEncumbrance.ongoing) {
this.setEncumbranceRowFields({
label: 'Ongoing encumbrances',
encumbrances: rolloverEncumbrance.ongoing,
});
}
if (rolloverEncumbrance.ongoingSubscription) {
this.setEncumbranceRowFields({
label: 'Ongoing-subscription encumbrances',
encumbrances: rolloverEncumbrance.ongoingSubscription,
});
}
if (rolloverEncumbrance.oneTime) {
const fieldItem = encumbrancesDetailsSection.find(
RepeatableFieldItem({ content: including('One-time encumbrances') }),
);
cy.do(fieldItem.find(Checkbox()).click());
cy.wait(300);

if (rolloverEncumbrance.oneTime.basedOn) {
cy.do([
fieldItem.find(Select({ label: including('Based on') })).click(),
fieldItem
.find(Select({ label: including('Based on') }))
.choose(rolloverEncumbrance.oneTime.basedOn),
]);
}
this.setEncumbranceRowFields({
label: 'One-time encumbrances',
encumbrances: rolloverEncumbrance.oneTime,
});
}
},
setEncumbranceRowFields({ label, encumbrances }) {
const fieldItem = encumbrancesDetailsSection.find(
RepeatableFieldItem({ content: including(label) }),
);
cy.do(fieldItem.find(Checkbox()).click());
// wait for fields to become enabled
cy.wait(300);

if (encumbrances.basedOn) {
cy.do([
fieldItem.find(Select({ label: including('Based on') })).click(),
fieldItem.find(Select({ label: including('Based on') })).choose(encumbrances.basedOn),
]);
}
},
clickContinueInConfirmationModal() {
Expand Down

0 comments on commit f863b58

Please sign in to comment.