Astra: coverage of the client's usage (AP payments, approval, AR types and receipts, GL categories), navigation links, form-control field lookup (79a8be7)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- automation/remote_runner/server.py +1 -1
- automation/scripts/check-nav.ts +17 -0
- automation/src/fusion/fixtures.ts +52 -6
- automation/src/fusion/nav.ts +21 -0
- automation/src/fusion/rest.ts +183 -8
- automation/src/fusion/steps.ts +135 -18
- automation/src/fusion/ui.ts +198 -7
- automation/tests/fusion/steps/AP-FUS-020.spec.ts +4 -0
- automation/tests/fusion/steps/AP-FUS-021.spec.ts +4 -0
- automation/tests/fusion/steps/AP-FUS-022.spec.ts +4 -0
- automation/tests/fusion/steps/AP-FUS-023.spec.ts +4 -0
- automation/tests/fusion/steps/AP-FUS-024.spec.ts +4 -0
- automation/tests/fusion/steps/AP-FUS-025.spec.ts +4 -0
- automation/tests/fusion/steps/AP-FUS-026.spec.ts +4 -0
- automation/tests/fusion/steps/AP-FUS-027.spec.ts +4 -0
- automation/tests/fusion/steps/AR-FUS-001.spec.ts +4 -0
- automation/tests/fusion/steps/AR-FUS-002.spec.ts +4 -0
- automation/tests/fusion/steps/AR-FUS-003.spec.ts +4 -0
- automation/tests/fusion/steps/AR-FUS-004.spec.ts +4 -0
- automation/tests/fusion/steps/AR-FUS-005.spec.ts +4 -0
- automation/tests/fusion/steps/AR-FUS-006.spec.ts +4 -0
- automation/tests/fusion/steps/GL-FUS-002.spec.ts +4 -0
- automation/tests/fusion/steps/GL-FUS-003.spec.ts +4 -0
- automation/tests/fusion/steps/GL-FUS-004.spec.ts +4 -0
- automation/tests/fusion/steps/GL-FUS-005.spec.ts +4 -0
- coworker/adapters/remote_runner.py +1 -1
- coworker/api/routes/pods.py +21 -1
- coworker/api/schemas.py +10 -0
- coworker/llm/prompts/write_steps.md +3 -0
- coworker/llm/schemas.py +7 -0
- coworker/platform/cleanup.py +49 -2
- coworker/platform/left_on_pod.py +17 -1
- coworker/platform/migrations/031_pod_nav_links.sql +4 -0
- coworker/platform/pods.py +45 -1
- coworker/platform/step_writer.py +218 -21
- coworker/platform/usage.py +42 -10
- coworker/tests/test_cov_ap_pay.py +162 -0
- coworker/tests/test_cov_ar.py +204 -0
- coworker/tests/test_cov_final.py +229 -0
- coworker/tests/test_cov_gl.py +136 -0
- coworker/tests/test_nav_links.py +99 -0
- tests/cases/AP-FUS-020.yaml +65 -0
- tests/cases/AP-FUS-021.yaml +65 -0
- tests/cases/AP-FUS-022.yaml +65 -0
- tests/cases/AP-FUS-023.yaml +58 -0
- tests/cases/AP-FUS-024.yaml +47 -0
- tests/cases/AP-FUS-025.yaml +47 -0
- tests/cases/AP-FUS-026.yaml +60 -0
- tests/cases/AP-FUS-027.yaml +57 -0
- tests/cases/AR-FUS-001.yaml +52 -0
automation/remote_runner/server.py
CHANGED
|
@@ -55,7 +55,7 @@ CASES = AUTOMATION.parent / "tests" / "cases"
|
|
| 55 |
VERSION_FILE = AUTOMATION.parent / "VERSION"
|
| 56 |
CONFIGS = {"playwright.fusion.config.ts", "playwright.agent.config.ts"}
|
| 57 |
ENV_KEYS = {"FUSION_BASE_URL", "FUSION_USERNAME", "FUSION_PASSWORD", "FUSION_TESTDATA", "FUSION_TESTDATA_CANDIDATES",
|
| 58 |
-
"FPT_FUSION_WORKERS", "PW_LOCATOR_OVERRIDES", "FPT_BROWSER_SLOWMO_MS", "FPT_SIGN_IN_MODE", "FPT_HEALS"}
|
| 59 |
SESSION_STATE = "sign-in-state.json" # an attempt's signed-in session (assisted sign-in), in its job folder while it runs
|
| 60 |
SPEC = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]{0,120}\.spec\.ts$")
|
| 61 |
ID = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._:-]{0,80}$")
|
|
|
|
| 55 |
VERSION_FILE = AUTOMATION.parent / "VERSION"
|
| 56 |
CONFIGS = {"playwright.fusion.config.ts", "playwright.agent.config.ts"}
|
| 57 |
ENV_KEYS = {"FUSION_BASE_URL", "FUSION_USERNAME", "FUSION_PASSWORD", "FUSION_TESTDATA", "FUSION_TESTDATA_CANDIDATES",
|
| 58 |
+
"FPT_FUSION_WORKERS", "PW_LOCATOR_OVERRIDES", "FPT_BROWSER_SLOWMO_MS", "FPT_SIGN_IN_MODE", "FPT_HEALS", "FPT_NAV_LINKS"}
|
| 59 |
SESSION_STATE = "sign-in-state.json" # an attempt's signed-in session (assisted sign-in), in its job folder while it runs
|
| 60 |
SPEC = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]{0,120}\.spec\.ts$")
|
| 61 |
ID = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._:-]{0,80}$")
|
automation/scripts/check-nav.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Checks the navigation-link parsing and matching (src/fusion/nav.ts) without a browser: `npx tsx scripts/check-nav.ts`. */
|
| 2 |
+
import assert from 'node:assert/strict';
|
| 3 |
+
import { navLink, parseNavLinks } from '../src/fusion/nav';
|
| 4 |
+
|
| 5 |
+
const url = 'https://pod.fa.ocs.oraclecloud.com/fscmUI/faces/FuseOverview?fndGlobalItemNodeId=itemNode_procurement_purchase_orders';
|
| 6 |
+
const links = parseNavLinks(JSON.stringify({ 'Procurement > Purchase Orders': url, 'Payables > Invoices': 'http://x/fscmUI/a', 'nogroup': url, 'A > B': 5 }));
|
| 7 |
+
assert.deepEqual(Object.keys(links), ['Procurement > Purchase Orders']); // http, no "A > B" form and non-strings dropped
|
| 8 |
+
assert.equal(navLink(links, 'Procurement', 'Purchase Orders'), url);
|
| 9 |
+
assert.equal(navLink(links, ' procurement ', 'PURCHASE orders'), url); // case and spacing do not matter
|
| 10 |
+
assert.equal(navLink(links, 'Procurement', 'Purchase Order'), null); // no guessing
|
| 11 |
+
assert.equal(navLink(links, 'Payables', 'Invoices'), null);
|
| 12 |
+
// bad input is ignored
|
| 13 |
+
assert.deepEqual(parseNavLinks(undefined), {});
|
| 14 |
+
assert.deepEqual(parseNavLinks('not json'), {});
|
| 15 |
+
assert.deepEqual(parseNavLinks('[1,2]'), {});
|
| 16 |
+
assert.deepEqual(parseNavLinks('null'), {});
|
| 17 |
+
console.log('nav: all checks pass');
|
automation/src/fusion/fixtures.ts
CHANGED
|
@@ -17,19 +17,54 @@ export interface ApInvoices {
|
|
| 17 |
/** The Purchasing, General Ledger and Receivables test documents a test creates, by the reference registered BEFORE the save (the
|
| 18 |
* test's FPT- tag in a requisition's or an order's Description, a journal batch's name, a transaction's Comments, a receipt's number): Fusion gives a requisition
|
| 19 |
* or an order its number only when it is saved. */
|
| 20 |
-
export type DocKind = 'po_requisition' | 'po_order' | 'po_receipt' | 'gl_journal' | 'ar_transaction' | 'ar_receipt';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
export interface FusionDocs {
|
| 22 |
/** Register a test document BEFORE saving it, so it is cleaned up even if the test fails half-way. A receipt of an order
|
| 23 |
* names that order's tag (`order`): the order is left for a person too while its receipt is. */
|
| 24 |
track(kind: DocKind, ref: string, order?: string): string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
/** Clean-up of one test document over REST (rest.ts): a requisition or order cancelled or deleted, a journal deleted
|
| 28 |
* while unposted, an incomplete transaction deleted (a completed one or a receipt is left for a person). What REST cannot do (a submitted requisition, an order pending approval) is done on the screens
|
| 29 |
* with the business action's own steps, then REST is asked again. */
|
| 30 |
-
async function cleanDoc(rest: FusionRest, ui: FusionUi, kind: DocKind, ref: string, received = false): Promise<string> {
|
|
|
|
| 31 |
const clean = () => (kind === 'po_requisition' ? rest.cleanRequisition(ref) : kind === 'po_order' ? rest.cleanPurchaseOrder(ref, received)
|
| 32 |
-
: kind === 'po_receipt' ? rest.cleanPoReceipt(ref)
|
| 33 |
: kind === 'ar_transaction' ? rest.cleanTransaction(ref) : kind === 'ar_receipt' ? rest.cleanReceipt(ref) : rest.cleanJournal(ref));
|
| 34 |
try {
|
| 35 |
return await clean();
|
|
@@ -37,6 +72,7 @@ async function cleanDoc(rest: FusionRest, ui: FusionUi, kind: DocKind, ref: stri
|
|
| 37 |
if (!(e instanceof NeedsScreen)) throw e;
|
| 38 |
if (kind === 'po_requisition') await ui.cancelRequisition(ref);
|
| 39 |
else if (kind === 'po_order') await ui.cancelPurchaseOrder(ref);
|
|
|
|
| 40 |
else throw e;
|
| 41 |
return `${await clean()} (on the screens: ${e.message})`;
|
| 42 |
}
|
|
@@ -94,7 +130,12 @@ export const test = base.extend<{ fusion: FusionUi; apInvoices: ApInvoices; fusi
|
|
| 94 |
const done = await rest.cancelIfPresent(n, d.businessUnit, d.supplier);
|
| 95 |
testInfo.annotations.push({ type: 'cleanup', description: done });
|
| 96 |
ledger({ kind: 'ap_invoice', number: n, cleaned: done });
|
| 97 |
-
} catch (e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
}
|
| 99 |
if (errors.length) throw new Error(`Clean-up failed, test data may be left on the pod: ${errors.join('; ')}`);
|
| 100 |
},
|
|
@@ -102,11 +143,16 @@ export const test = base.extend<{ fusion: FusionUi; apInvoices: ApInvoices; fusi
|
|
| 102 |
// it is torn down before the page (it depends on `fusion`).
|
| 103 |
fusionDocs: async ({ fusion }, use, testInfo) => {
|
| 104 |
const docs: [DocKind, string, string?][] = [];
|
|
|
|
| 105 |
await use({
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
track: (kind, ref, order) => {
|
| 107 |
if (!docs.some(([k, r]) => k === kind && r === ref)) {
|
| 108 |
ledger({ kind, number: ref, by: kind === 'gl_journal' ? 'name' : kind === 'ar_receipt' ? 'receipt number' : kind === 'ar_transaction' ? 'comments'
|
| 109 |
-
: kind === 'po_receipt' ? 'packing slip' : 'description', order, test: testInfo.title });
|
| 110 |
docs.push([kind, ref, order]);
|
| 111 |
}
|
| 112 |
return ref;
|
|
@@ -123,7 +169,7 @@ export const test = base.extend<{ fusion: FusionUi; apInvoices: ApInvoices; fusi
|
|
| 123 |
// the newest first: an order made from a requisition goes before the requisition, a receipt before its order
|
| 124 |
for (const [kind, ref, order] of [...docs].reverse()) {
|
| 125 |
try {
|
| 126 |
-
const done = await cleanDoc(rest, fusion, kind, ref, received.has(ref));
|
| 127 |
testInfo.annotations.push({ type: 'cleanup', description: done });
|
| 128 |
ledger({ kind, number: ref, cleaned: done });
|
| 129 |
} catch (e) {
|
|
|
|
| 17 |
/** The Purchasing, General Ledger and Receivables test documents a test creates, by the reference registered BEFORE the save (the
|
| 18 |
* test's FPT- tag in a requisition's or an order's Description, a journal batch's name, a transaction's Comments, a receipt's number): Fusion gives a requisition
|
| 19 |
* or an order its number only when it is saved. */
|
| 20 |
+
export type DocKind = 'po_requisition' | 'po_order' | 'po_receipt' | 'gl_journal' | 'ar_transaction' | 'ar_receipt' | 'ap_payment' | 'ap_approval';
|
| 21 |
+
/** A test payment is registered as "<invoice number>-PAY" (kind ap_payment) before the invoice is paid; its own number is
|
| 22 |
+
* noted once Fusion has made it, so clean-up voids that payment before the invoice is cancelled. */
|
| 23 |
+
export const paymentRef = (invoice: string) => `${invoice}-PAY`;
|
| 24 |
+
/** An invoice a test sends for approval is registered as "<invoice number>-APR" (kind ap_approval) before it is sent: the clean-up
|
| 25 |
+
* withdraws the approval on the screens before the invoice is cancelled (Fusion does not cancel one in approval). */
|
| 26 |
+
export const approvalRef = (invoice: string) => `${invoice}-APR`;
|
| 27 |
export interface FusionDocs {
|
| 28 |
/** Register a test document BEFORE saving it, so it is cleaned up even if the test fails half-way. A receipt of an order
|
| 29 |
* names that order's tag (`order`): the order is left for a person too while its receipt is. */
|
| 30 |
track(kind: DocKind, ref: string, order?: string): string;
|
| 31 |
+
/** The number of the payment registered as `ref` (kind ap_payment), once Fusion made it. */
|
| 32 |
+
payment(ref: string, number: string): void;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/** Clean-up of an invoice sent for approval: the approval is withdrawn on the screens when it is under way. Fusion not offering the
|
| 36 |
+
* withdraw, or not showing the approval withdrawn, is no failure of the test: it is left for a person, with what to do. */
|
| 37 |
+
async function cleanApproval(rest: FusionRest, ui: FusionUi, ref: string): Promise<string> {
|
| 38 |
+
const invoice = ref.replace(/-APR$/, '');
|
| 39 |
+
const todo = 'withdraw the approval on Payables > Invoices > Manage Invoices (Invoice Actions > Approval > Withdraw), then cancel the invoice';
|
| 40 |
+
try {
|
| 41 |
+
return await rest.cleanApproval(invoice);
|
| 42 |
+
} catch (e) {
|
| 43 |
+
if (!(e instanceof NeedsScreen)) throw e;
|
| 44 |
+
try {
|
| 45 |
+
await ui.withdrawApproval(invoice);
|
| 46 |
+
} catch (w) {
|
| 47 |
+
throw new LeftForPerson(`invoice ${invoice} is in approval and Fusion's screens did not withdraw it (${String((w as Error).message || w).split('\n')[0].slice(0, 200)}): ${todo}`);
|
| 48 |
+
}
|
| 49 |
+
for (let i = 0; i < 12; i++) { // the withdrawal is a workflow: it takes a moment to show
|
| 50 |
+
try {
|
| 51 |
+
return `${await rest.cleanApproval(invoice)} (on the screens: ${e.message})`;
|
| 52 |
+
} catch (x) {
|
| 53 |
+
if (!(x instanceof NeedsScreen)) throw x;
|
| 54 |
+
await new Promise((r) => setTimeout(r, 5_000));
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
throw new LeftForPerson(`invoice ${invoice} is still in approval after Withdraw: ${todo}`);
|
| 58 |
+
}
|
| 59 |
}
|
| 60 |
|
| 61 |
/** Clean-up of one test document over REST (rest.ts): a requisition or order cancelled or deleted, a journal deleted
|
| 62 |
* while unposted, an incomplete transaction deleted (a completed one or a receipt is left for a person). What REST cannot do (a submitted requisition, an order pending approval) is done on the screens
|
| 63 |
* with the business action's own steps, then REST is asked again. */
|
| 64 |
+
async function cleanDoc(rest: FusionRest, ui: FusionUi, kind: DocKind, ref: string, received = false, payment = ''): Promise<string> {
|
| 65 |
+
if (kind === 'ap_approval') return cleanApproval(rest, ui, ref);
|
| 66 |
const clean = () => (kind === 'po_requisition' ? rest.cleanRequisition(ref) : kind === 'po_order' ? rest.cleanPurchaseOrder(ref, received)
|
| 67 |
+
: kind === 'po_receipt' ? rest.cleanPoReceipt(ref) : kind === 'ap_payment' ? rest.cleanPayment(ref.replace(/-PAY$/, ''), payment || undefined)
|
| 68 |
: kind === 'ar_transaction' ? rest.cleanTransaction(ref) : kind === 'ar_receipt' ? rest.cleanReceipt(ref) : rest.cleanJournal(ref));
|
| 69 |
try {
|
| 70 |
return await clean();
|
|
|
|
| 72 |
if (!(e instanceof NeedsScreen)) throw e;
|
| 73 |
if (kind === 'po_requisition') await ui.cancelRequisition(ref);
|
| 74 |
else if (kind === 'po_order') await ui.cancelPurchaseOrder(ref);
|
| 75 |
+
else if (kind === 'ap_payment' && payment) await ui.voidPayment(payment);
|
| 76 |
else throw e;
|
| 77 |
return `${await clean()} (on the screens: ${e.message})`;
|
| 78 |
}
|
|
|
|
| 130 |
const done = await rest.cancelIfPresent(n, d.businessUnit, d.supplier);
|
| 131 |
testInfo.annotations.push({ type: 'cleanup', description: done });
|
| 132 |
ledger({ kind: 'ap_invoice', number: n, cleaned: done });
|
| 133 |
+
} catch (e) {
|
| 134 |
+
if (e instanceof LeftForPerson) { // an invoice still in approval: not a failure of the test, the run's test data lists it
|
| 135 |
+
testInfo.annotations.push({ type: 'cleanup', description: `left for a person: ${e.message}` });
|
| 136 |
+
ledger({ kind: 'ap_invoice', number: n, left: e.message });
|
| 137 |
+
} else errors.push(String((e as Error).message || e));
|
| 138 |
+
}
|
| 139 |
}
|
| 140 |
if (errors.length) throw new Error(`Clean-up failed, test data may be left on the pod: ${errors.join('; ')}`);
|
| 141 |
},
|
|
|
|
| 143 |
// it is torn down before the page (it depends on `fusion`).
|
| 144 |
fusionDocs: async ({ fusion }, use, testInfo) => {
|
| 145 |
const docs: [DocKind, string, string?][] = [];
|
| 146 |
+
const payments: Record<string, string> = {}; // payment number by the ref it was registered under
|
| 147 |
await use({
|
| 148 |
+
payment: (ref, number) => {
|
| 149 |
+
payments[ref] = number;
|
| 150 |
+
ledger({ kind: 'ap_payment', number: ref, payment: number });
|
| 151 |
+
},
|
| 152 |
track: (kind, ref, order) => {
|
| 153 |
if (!docs.some(([k, r]) => k === kind && r === ref)) {
|
| 154 |
ledger({ kind, number: ref, by: kind === 'gl_journal' ? 'name' : kind === 'ar_receipt' ? 'receipt number' : kind === 'ar_transaction' ? 'comments'
|
| 155 |
+
: kind === 'po_receipt' ? 'packing slip' : kind === 'ap_payment' || kind === 'ap_approval' ? 'invoice number' : 'description', order, test: testInfo.title });
|
| 156 |
docs.push([kind, ref, order]);
|
| 157 |
}
|
| 158 |
return ref;
|
|
|
|
| 169 |
// the newest first: an order made from a requisition goes before the requisition, a receipt before its order
|
| 170 |
for (const [kind, ref, order] of [...docs].reverse()) {
|
| 171 |
try {
|
| 172 |
+
const done = await cleanDoc(rest, fusion, kind, ref, received.has(ref), payments[ref]);
|
| 173 |
testInfo.annotations.push({ type: 'cleanup', description: done });
|
| 174 |
ledger({ kind, number: ref, cleaned: done });
|
| 175 |
} catch (e) {
|
automation/src/fusion/nav.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** Per-pod navigation links (FPT_NAV_LINKS, set by the co-worker): the address of a work area a consultant opened by hand,
|
| 2 |
+
* for pods whose menus do not show it to the test user. Pure, so a script can check it without a browser. */
|
| 3 |
+
|
| 4 |
+
const key = (s: string) => s.split('>').map((p) => p.replace(/\s+/g, ' ').trim().toLowerCase()).join('>');
|
| 5 |
+
|
| 6 |
+
/** The run's links, {"Group > Page": address}; anything malformed is ignored, never an error. */
|
| 7 |
+
export function parseNavLinks(raw: string | undefined): Record<string, string> {
|
| 8 |
+
if (!raw) return {};
|
| 9 |
+
try {
|
| 10 |
+
const o = JSON.parse(raw);
|
| 11 |
+
if (!o || typeof o !== 'object' || Array.isArray(o)) return {};
|
| 12 |
+
return Object.fromEntries(Object.entries(o).filter(([k, v]) => k.includes('>') && typeof v === 'string' && /^https:\/\//i.test(v)) as [string, string][]);
|
| 13 |
+
} catch { return {}; }
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
/** The address saved for "group > page" (case and spacing do not matter), or null. */
|
| 17 |
+
export function navLink(links: Record<string, string>, group: string, page: string): string | null {
|
| 18 |
+
const want = key(`${group} > ${page}`);
|
| 19 |
+
const hit = Object.keys(links).find((k) => key(k) === want);
|
| 20 |
+
return hit ? links[hit] : null;
|
| 21 |
+
}
|
automation/src/fusion/rest.ts
CHANGED
|
@@ -58,7 +58,7 @@ const q = (s: string) => s.replace(/'/g, "''");
|
|
| 58 |
|
| 59 |
/** What a step expects of an invoice in Fusion (business action expect_invoice). */
|
| 60 |
export interface InvoiceExpectation { status?: string; amount?: number; amountAtLeast?: number; canceled?: boolean; type?: string;
|
| 61 |
-
paymentMethod?: string }
|
| 62 |
|
| 63 |
/** A status as the page and REST both mean it: case, spacing and the British "Cancelled" do not matter. */
|
| 64 |
const spelling = (s: string) => s.trim().toLowerCase().replace(/\s+/g, ' ').replace('cancelled', 'canceled');
|
|
@@ -109,12 +109,80 @@ export function invoiceProblems(number: string, inv: Invoice | null, want: Invoi
|
|
| 109 |
out.push(`its payment method is "${has[0] ?? ''}", expected "${want.paymentMethod}"`);
|
| 110 |
}
|
| 111 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
return out;
|
| 113 |
}
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
/** The holds still on the invoice: a released hold carries the name of its release. */
|
| 116 |
export const activeHolds = (holds: InvoiceHold[]) => holds.filter((h) => !h.ReleaseName);
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
/*
|
| 119 |
* Purchasing and General Ledger. Every test document carries the test's own FPT- tag where Fusion keeps a free text
|
| 120 |
* (a requisition's and an order's Description, a journal batch's name): the number Fusion gives a requisition or an
|
|
@@ -129,7 +197,8 @@ export interface JournalBatch { JeBatchId: number; BatchName: string; Status?: s
|
|
| 129 |
|
| 130 |
/** What a step expects of a requisition, an order or a journal batch (expect_requisition, expect_purchase_order,
|
| 131 |
* expect_journal). */
|
| 132 |
-
export interface DocExpectation { status?: string; amount?: number; amountAtLeast?: number; canceled?: boolean; posted?: boolean
|
|
|
|
| 133 |
|
| 134 |
/** A requisition's status in words (DocumentStatus; the code when a pod returns only that). */
|
| 135 |
export const requisitionStatus = (r: Requisition) => String(r.DocumentStatus || r.DocumentStatusCode || '').trim();
|
|
@@ -204,9 +273,31 @@ export function purchaseOrderProblems(number: string, o: PurchaseOrder | null, w
|
|
| 204 |
return docProblems(`purchase order ${number}`, orderStatus(o), orderAmount(o), undefined, want);
|
| 205 |
}
|
| 206 |
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
if (!b) return [`journal batch ${name} is not in Fusion`];
|
| 209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
}
|
| 211 |
|
| 212 |
/*
|
|
@@ -247,9 +338,36 @@ export function receiptState(r: ArReceipt): string {
|
|
| 247 |
return open < 0.005 ? 'Applied' : open >= total - 0.005 ? 'Unapplied' : 'Partially applied';
|
| 248 |
}
|
| 249 |
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
if (!t) return [`transaction ${number} is not in Fusion`];
|
| 252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
}
|
| 254 |
|
| 255 |
export function receiptProblems(number: string, r: ArReceipt | null, want: DocExpectation): string[] {
|
|
@@ -343,8 +461,8 @@ export class FusionRest {
|
|
| 343 |
return { status: res.status, text: await res.text() };
|
| 344 |
}
|
| 345 |
|
| 346 |
-
private async get<T>(resource: string, query: string): Promise<T[]> {
|
| 347 |
-
const params = new URLSearchParams({ q: query, onlyData: 'true', limit: '100' });
|
| 348 |
const r = await this.call('GET', `${resource}?${params}`);
|
| 349 |
if (r.status !== 200) throw new Error(`GET ${resource} failed: HTTP ${r.status} ${r.text.slice(0, 300)}`);
|
| 350 |
return (JSON.parse(r.text).items || []) as T[];
|
|
@@ -368,6 +486,24 @@ export class FusionRest {
|
|
| 368 |
return this.get<InvoiceHold>('invoiceHolds', `InvoiceNumber='${q(number)}'`);
|
| 369 |
}
|
| 370 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
/** Run an invoice action (validateInvoice, cancelInvoice, ...) the way Fusion's REST service offers it. */
|
| 372 |
async invoiceAction(action: string, body: Record<string, unknown>): Promise<string> {
|
| 373 |
const r = await this.call('POST', `invoices/action/${action}`, body, 'application/vnd.oracle.adf.action+json');
|
|
@@ -381,12 +517,42 @@ export class FusionRest {
|
|
| 381 |
const inv = await this.invoice(number, supplier) ?? await this.invoiceByNumber(number);
|
| 382 |
if (!inv) return `${number}: not saved, nothing to clean up`;
|
| 383 |
if (inv.CanceledFlag) return `${number}: already cancelled`;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
await this.invoiceAction('cancelInvoice', { InvoiceNumber: number, BusinessUnit: inv.BusinessUnit || businessUnit, Supplier: inv.Supplier || supplier });
|
| 385 |
const after = await this.invoice(number, inv.Supplier || supplier);
|
| 386 |
if (!after?.CanceledFlag) throw new Error(`${number}: cancelInvoice reported success but the invoice is not cancelled`);
|
| 387 |
return `${number}: cancelled by clean-up`;
|
| 388 |
}
|
| 389 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
/** The first item of a resource matching `query`, or null. A query the resource refuses (an attribute this pod does not
|
| 391 |
* have: HTTP 400) answers null, so the caller's next way of finding it is tried. */
|
| 392 |
private async first<T>(resource: string, query: string): Promise<T | null> {
|
|
@@ -417,6 +583,15 @@ export class FusionRest {
|
|
| 417 |
return this.first<JournalBatch>('journalBatches', `BatchName='${q(name)}'`);
|
| 418 |
}
|
| 419 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 420 |
/** The batches whose name holds the test's batch name: the batch itself and the reversal Fusion makes of it (Fusion
|
| 421 |
* names a reversal after the batch it reverses). Null when this pod refuses the LIKE query. */
|
| 422 |
async journalBatchesNamed(name: string): Promise<JournalBatch[] | null> {
|
|
|
|
| 58 |
|
| 59 |
/** What a step expects of an invoice in Fusion (business action expect_invoice). */
|
| 60 |
export interface InvoiceExpectation { status?: string; amount?: number; amountAtLeast?: number; canceled?: boolean; type?: string;
|
| 61 |
+
paymentMethod?: string; approvalStatus?: string; validationStatus?: string }
|
| 62 |
|
| 63 |
/** A status as the page and REST both mean it: case, spacing and the British "Cancelled" do not matter. */
|
| 64 |
const spelling = (s: string) => s.trim().toLowerCase().replace(/\s+/g, ' ').replace('cancelled', 'canceled');
|
|
|
|
| 109 |
out.push(`its payment method is "${has[0] ?? ''}", expected "${want.paymentMethod}"`);
|
| 110 |
}
|
| 111 |
}
|
| 112 |
+
if (want.approvalStatus) { // "Not required" / "Required" ...: where this pod's REST returns the approval status
|
| 113 |
+
const got = invoiceApprovalStatus(inv);
|
| 114 |
+
if (!got) out.push(`this pod's REST does not return the invoice's approval status, so "${want.approvalStatus}" cannot be checked`);
|
| 115 |
+
else if (codeKey(got) !== codeKey(want.approvalStatus)) out.push(`its approval status is "${got}", expected "${want.approvalStatus}"`);
|
| 116 |
+
}
|
| 117 |
+
if (want.validationStatus && validationKey(String(inv.ValidationStatus ?? '')) !== validationKey(want.validationStatus)
|
| 118 |
+
&& !(validationKey(want.validationStatus) === 'canceled' && inv.CanceledFlag)) {
|
| 119 |
+
out.push(`its validation status is "${inv.ValidationStatus ?? ''}", expected "${want.validationStatus}"`);
|
| 120 |
+
}
|
| 121 |
return out;
|
| 122 |
}
|
| 123 |
|
| 124 |
+
/** A status in the words of a code or a meaning: "NOT REQUIRED", "Not_required" and "not required" are one status. */
|
| 125 |
+
const codeKey = (s: string) => spelling(String(s ?? '').replace(/_/g, ' '));
|
| 126 |
+
|
| 127 |
+
/** The invoice's approval status as this pod's REST returns it ("Not required", "Required", "Approved" ...): the first of the
|
| 128 |
+
* attributes releases use for it that holds a value ('' when the pod exposes none: it then cannot be checked). */
|
| 129 |
+
export const invoiceApprovalStatus = (inv: Invoice): string => String([inv.ApprovalStatus, inv.WFapprovalStatus, inv.ApprovalStatusMeaning]
|
| 130 |
+
.find((v) => v !== undefined && v !== null && v !== '') ?? '').trim();
|
| 131 |
+
|
| 132 |
+
/** What a validation status is called by the client ("Not validated") and by REST on an invoice nobody validated yet
|
| 133 |
+
* ("Never validated" in Oracle's own lookup): one status for a saved invoice that was not validated. */
|
| 134 |
+
const validationKey = (s: string) => { const k = codeKey(s); return k === 'never validated' ? 'not validated' : k; };
|
| 135 |
+
|
| 136 |
+
/** Whether the invoice's approval is under way (Initiated, or "In process" / "Pending" where a release says so): such an invoice
|
| 137 |
+
* cannot be cancelled until the approval is withdrawn. */
|
| 138 |
+
export const invoiceInApproval = (inv: Invoice): boolean => /^(initiated|in process|in progress|pending|pending approval)$/.test(codeKey(invoiceApprovalStatus(inv)));
|
| 139 |
+
|
| 140 |
+
/** Whether the invoice has been paid, wholly or in part (its payment status): a paid invoice cannot be cancelled until its
|
| 141 |
+
* payment is voided. */
|
| 142 |
+
export const invoiceIsPaid = (inv: Invoice): boolean => /^(paid|partially paid|y|p)$/.test(codeKey(String(inv.PaymentStatus ?? inv.PaymentStatusCode ?? '')));
|
| 143 |
+
|
| 144 |
/** The holds still on the invoice: a released hold carries the name of its release. */
|
| 145 |
export const activeHolds = (holds: InvoiceHold[]) => holds.filter((h) => !h.ReleaseName);
|
| 146 |
|
| 147 |
+
/*
|
| 148 |
+
* Payables payments (payablesPayments): a quick payment of one test invoice (create_payment), checked and voided by its
|
| 149 |
+
* payment number. Attribute names are the documented ones of 11.13.18.05 as far as known; where releases differ several are
|
| 150 |
+
* read, and every guess is listed in the report of the change that added them (verify them on the pod).
|
| 151 |
+
*/
|
| 152 |
+
export interface Payment { PaymentId: number; PaymentNumber: number | string; PaymentAmount?: number; PaymentMethod?: string; PaymentMethodCode?: string;
|
| 153 |
+
PaymentType?: string; PaymentStatus?: string; [k: string]: unknown }
|
| 154 |
+
export interface PaymentExpectation { status?: string; amount?: number; amountAtLeast?: number; method?: string; type?: string }
|
| 155 |
+
|
| 156 |
+
/** A payment's status in words ("Negotiable", "Voided" ...; the code when a pod returns only that). */
|
| 157 |
+
export const paymentStatus = (p: Payment) => String(p.PaymentStatus || p.PaymentStatusCode || p.Status || '').trim();
|
| 158 |
+
|
| 159 |
+
/** A payment type as the step and REST both mean it: "Quick", "QUICK" and "Quick payment" are one type; Payment Process Request
|
| 160 |
+
* is also written "PPR" or "Payment Process Requests". */
|
| 161 |
+
export function paymentTypeKey(t: string): string {
|
| 162 |
+
const s = codeKey(String(t ?? ''));
|
| 163 |
+
return /^quick( payments?)?$/.test(s) ? 'quick' : /^manual( payments?)?$/.test(s) ? 'manual' : /^refunds?$/.test(s) ? 'refund'
|
| 164 |
+
: /^(ppr|payment process requests?)$/.test(s) ? 'payment process request' : s;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
/** The payment's amount (NaN when it carries none). */
|
| 168 |
+
export const paymentAmount = (p: Payment) => Number(firstOf(p, ['PaymentAmount', 'Amount', 'PaidAmount']) ?? NaN);
|
| 169 |
+
|
| 170 |
+
/** Every way a payment differs from what is expected, in words (empty: as expected). */
|
| 171 |
+
export function paymentProblems(ref: string, p: Payment | null, want: PaymentExpectation): string[] {
|
| 172 |
+
if (!p) return [`payment ${ref} is not in Fusion`];
|
| 173 |
+
const out = docProblems(`payment ${ref}`, paymentStatus(p), paymentAmount(p), undefined, want);
|
| 174 |
+
const typeGot = String(p.PaymentType ?? p.PaymentTypeCode ?? '').trim();
|
| 175 |
+
if (want.type && paymentTypeKey(typeGot) !== paymentTypeKey(want.type)) out.push(`payment ${ref}: its type is "${typeGot}", expected "${want.type}"`);
|
| 176 |
+
if (want.method) { // the method's name or its code, whichever this release returns
|
| 177 |
+
const has = [p.PaymentMethod, p.PaymentMethodCode, p.PaymentMethodName].filter((v) => v !== undefined && v !== null && v !== '').map(String);
|
| 178 |
+
if (!has.some((m) => spelling(m) === spelling(want.method!))) out.push(`payment ${ref}: its payment method is "${has[0] ?? ''}", expected "${want.method}"`);
|
| 179 |
+
}
|
| 180 |
+
return out;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
/** A payment that is out of the way: voided (or stopped by the bank, which a clean-up cannot undo but leaves nothing to void). */
|
| 184 |
+
export const paymentVoided = (p: Payment) => statusKey(paymentStatus(p)) === 'voided';
|
| 185 |
+
|
| 186 |
/*
|
| 187 |
* Purchasing and General Ledger. Every test document carries the test's own FPT- tag where Fusion keeps a free text
|
| 188 |
* (a requisition's and an order's Description, a journal batch's name): the number Fusion gives a requisition or an
|
|
|
|
| 197 |
|
| 198 |
/** What a step expects of a requisition, an order or a journal batch (expect_requisition, expect_purchase_order,
|
| 199 |
* expect_journal). */
|
| 200 |
+
export interface DocExpectation { status?: string; amount?: number; amountAtLeast?: number; canceled?: boolean; posted?: boolean;
|
| 201 |
+
category?: string; source?: string }
|
| 202 |
|
| 203 |
/** A requisition's status in words (DocumentStatus; the code when a pod returns only that). */
|
| 204 |
export const requisitionStatus = (r: Requisition) => String(r.DocumentStatus || r.DocumentStatusCode || '').trim();
|
|
|
|
| 273 |
return docProblems(`purchase order ${number}`, orderStatus(o), orderAmount(o), undefined, want);
|
| 274 |
}
|
| 275 |
|
| 276 |
+
/** The attributes a pod may keep a journal's category and source in (journalHeaders carries the category, a batch or its
|
| 277 |
+
* journals the source); the names are those of usage.py's GL read. */
|
| 278 |
+
const JOURNAL_CATEGORY_ATTRS = ['JournalCategory', 'UserJeCategoryName', 'CategoryName', 'Category'];
|
| 279 |
+
const JOURNAL_SOURCE_ATTRS = ['JournalSource', 'UserJeSourceName', 'SourceName', 'Source'];
|
| 280 |
+
|
| 281 |
+
/** A journal's category or source as Fusion shows it: the first of `attrs` that holds a value on the batch or on one of its
|
| 282 |
+
* journals; '' when the pod returns none of them. */
|
| 283 |
+
export function journalAttribute(b: JournalBatch, headers: Record<string, unknown>[], attrs: string[]): string {
|
| 284 |
+
for (const row of [b as Record<string, unknown>, ...headers]) {
|
| 285 |
+
const v = attrs.map((k) => row[k]).find((x) => x !== undefined && x !== null && String(x).trim() !== '');
|
| 286 |
+
if (v !== undefined) return String(v).trim();
|
| 287 |
+
}
|
| 288 |
+
return '';
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
export function journalProblems(name: string, b: JournalBatch | null, want: DocExpectation, headers: Record<string, unknown>[] = []): string[] {
|
| 292 |
if (!b) return [`journal batch ${name} is not in Fusion`];
|
| 293 |
+
const out = docProblems(`journal batch ${name}`, journalStatus(b), NaN, journalPosted(b), want);
|
| 294 |
+
for (const [what, wanted, attrs] of [['category', want.category, JOURNAL_CATEGORY_ATTRS], ['source', want.source, JOURNAL_SOURCE_ATTRS]] as const) {
|
| 295 |
+
if (!wanted) continue;
|
| 296 |
+
const shown = journalAttribute(b, headers, [...attrs]);
|
| 297 |
+
if (!shown) out.push(`journal batch ${name}: Fusion's REST gives no ${what} for it (cannot check it is "${wanted}")`);
|
| 298 |
+
else if (spelling(shown) !== spelling(wanted)) out.push(`journal batch ${name}: its ${what} is "${shown}", expected "${wanted}"`);
|
| 299 |
+
}
|
| 300 |
+
return out;
|
| 301 |
}
|
| 302 |
|
| 303 |
/*
|
|
|
|
| 338 |
return open < 0.005 ? 'Applied' : open >= total - 0.005 ? 'Unapplied' : 'Partially applied';
|
| 339 |
}
|
| 340 |
|
| 341 |
+
/** What a step expects of a transaction: the document's own expectations, its type (Invoice, Credit Memo, Debit Memo or the
|
| 342 |
+
* pod's own) and its source (Manual or the pod's own). */
|
| 343 |
+
export interface TransactionExpectation extends DocExpectation { type?: string; source?: string }
|
| 344 |
+
|
| 345 |
+
/** A transaction type or source as the step and REST both mean it: case and spacing do not matter ("Credit memo" is the
|
| 346 |
+
* pod's "Credit Memo"; a "_" or "-" is a space). */
|
| 347 |
+
export function transactionNameKey(t: string): string {
|
| 348 |
+
return String(t ?? '').trim().toLowerCase().replace(/[_-]+/g, ' ').replace(/\s+/g, ' ');
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
/** The sign Fusion enforces on a transaction's line amount by its type: a credit memo is entered negative, an invoice and a
|
| 352 |
+
* debit memo positive. A type of the pod's own (a PA invoice, a client's) has no rule here. Words for what is wrong
|
| 353 |
+
* (empty: right); no type is an invoice. */
|
| 354 |
+
export function transactionAmountProblems(type: string | undefined, amount: number): string[] {
|
| 355 |
+
const kind = transactionNameKey(type || 'invoice');
|
| 356 |
+
if (kind === 'credit memo' && !(amount < 0)) return [`the amount (${amount}): a credit memo is entered with a negative amount`];
|
| 357 |
+
if ((kind === 'invoice' || kind === 'debit memo') && amount < 0) return [`the amount (${amount}): ${kind === 'invoice' ? 'an invoice' : 'a debit memo'} has a positive amount (a negative one is a credit memo)`];
|
| 358 |
+
return [];
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
export function transactionProblems(number: string, t: ArTransaction | null, want: TransactionExpectation): string[] {
|
| 362 |
if (!t) return [`transaction ${number} is not in Fusion`];
|
| 363 |
+
const out = docProblems(`transaction ${number}`, transactionStatus(t), transactionAmount(t), undefined, want);
|
| 364 |
+
if (want.type && transactionNameKey(String(t.TransactionType ?? '')) !== transactionNameKey(want.type)) {
|
| 365 |
+
out.push(`transaction ${number}: its type is "${t.TransactionType ?? ''}", expected "${want.type}"`);
|
| 366 |
+
}
|
| 367 |
+
if (want.source && transactionNameKey(String(t.TransactionSource ?? t.BatchSource ?? '')) !== transactionNameKey(want.source)) {
|
| 368 |
+
out.push(`transaction ${number}: its source is "${t.TransactionSource ?? t.BatchSource ?? ''}", expected "${want.source}"`);
|
| 369 |
+
}
|
| 370 |
+
return out;
|
| 371 |
}
|
| 372 |
|
| 373 |
export function receiptProblems(number: string, r: ArReceipt | null, want: DocExpectation): string[] {
|
|
|
|
| 461 |
return { status: res.status, text: await res.text() };
|
| 462 |
}
|
| 463 |
|
| 464 |
+
private async get<T>(resource: string, query: string, extra: Record<string, string> = {}): Promise<T[]> {
|
| 465 |
+
const params = new URLSearchParams({ q: query, onlyData: 'true', limit: '100', ...extra });
|
| 466 |
const r = await this.call('GET', `${resource}?${params}`);
|
| 467 |
if (r.status !== 200) throw new Error(`GET ${resource} failed: HTTP ${r.status} ${r.text.slice(0, 300)}`);
|
| 468 |
return (JSON.parse(r.text).items || []) as T[];
|
|
|
|
| 486 |
return this.get<InvoiceHold>('invoiceHolds', `InvoiceNumber='${q(number)}'`);
|
| 487 |
}
|
| 488 |
|
| 489 |
+
/** The payment with this number (payablesPayments; the number is numeric on some releases, text on others). */
|
| 490 |
+
async payment(number: string): Promise<Payment | null> {
|
| 491 |
+
return await this.first<Payment>('payablesPayments', `PaymentNumber=${q(number)}`) ?? await this.first<Payment>('payablesPayments', `PaymentNumber='${q(number)}'`);
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
/** The newest payments to a payee (a supplier), newest first: how the payment a step just made is found when Fusion does not
|
| 495 |
+
* name its number. A pod that does not have the attribute answers HTTP 400: the next one is tried; none: []. */
|
| 496 |
+
async recentPayments(supplier: string): Promise<Payment[]> {
|
| 497 |
+
for (const attr of ['Payee', 'PayeeName', 'SupplierName', 'Supplier']) {
|
| 498 |
+
try {
|
| 499 |
+
return await this.get<Payment>('payablesPayments', `${attr}='${q(supplier)}'`, { orderBy: 'PaymentId:desc' });
|
| 500 |
+
} catch (e) {
|
| 501 |
+
if (!/HTTP 400\b/.test(String((e as Error).message))) throw e;
|
| 502 |
+
}
|
| 503 |
+
}
|
| 504 |
+
return [];
|
| 505 |
+
}
|
| 506 |
+
|
| 507 |
/** Run an invoice action (validateInvoice, cancelInvoice, ...) the way Fusion's REST service offers it. */
|
| 508 |
async invoiceAction(action: string, body: Record<string, unknown>): Promise<string> {
|
| 509 |
const r = await this.call('POST', `invoices/action/${action}`, body, 'application/vnd.oracle.adf.action+json');
|
|
|
|
| 517 |
const inv = await this.invoice(number, supplier) ?? await this.invoiceByNumber(number);
|
| 518 |
if (!inv) return `${number}: not saved, nothing to clean up`;
|
| 519 |
if (inv.CanceledFlag) return `${number}: already cancelled`;
|
| 520 |
+
if (invoiceInApproval(inv)) { // only the screens withdraw an approval (cleanApproval does it before this); one left stays for a person
|
| 521 |
+
throw new LeftForPerson(`invoice ${number} is in approval (${invoiceApprovalStatus(inv)}) and Fusion does not cancel it: withdraw the approval on Payables > Invoices > Manage Invoices `
|
| 522 |
+
+ '(Invoice Actions > Approval > Withdraw), then cancel the invoice');
|
| 523 |
+
}
|
| 524 |
await this.invoiceAction('cancelInvoice', { InvoiceNumber: number, BusinessUnit: inv.BusinessUnit || businessUnit, Supplier: inv.Supplier || supplier });
|
| 525 |
const after = await this.invoice(number, inv.Supplier || supplier);
|
| 526 |
if (!after?.CanceledFlag) throw new Error(`${number}: cancelInvoice reported success but the invoice is not cancelled`);
|
| 527 |
return `${number}: cancelled by clean-up`;
|
| 528 |
}
|
| 529 |
|
| 530 |
+
/** Clean-up of the approval of an invoice a test sent for approval (`invoice`): one under way is withdrawn on the screens (REST has
|
| 531 |
+
* no withdraw for it: NeedsScreen), because Fusion does not cancel an invoice while its approval is under way. */
|
| 532 |
+
async cleanApproval(invoice: string): Promise<string> {
|
| 533 |
+
const inv = await this.invoiceByNumber(invoice);
|
| 534 |
+
if (!inv) return `${invoice}: not in Fusion, no approval to withdraw`;
|
| 535 |
+
if (inv.CanceledFlag) return `${invoice}: already cancelled, no approval to withdraw`;
|
| 536 |
+
if (invoiceInApproval(inv)) throw new NeedsScreen(`invoice ${invoice} is in approval (${invoiceApprovalStatus(inv)}): its approval is withdrawn on Manage Invoices (Invoice Actions > Approval > Withdraw)`);
|
| 537 |
+
return `${invoice}: approval ${invoiceApprovalStatus(inv) || 'not under way'}, nothing to withdraw`;
|
| 538 |
+
}
|
| 539 |
+
|
| 540 |
+
/** Clean-up of the test payment of an invoice (`invoice`; `number` = the payment's number when it is known): a payment that
|
| 541 |
+
* is not voided is voided on the screens (REST has no void for it: NeedsScreen), because an invoice that is paid cannot be
|
| 542 |
+
* cancelled. A paid invoice whose payment is not known is left for a person. */
|
| 543 |
+
async cleanPayment(invoice: string, number?: string): Promise<string> {
|
| 544 |
+
if (number) {
|
| 545 |
+
const p = await this.payment(number);
|
| 546 |
+
if (!p) return `payment ${number}: not in Fusion, nothing to clean up`;
|
| 547 |
+
if (paymentVoided(p)) return `payment ${number}: already voided`;
|
| 548 |
+
throw new NeedsScreen(`payment ${number} is ${paymentStatus(p) || 'not voided'}: it is voided on Manage Payments (Actions > Void Payment)`);
|
| 549 |
+
}
|
| 550 |
+
const inv = await this.invoiceByNumber(invoice);
|
| 551 |
+
if (!inv || !invoiceIsPaid(inv)) return `${invoice}: no payment made, nothing to clean up`;
|
| 552 |
+
throw new LeftForPerson(`invoice ${invoice} is ${inv.PaymentStatus}, and the number of its payment is not known: void the payment on `
|
| 553 |
+
+ 'Payables > Payments > Manage Payments (Actions > Void Payment), then cancel the invoice');
|
| 554 |
+
}
|
| 555 |
+
|
| 556 |
/** The first item of a resource matching `query`, or null. A query the resource refuses (an attribute this pod does not
|
| 557 |
* have: HTTP 400) answers null, so the caller's next way of finding it is tried. */
|
| 558 |
private async first<T>(resource: string, query: string): Promise<T | null> {
|
|
|
|
| 583 |
return this.first<JournalBatch>('journalBatches', `BatchName='${q(name)}'`);
|
| 584 |
}
|
| 585 |
|
| 586 |
+
/** The journals of a batch (journalBatches child journalHeaders: their category, and on some pods their source); empty when
|
| 587 |
+
* the pod refuses the child resource. */
|
| 588 |
+
async journalHeaders(batchId: number): Promise<Record<string, unknown>[]> {
|
| 589 |
+
try { return await this.getAll(`journalBatches/${batchId}/child/journalHeaders`); } catch (e) {
|
| 590 |
+
if (/HTTP (400|404)/.test(String((e as Error).message))) return [];
|
| 591 |
+
throw e;
|
| 592 |
+
}
|
| 593 |
+
}
|
| 594 |
+
|
| 595 |
/** The batches whose name holds the test's batch name: the batch itself and the reversal Fusion makes of it (Fusion
|
| 596 |
* names a reversal after the batch it reverses). Null when this pod refuses the LIKE query. */
|
| 597 |
async journalBatchesNamed(name: string): Promise<JournalBatch[] | null> {
|
automation/src/fusion/steps.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
import * as fs from 'fs';
|
| 2 |
import * as path from 'path';
|
| 3 |
import YAML from 'yaml';
|
| 4 |
-
import { expect, test, type DocKind, type FusionDocs } from './fixtures';
|
| 5 |
import { activeHolds, closeAction, invoiceAmountProblems, invoiceProblems, journalPosted, journalProblems, journalStatus, NO_REST_WHY, orderCloseable,
|
| 6 |
-
orderReceivable, orderStatus, poReceiptProblems, purchaseOrderProblems, receiptProblems, requisitionProblems, REST_SKIPPED, transactionProblems, transactionStatus, type DocExpectation, type FusionRest, type InvoiceExpectation } from './rest';
|
|
|
|
| 7 |
import { apDataSets, fusionDate, podCandidates, podValue, testNumber, used, ValueRefused, type ApDataSet, type FusionUi } from './ui';
|
| 8 |
|
| 9 |
/*
|
|
@@ -25,11 +26,20 @@ import { apDataSets, fusionDate, podCandidates, podValue, testNumber, used, Valu
|
|
| 25 |
* create_transaction, complete_transaction, find_transaction, expect_transaction, create_receipt, find_receipt,
|
| 26 |
* expect_receipt (extra field applies_to: the transaction a receipt is applied to). Receiving: create_receipt_for_order and
|
| 27 |
* expect_receipt_of_order (extra fields applies_to: the order, and quantity), close_purchase_order (value: how). create_invoice and expect_invoice also
|
| 28 |
-
* take invoice_type (Standard, Credit memo, Debit memo, Prepayment) and payment_method (the pod's: Check, Electronic, Wire)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
*/
|
| 30 |
export interface Step { n?: number; action: string; field?: string; value?: string | number; expected?: string; name?: string; fields?: string[];
|
| 31 |
lines?: (string | number)[]; status?: string; amount?: string | number; amount_at_least?: string | number; canceled?: boolean;
|
| 32 |
-
quantity?: string | number; price?: string | number; posted?: boolean; applies_to?: string; invoice_type?: string; payment_method?: string
|
|
|
|
| 33 |
export interface StepCase { id: string; title: string; runner?: string; steps: Step[]; test_values?: Record<string, unknown>;
|
| 34 |
canary?: boolean } // a canary (tests/cases/CANARY-<AREA>.yaml): create_invoice tries the pod's data sets in turn
|
| 35 |
|
|
@@ -190,6 +200,15 @@ function choices(ctx: Ctx, area: string, key: string, ...also: [string, string][
|
|
| 190 |
return out.filter((v, i, all) => v && all.indexOf(v) === i);
|
| 191 |
}
|
| 192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
/** A new test reference for a document of this scenario (FPT-<id>-<time>): what clean-up registers before the save. */
|
| 194 |
const docTag = (ctx: Ctx, kind = '') => testNumber(ctx.c.id.replace(/[^A-Za-z0-9]/g, '') + kind);
|
| 195 |
|
|
@@ -201,6 +220,7 @@ function docRef(s: Step, ctx: Ctx, fallback: string, noun: string, creator: stri
|
|
| 201 |
if (!n) throw new Error(`${s.action} needs ${noun}: nothing is remembered as "${name}" (${creator} or remember it first)`);
|
| 202 |
return n;
|
| 203 |
}
|
|
|
|
| 204 |
const requisitionNumber = (s: Step, ctx: Ctx) => docRef(s, ctx, 'requisition_number', 'a requisition', 'create_requisition');
|
| 205 |
const orderNumber = (s: Step, ctx: Ctx) => docRef(s, ctx, 'order_number', 'a purchase order', 'create_purchase_order');
|
| 206 |
const journalBatch = (s: Step, ctx: Ctx) => docRef(s, ctx, 'journal_batch', 'a journal', 'create_journal');
|
|
@@ -248,6 +268,10 @@ function amountValue(s: Step, ctx: Ctx): string {
|
|
| 248 |
return amount;
|
| 249 |
}
|
| 250 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
/** The transaction types to try for an invoice: Invoice first, then the pod's own that are not another class's (the pod's
|
| 252 |
* latest transactions may be credit memos); the one Fusion already took in this test alone. */
|
| 253 |
function invoiceTypes(ctx: Ctx): string[] {
|
|
@@ -329,7 +353,9 @@ const ACTIONS: Record<string, (s: Step, ctx: Ctx) => Promise<void>> = {
|
|
| 329 |
/** Check the invoice in Fusion (REST) by its number. status = the status it must have (Validated, Needs revalidation,
|
| 330 |
* Canceled ...: matched without regard to case); amount = its exact amount; amount_at_least = at least this amount
|
| 331 |
* (the pod may add tax on top); canceled = true or false; invoice_type = Standard, Credit memo, Debit memo or Prepayment;
|
| 332 |
-
* payment_method = the method's name
|
|
|
|
|
|
|
| 333 |
expect_invoice: async (s, ctx) => {
|
| 334 |
const number = invoiceNumber(s, ctx);
|
| 335 |
const want: InvoiceExpectation = {
|
|
@@ -339,6 +365,8 @@ const ACTIONS: Record<string, (s: Step, ctx: Ctx) => Promise<void>> = {
|
|
| 339 |
canceled: s.canceled,
|
| 340 |
type: s.invoice_type ? fill(s.invoice_type, ctx) : undefined,
|
| 341 |
paymentMethod: s.payment_method ? fill(s.payment_method, ctx) : undefined,
|
|
|
|
|
|
|
| 342 |
};
|
| 343 |
await restCheck(ctx, `expect_invoice ${number}`, () =>
|
| 344 |
untilRight(async () => invoiceProblems(number, await ctx.rest.invoiceByNumber(number), want), `invoice ${number} in Fusion`));
|
|
@@ -362,6 +390,73 @@ const ACTIONS: Record<string, (s: Step, ctx: Ctx) => Promise<void>> = {
|
|
| 362 |
return holds.length ? [`it is on hold: ${holds.map((h) => h.HoldName).join(', ')}`] : [];
|
| 363 |
}, `invoice ${number}`, 20_000));
|
| 364 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
// Purchasing business actions
|
| 366 |
/** Create a requisition of one noncatalog line on its own screen and submit it. value = the item's description
|
| 367 |
* (after the test's tag); quantity (default the test value "quantity", else one) and price (default the test value
|
|
@@ -491,14 +586,22 @@ const ACTIONS: Record<string, (s: Step, ctx: Ctx) => Promise<void>> = {
|
|
| 491 |
},
|
| 492 |
// Receivables business actions
|
| 493 |
/** Create and save (Incomplete) a transaction on its own screen: an Invoice of one line of value (default {{tv.amount}}),
|
| 494 |
-
* the pod's business unit, source and customer.
|
|
|
|
|
|
|
| 495 |
create_transaction: async (s, ctx) => {
|
| 496 |
const amount = amountValue(s, ctx);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 497 |
const tag = track(ctx, 'ar_transaction');
|
| 498 |
const got = await ctx.ui.createTransaction({ tag, description: 'Test transaction', amount, bu: choices(ctx, 'ar', 'business_unit'),
|
| 499 |
source: choices(ctx, 'ar', 'transaction_source'), type: invoiceTypes(ctx), customer: choices(ctx, 'ar', 'customer'),
|
| 500 |
-
memo: choices(ctx, 'ar', 'memo_line') });
|
| 501 |
-
for (const [k, v] of Object.entries(got))
|
|
|
|
|
|
|
| 502 |
const shown = await ctx.ui.transactionNumberOnPage();
|
| 503 |
if (!ctx.rest.available && shown) { // assisted sign-in: the number Fusion shows on the transaction
|
| 504 |
ctx.saved[s.name || 'transaction_number'] = shown;
|
|
@@ -520,10 +623,11 @@ const ACTIONS: Record<string, (s: Step, ctx: Ctx) => Promise<void>> = {
|
|
| 520 |
}, `transaction ${number} after Complete`, 120_000));
|
| 521 |
},
|
| 522 |
/** Check the transaction in Fusion (REST): status (Incomplete, Complete ...: any case), amount = its exact amount,
|
| 523 |
-
* amount_at_least = at least this (the pod may add tax). */
|
| 524 |
expect_transaction: async (s, ctx) => {
|
| 525 |
const number = transactionNumber(s, ctx);
|
| 526 |
-
const want = expectation(s, ctx)
|
|
|
|
| 527 |
await restCheck(ctx, `expect_transaction ${number}`, () =>
|
| 528 |
untilRight(async () => transactionProblems(number, await ctx.rest.transaction(number), want), `transaction ${number} in Fusion`));
|
| 529 |
},
|
|
@@ -553,16 +657,22 @@ const ACTIONS: Record<string, (s: Step, ctx: Ctx) => Promise<void>> = {
|
|
| 553 |
},
|
| 554 |
// General Ledger business actions
|
| 555 |
/** Create and save a journal batch on its own screen: one debit and one credit of value (default {{tv.amount}}) on
|
| 556 |
-
* the same account of the pod.
|
|
|
|
|
|
|
| 557 |
create_journal: async (s, ctx) => {
|
| 558 |
const amount = s.value !== undefined && s.value !== '' ? fill(s.value, ctx)
|
| 559 |
: ctx.c.test_values?.amount !== undefined ? fill('{{tv.amount}}', ctx) : '';
|
| 560 |
if (!amount) throw new Error('create_journal needs an amount: value, or the test value "amount"');
|
| 561 |
amountOf(amount, ctx, 'the journal amount');
|
|
|
|
|
|
|
|
|
|
| 562 |
const batch = track(ctx, 'gl_journal');
|
| 563 |
-
const got = await ctx.ui.createJournal({ batch, amount, ledger: choices(ctx, 'gl', 'ledger'),
|
| 564 |
-
|
| 565 |
-
|
|
|
|
| 566 |
await restCheck(ctx, `create_journal ${batch}`, async () => {
|
| 567 |
await untilFound(() => ctx.rest.journalBatch(batch), `journal batch ${batch} should be in Fusion after the save`);
|
| 568 |
});
|
|
@@ -590,12 +700,17 @@ const ACTIONS: Record<string, (s: Step, ctx: Ctx) => Promise<void>> = {
|
|
| 590 |
return [`journal batch ${batch} is still ${status || 'not posted'}`];
|
| 591 |
}, `journal batch ${batch} after Post`, 300_000));
|
| 592 |
},
|
| 593 |
-
/** Check the journal batch in Fusion (REST): status (Posted, Unposted ...: any case), posted = true or false
|
|
|
|
| 594 |
expect_journal: async (s, ctx) => {
|
| 595 |
const batch = journalBatch(s, ctx);
|
| 596 |
-
const want = expectation(s, ctx)
|
| 597 |
-
|
| 598 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 599 |
},
|
| 600 |
/** Reverse the posted journal batch (opened from Manage Journals when it is not on the page). Fusion's reversal is a
|
| 601 |
* batch it names after this one: the step waits until REST shows it (or the batch says it is reversed; on a pod that
|
|
@@ -628,6 +743,8 @@ const UI_BLOCKS: Record<string, { method: string; args: (s: Step, ctx: Ctx) => u
|
|
| 628 |
/** Invoice Actions > Cancel Invoice on the invoice remembered as `name`, confirmed: it must then show Canceled. */
|
| 629 |
cancel_invoice: { method: 'cancelInvoice', args: (s, ctx) => [invoiceNumber(s, ctx)] },
|
| 630 |
expect_status: { method: 'expectStatusText', args: (s, ctx) => [fill(s.value, ctx)] },
|
|
|
|
|
|
|
| 631 |
/** Cancel the requisition remembered as `name` (default requisition_number), or withdraw it while pending approval. */
|
| 632 |
cancel_requisition: { method: 'cancelRequisition', args: (s, ctx) => [requisitionNumber(s, ctx)] },
|
| 633 |
/** Find the order remembered as `name` (default order_number) on Manage Orders: exactly it must be listed. */
|
|
|
|
| 1 |
import * as fs from 'fs';
|
| 2 |
import * as path from 'path';
|
| 3 |
import YAML from 'yaml';
|
| 4 |
+
import { approvalRef, expect, paymentRef, test, type DocKind, type FusionDocs } from './fixtures';
|
| 5 |
import { activeHolds, closeAction, invoiceAmountProblems, invoiceProblems, journalPosted, journalProblems, journalStatus, NO_REST_WHY, orderCloseable,
|
| 6 |
+
orderReceivable, orderStatus, paymentProblems, paymentTypeKey, poReceiptProblems, purchaseOrderProblems, receiptProblems, requisitionProblems, REST_SKIPPED, transactionProblems, transactionStatus, type DocExpectation, type FusionRest, type InvoiceExpectation, type PaymentExpectation } from './rest';
|
| 7 |
+
import { transactionAmountProblems, type TransactionExpectation } from './rest';
|
| 8 |
import { apDataSets, fusionDate, podCandidates, podValue, testNumber, used, ValueRefused, type ApDataSet, type FusionUi } from './ui';
|
| 9 |
|
| 10 |
/*
|
|
|
|
| 26 |
* create_transaction, complete_transaction, find_transaction, expect_transaction, create_receipt, find_receipt,
|
| 27 |
* expect_receipt (extra field applies_to: the transaction a receipt is applied to). Receiving: create_receipt_for_order and
|
| 28 |
* expect_receipt_of_order (extra fields applies_to: the order, and quantity), close_purchase_order (value: how). create_invoice and expect_invoice also
|
| 29 |
+
* take invoice_type (Standard, Credit memo, Debit memo, Prepayment) and payment_method (the pod's: Check, Electronic, Wire);
|
| 30 |
+
* expect_invoice also checks approval_status (Not required, Required ...) and validation_status (Validated, Not validated,
|
| 31 |
+
* Needs revalidation).
|
| 32 |
+
* Payments (scenario-only, never in a canary): create_payment (a quick payment of a validated invoice: applies_to = the invoice's
|
| 33 |
+
* remembered name, payment_method, payment_type Quick; name = what to remember the payment number as, payment_number),
|
| 34 |
+
* find_payment, expect_payment (status, amount, amount_at_least, payment_method, payment_type), void_payment. A payment the
|
| 35 |
+
* test leaves is voided by the clean-up, before the invoice is cancelled.
|
| 36 |
+
* initiate_approval (scenario-only: name = the invoice's remembered name) sends a validated invoice for approval (Invoice Actions >
|
| 37 |
+
* Approval > Initiate) and checks Fusion shows the approval Initiated; the clean-up withdraws it before the invoice is cancelled.
|
| 38 |
*/
|
| 39 |
export interface Step { n?: number; action: string; field?: string; value?: string | number; expected?: string; name?: string; fields?: string[];
|
| 40 |
lines?: (string | number)[]; status?: string; amount?: string | number; amount_at_least?: string | number; canceled?: boolean;
|
| 41 |
+
quantity?: string | number; price?: string | number; posted?: boolean; applies_to?: string; invoice_type?: string; payment_method?: string;
|
| 42 |
+
category?: string; source?: string; payment_type?: string; approval_status?: string; validation_status?: string }
|
| 43 |
export interface StepCase { id: string; title: string; runner?: string; steps: Step[]; test_values?: Record<string, unknown>;
|
| 44 |
canary?: boolean } // a canary (tests/cases/CANARY-<AREA>.yaml): create_invoice tries the pod's data sets in turn
|
| 45 |
|
|
|
|
| 200 |
return out.filter((v, i, all) => v && all.indexOf(v) === i);
|
| 201 |
}
|
| 202 |
|
| 203 |
+
/** A journal step's category: a name Fusion lists (Adjustment, Accrual, Allocation, Reclass ...) or a pod placeholder
|
| 204 |
+
* ({{pod.gl.category}}), which gives the pod's candidates in turn. Empty: the category Fusion defaults. */
|
| 205 |
+
function journalCategories(s: Step, ctx: Ctx): { names: string[]; fromPod: boolean } {
|
| 206 |
+
const raw = String(s.category ?? '').trim();
|
| 207 |
+
const ref = /^\{\{\s*pod\.([a-z0-9]+)\.([a-z][a-z0-9_]*)\s*\}\}$/i.exec(raw);
|
| 208 |
+
if (ref) return { names: choices(ctx, ref[1].toLowerCase(), ref[2].toLowerCase()), fromPod: true };
|
| 209 |
+
return { names: raw ? [fill(raw, ctx).trim()] : [], fromPod: false };
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
/** A new test reference for a document of this scenario (FPT-<id>-<time>): what clean-up registers before the save. */
|
| 213 |
const docTag = (ctx: Ctx, kind = '') => testNumber(ctx.c.id.replace(/[^A-Za-z0-9]/g, '') + kind);
|
| 214 |
|
|
|
|
| 220 |
if (!n) throw new Error(`${s.action} needs ${noun}: nothing is remembered as "${name}" (${creator} or remember it first)`);
|
| 221 |
return n;
|
| 222 |
}
|
| 223 |
+
const paymentNumber = (s: Step, ctx: Ctx) => docRef(s, ctx, 'payment_number', 'a payment', 'create_payment');
|
| 224 |
const requisitionNumber = (s: Step, ctx: Ctx) => docRef(s, ctx, 'requisition_number', 'a requisition', 'create_requisition');
|
| 225 |
const orderNumber = (s: Step, ctx: Ctx) => docRef(s, ctx, 'order_number', 'a purchase order', 'create_purchase_order');
|
| 226 |
const journalBatch = (s: Step, ctx: Ctx) => docRef(s, ctx, 'journal_batch', 'a journal', 'create_journal');
|
|
|
|
| 268 |
return amount;
|
| 269 |
}
|
| 270 |
|
| 271 |
+
/** Receivables: create_transaction and expect_transaction also take transaction_type (Invoice by default; Credit Memo, Debit
|
| 272 |
+
* Memo or the pod's own type) and transaction_source (Manual or the pod's own source). */
|
| 273 |
+
export interface Step { transaction_type?: string; transaction_source?: string }
|
| 274 |
+
|
| 275 |
/** The transaction types to try for an invoice: Invoice first, then the pod's own that are not another class's (the pod's
|
| 276 |
* latest transactions may be credit memos); the one Fusion already took in this test alone. */
|
| 277 |
function invoiceTypes(ctx: Ctx): string[] {
|
|
|
|
| 353 |
/** Check the invoice in Fusion (REST) by its number. status = the status it must have (Validated, Needs revalidation,
|
| 354 |
* Canceled ...: matched without regard to case); amount = its exact amount; amount_at_least = at least this amount
|
| 355 |
* (the pod may add tax on top); canceled = true or false; invoice_type = Standard, Credit memo, Debit memo or Prepayment;
|
| 356 |
+
* payment_method = the method's name; approval_status = Not required, Required ...; validation_status = Validated, Not validated,
|
| 357 |
+
* Needs revalidation (REST's ValidationStatus; a never validated invoice is Not validated). With none of them, it checks that
|
| 358 |
+
* the invoice exists. */
|
| 359 |
expect_invoice: async (s, ctx) => {
|
| 360 |
const number = invoiceNumber(s, ctx);
|
| 361 |
const want: InvoiceExpectation = {
|
|
|
|
| 365 |
canceled: s.canceled,
|
| 366 |
type: s.invoice_type ? fill(s.invoice_type, ctx) : undefined,
|
| 367 |
paymentMethod: s.payment_method ? fill(s.payment_method, ctx) : undefined,
|
| 368 |
+
approvalStatus: s.approval_status ? fill(s.approval_status, ctx) : undefined,
|
| 369 |
+
validationStatus: s.validation_status ? fill(s.validation_status, ctx) : undefined,
|
| 370 |
};
|
| 371 |
await restCheck(ctx, `expect_invoice ${number}`, () =>
|
| 372 |
untilRight(async () => invoiceProblems(number, await ctx.rest.invoiceByNumber(number), want), `invoice ${number} in Fusion`));
|
|
|
|
| 390 |
return holds.length ? [`it is on hold: ${holds.map((h) => h.HoldName).join(', ')}`] : [];
|
| 391 |
}, `invoice ${number}`, 20_000));
|
| 392 |
},
|
| 393 |
+
// Payments of invoices (not in the canary: a payment is a scenario's, and clean-up voids it)
|
| 394 |
+
/** Pay the validated invoice remembered as applies_to (default invoice_number) in full with a quick payment: Invoice Actions >
|
| 395 |
+
* Pay in Full. payment_method = the method the payment is made with (when Fusion's window offers it; else the invoice's own
|
| 396 |
+
* stays); payment_type is Quick (the only one created). The pod's bank account, payment document and payment process profile
|
| 397 |
+
* are the test data ap.bank_account, ap.payment_document and ap.payment_process_profile when set, else Fusion's defaults or the
|
| 398 |
+
* first choice of its lists. The payment is registered for clean-up before it is made (the clean-up voids it, then the
|
| 399 |
+
* invoice is cancelled). name = what to remember its number as (default payment_number). */
|
| 400 |
+
create_payment: async (s, ctx) => {
|
| 401 |
+
const invoice = invoiceNumber({ ...s, name: s.applies_to }, ctx);
|
| 402 |
+
const type = s.payment_type ? fill(s.payment_type, ctx).trim() : 'Quick';
|
| 403 |
+
if (paymentTypeKey(type) !== 'quick') {
|
| 404 |
+
throw new Error(`create_payment payment_type "${type}": only a Quick payment (Pay in Full on the invoice) is created; a ${type} payment can only be checked (expect_payment)`);
|
| 405 |
+
}
|
| 406 |
+
const method = s.payment_method ? fill(s.payment_method, ctx).trim() : undefined;
|
| 407 |
+
const supplier = ctx.chosen['ap.supplier'] ?? '';
|
| 408 |
+
await restCheck(ctx, `create_payment ${invoice}`, () => untilRight(async () => invoiceProblems(invoice, await ctx.rest.invoiceByNumber(invoice), { status: 'Validated', canceled: false }),
|
| 409 |
+
`invoice ${invoice} before it is paid (only a validated invoice is paid)`, 30_000));
|
| 410 |
+
const before = new Set<number>(ctx.rest.available && supplier ? (await ctx.rest.recentPayments(supplier)).map((p) => p.PaymentId) : []);
|
| 411 |
+
const ref = ctx.docs.track('ap_payment', paymentRef(invoice));
|
| 412 |
+
const got = await ctx.ui.createPayment({ invoice, method, bank: choices(ctx, 'ap', 'bank_account'), document: choices(ctx, 'ap', 'payment_document'),
|
| 413 |
+
profile: choices(ctx, 'ap', 'payment_process_profile') });
|
| 414 |
+
let number = got.number;
|
| 415 |
+
if (ctx.rest.available) { // the payment Fusion named, else the newest payment to the supplier that was not there before
|
| 416 |
+
const fresh = async () => (await ctx.rest.recentPayments(supplier)).find((p) => !before.has(p.PaymentId)) ?? null;
|
| 417 |
+
const p = await untilFound(async () => (number ? await ctx.rest.payment(number) : null) ?? (supplier ? await fresh() : null),
|
| 418 |
+
`a payment of invoice ${invoice} should be in Fusion after Pay in Full${number ? ` (Fusion named ${number})` : ''}`);
|
| 419 |
+
number = String(p.PaymentNumber);
|
| 420 |
+
}
|
| 421 |
+
if (!number) throw new Error(`invoice ${invoice} was paid, but Fusion did not name the payment's number and this run has no Fusion REST to find it: void the payment on Payments > Manage Payments`);
|
| 422 |
+
ctx.docs.payment(ref, number);
|
| 423 |
+
ctx.saved[s.name || 'payment_number'] = number;
|
| 424 |
+
},
|
| 425 |
+
/** Check the payment in Fusion (REST): status (Negotiable, Voided ...: any case), amount = its exact amount, amount_at_least =
|
| 426 |
+
* at least this, payment_method = the method's name, payment_type = Quick, Manual, Refund or Payment Process Request. */
|
| 427 |
+
expect_payment: async (s, ctx) => {
|
| 428 |
+
const number = paymentNumber(s, ctx);
|
| 429 |
+
const want: PaymentExpectation = {
|
| 430 |
+
status: s.status ? fill(s.status, ctx) : undefined,
|
| 431 |
+
amount: s.amount !== undefined ? amountOf(s.amount, ctx, 'amount') : undefined,
|
| 432 |
+
amountAtLeast: s.amount_at_least !== undefined ? amountOf(s.amount_at_least, ctx, 'amount_at_least') : undefined,
|
| 433 |
+
method: s.payment_method ? fill(s.payment_method, ctx) : undefined,
|
| 434 |
+
type: s.payment_type ? fill(s.payment_type, ctx) : undefined,
|
| 435 |
+
};
|
| 436 |
+
await restCheck(ctx, `expect_payment ${number}`, () =>
|
| 437 |
+
untilRight(async () => paymentProblems(number, await ctx.rest.payment(number), want), `payment ${number} in Fusion`));
|
| 438 |
+
},
|
| 439 |
+
/** Void the payment remembered as `name` (default payment_number): Actions > Void Payment on Manage Payments; Fusion must
|
| 440 |
+
* then show it Voided. The invoice is unpaid again, and clean-up cancels it as usual. */
|
| 441 |
+
void_payment: async (s, ctx) => {
|
| 442 |
+
const number = paymentNumber(s, ctx);
|
| 443 |
+
await ctx.ui.voidPayment(number);
|
| 444 |
+
await restCheck(ctx, `void_payment ${number}`, () =>
|
| 445 |
+
untilRight(async () => paymentProblems(number, await ctx.rest.payment(number), { status: 'Voided' }), `payment ${number} after Void Payment`, 120_000));
|
| 446 |
+
},
|
| 447 |
+
/** Send the validated invoice for approval: Invoice Actions > Approval > Initiate (name = the invoice's remembered name, default
|
| 448 |
+
* invoice_number). Fusion must then show the invoice's approval Initiated. A pod whose invoice approval is not set up offers no
|
| 449 |
+
* such entry (or says so): the step then fails with that message, it never pretends. The invoice is registered for clean-up before
|
| 450 |
+
* it is sent (the clean-up withdraws the approval, then cancels the invoice; one it cannot withdraw is listed in left-on-pod). */
|
| 451 |
+
initiate_approval: async (s, ctx) => {
|
| 452 |
+
const invoice = invoiceNumber(s, ctx);
|
| 453 |
+
await restCheck(ctx, `initiate_approval ${invoice}`, () => untilRight(async () => invoiceProblems(invoice, await ctx.rest.invoiceByNumber(invoice), { status: 'Validated', canceled: false }),
|
| 454 |
+
`invoice ${invoice} before it is sent for approval (only a validated invoice is)`, 30_000));
|
| 455 |
+
ctx.docs.track('ap_approval', approvalRef(invoice));
|
| 456 |
+
await ctx.ui.initiateApproval(invoice);
|
| 457 |
+
await restCheck(ctx, `initiate_approval ${invoice}`, () => untilRight(async () => invoiceProblems(invoice, await ctx.rest.invoiceByNumber(invoice), { approvalStatus: 'Initiated' }),
|
| 458 |
+
`invoice ${invoice} after Approval > Initiate`, 120_000));
|
| 459 |
+
},
|
| 460 |
// Purchasing business actions
|
| 461 |
/** Create a requisition of one noncatalog line on its own screen and submit it. value = the item's description
|
| 462 |
* (after the test's tag); quantity (default the test value "quantity", else one) and price (default the test value
|
|
|
|
| 586 |
},
|
| 587 |
// Receivables business actions
|
| 588 |
/** Create and save (Incomplete) a transaction on its own screen: an Invoice of one line of value (default {{tv.amount}}),
|
| 589 |
+
* the pod's business unit, source and customer. transaction_type (Invoice by default; a credit memo's amount is negative) and
|
| 590 |
+
* transaction_source (Manual) are set when given, the pod's defaults otherwise. name = what to remember its number as (default
|
| 591 |
+
* transaction_number). */
|
| 592 |
create_transaction: async (s, ctx) => {
|
| 593 |
const amount = amountValue(s, ctx);
|
| 594 |
+
const typeIs = s.transaction_type ? fill(s.transaction_type, ctx).trim() : undefined;
|
| 595 |
+
const sourceIs = s.transaction_source ? fill(s.transaction_source, ctx).trim() : undefined;
|
| 596 |
+
const wrong = transactionAmountProblems(typeIs, amountOf(amount, ctx, 'the amount'));
|
| 597 |
+
if (wrong.length) throw new Error(`create_transaction transaction_type "${typeIs || 'Invoice'}": ${wrong.join('; ')}`);
|
| 598 |
const tag = track(ctx, 'ar_transaction');
|
| 599 |
const got = await ctx.ui.createTransaction({ tag, description: 'Test transaction', amount, bu: choices(ctx, 'ar', 'business_unit'),
|
| 600 |
source: choices(ctx, 'ar', 'transaction_source'), type: invoiceTypes(ctx), customer: choices(ctx, 'ar', 'customer'),
|
| 601 |
+
memo: choices(ctx, 'ar', 'memo_line'), typeIs, sourceIs });
|
| 602 |
+
for (const [k, v] of Object.entries(got)) { // a type or source the step asked for is not what the next transaction of the test starts from
|
| 603 |
+
if (v && !(k === 'transaction_type' && typeIs) && !(k === 'transaction_source' && sourceIs)) ctx.chosen[`ar.${k}`] = v;
|
| 604 |
+
}
|
| 605 |
const shown = await ctx.ui.transactionNumberOnPage();
|
| 606 |
if (!ctx.rest.available && shown) { // assisted sign-in: the number Fusion shows on the transaction
|
| 607 |
ctx.saved[s.name || 'transaction_number'] = shown;
|
|
|
|
| 623 |
}, `transaction ${number} after Complete`, 120_000));
|
| 624 |
},
|
| 625 |
/** Check the transaction in Fusion (REST): status (Incomplete, Complete ...: any case), amount = its exact amount,
|
| 626 |
+
* amount_at_least = at least this (the pod may add tax), transaction_type and transaction_source as the pod names them. */
|
| 627 |
expect_transaction: async (s, ctx) => {
|
| 628 |
const number = transactionNumber(s, ctx);
|
| 629 |
+
const want: TransactionExpectation = { ...expectation(s, ctx), type: s.transaction_type ? fill(s.transaction_type, ctx).trim() : undefined,
|
| 630 |
+
source: s.transaction_source ? fill(s.transaction_source, ctx).trim() : undefined };
|
| 631 |
await restCheck(ctx, `expect_transaction ${number}`, () =>
|
| 632 |
untilRight(async () => transactionProblems(number, await ctx.rest.transaction(number), want), `transaction ${number} in Fusion`));
|
| 633 |
},
|
|
|
|
| 657 |
},
|
| 658 |
// General Ledger business actions
|
| 659 |
/** Create and save a journal batch on its own screen: one debit and one credit of value (default {{tv.amount}}) on
|
| 660 |
+
* the same account of the pod. category = the journal category (Adjustment, Accrual, Allocation, Reclass ... or a pod
|
| 661 |
+
* value {{pod.gl.category}}; default the one Fusion fills); source = Manual, the only source a person enters (the
|
| 662 |
+
* subledger ones come from Create Accounting). name = what to remember the batch name as (default journal_batch). */
|
| 663 |
create_journal: async (s, ctx) => {
|
| 664 |
const amount = s.value !== undefined && s.value !== '' ? fill(s.value, ctx)
|
| 665 |
: ctx.c.test_values?.amount !== undefined ? fill('{{tv.amount}}', ctx) : '';
|
| 666 |
if (!amount) throw new Error('create_journal needs an amount: value, or the test value "amount"');
|
| 667 |
amountOf(amount, ctx, 'the journal amount');
|
| 668 |
+
const wanted = journalCategories(s, ctx);
|
| 669 |
+
const source = s.source ? fill(s.source, ctx).trim() : '';
|
| 670 |
+
if (source && source.toLowerCase() !== 'manual') throw new Error(`create_journal source "${source}": a person enters only Manual journals; the others come from Create Accounting`);
|
| 671 |
const batch = track(ctx, 'gl_journal');
|
| 672 |
+
const got = await ctx.ui.createJournal({ batch, amount, ledger: choices(ctx, 'gl', 'ledger'),
|
| 673 |
+
category: wanted.names.length ? wanted.names : choices(ctx, 'gl', 'category'), categoryWanted: wanted.names.length > 0,
|
| 674 |
+
source: source ? 'Manual' : undefined, period: choices(ctx, 'gl', 'accounting_period'), account: choices(ctx, 'gl', 'account', ['ap', 'account']) });
|
| 675 |
+
for (const [k, v] of Object.entries(got)) if (v && !(k === 'category' && wanted.names.length && !wanted.fromPod)) ctx.chosen[`gl.${k}`] = v;
|
| 676 |
await restCheck(ctx, `create_journal ${batch}`, async () => {
|
| 677 |
await untilFound(() => ctx.rest.journalBatch(batch), `journal batch ${batch} should be in Fusion after the save`);
|
| 678 |
});
|
|
|
|
| 700 |
return [`journal batch ${batch} is still ${status || 'not posted'}`];
|
| 701 |
}, `journal batch ${batch} after Post`, 300_000));
|
| 702 |
},
|
| 703 |
+
/** Check the journal batch in Fusion (REST): status (Posted, Unposted ...: any case), posted = true or false, category
|
| 704 |
+
* (as Fusion names it: the batch's journal), source (Manual). */
|
| 705 |
expect_journal: async (s, ctx) => {
|
| 706 |
const batch = journalBatch(s, ctx);
|
| 707 |
+
const want = { ...expectation(s, ctx), category: s.category ? fill(s.category, ctx).trim() : undefined,
|
| 708 |
+
source: s.source ? fill(s.source, ctx).trim() : undefined };
|
| 709 |
+
await restCheck(ctx, `expect_journal ${batch}`, () => untilRight(async () => {
|
| 710 |
+
const b = await ctx.rest.journalBatch(batch);
|
| 711 |
+
const headers = b && (want.category || want.source) ? await ctx.rest.journalHeaders(b.JeBatchId) : [];
|
| 712 |
+
return journalProblems(batch, b, want, headers);
|
| 713 |
+
}, `journal batch ${batch} in Fusion`));
|
| 714 |
},
|
| 715 |
/** Reverse the posted journal batch (opened from Manage Journals when it is not on the page). Fusion's reversal is a
|
| 716 |
* batch it names after this one: the step waits until REST shows it (or the batch says it is reversed; on a pod that
|
|
|
|
| 743 |
/** Invoice Actions > Cancel Invoice on the invoice remembered as `name`, confirmed: it must then show Canceled. */
|
| 744 |
cancel_invoice: { method: 'cancelInvoice', args: (s, ctx) => [invoiceNumber(s, ctx)] },
|
| 745 |
expect_status: { method: 'expectStatusText', args: (s, ctx) => [fill(s.value, ctx)] },
|
| 746 |
+
/** Find the payment remembered as `name` (default payment_number) on Manage Payments: exactly it must be listed. */
|
| 747 |
+
find_payment: { method: 'findPayment', args: (s, ctx) => [paymentNumber(s, ctx)] },
|
| 748 |
/** Cancel the requisition remembered as `name` (default requisition_number), or withdraw it while pending approval. */
|
| 749 |
cancel_requisition: { method: 'cancelRequisition', args: (s, ctx) => [requisitionNumber(s, ctx)] },
|
| 750 |
/** Find the order remembered as `name` (default order_number) on Manage Orders: exactly it must be listed. */
|
automation/src/fusion/ui.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
| 1 |
import * as fs from 'fs';
|
| 2 |
import { expect, test, type Locator, type Page } from '@playwright/test';
|
| 3 |
import { dateFormat, FALLBACK_FORMATS, formatDate, formatFromHint, inferDateFormat, parseDate, reformat, setDateFormat } from './dates';
|
|
|
|
| 4 |
import { parseHeals, pick, type HealHow, type HealKind, type HealRule } from './heal';
|
| 5 |
|
| 6 |
/** A text as a literal inside a regular expression. */
|
| 7 |
const esc = (s: string) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
/** Where the tests run and as whom. Set by the co-worker from the pod registration and its vault (never in code). */
|
| 10 |
export const fusionEnv = () => ({
|
| 11 |
baseUrl: (process.env.FUSION_BASE_URL || '').replace(/\/$/, ''),
|
|
@@ -101,6 +106,14 @@ const healRules = (): HealRule[] => {
|
|
| 101 |
return healCache.rules;
|
| 102 |
};
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
/** A note on the test in Playwright's report (outside a test, e.g. a script, nothing is recorded). The report keeps it
|
| 105 |
* with the step, so a healed step is never silent; the same note twice is kept once. */
|
| 106 |
function note(type: string, description: string): void {
|
|
@@ -498,6 +511,23 @@ export class FusionUi {
|
|
| 498 |
/** Open a work area ("Group > Page"): from the home page's springboard, as a user does; through Fusion's Navigator
|
| 499 |
* menu when the springboard does not show the group (pods and roles differ in what the home page offers). */
|
| 500 |
async openWorkArea(group: string, pageName: string) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
const shown = await this.openGroup(group).catch(() => [] as string[]);
|
| 502 |
if (shown.length) {
|
| 503 |
// the group's work area entries are Fusion's "itemNode_..." elements; any visible target otherwise
|
|
@@ -590,9 +620,11 @@ export class FusionUi {
|
|
| 590 |
|
| 591 |
/** A form field by its visible label; Fusion adds "(Required)" to the label of required fields. */
|
| 592 |
field(label: string): Locator {
|
| 593 |
-
// the visible one: Fusion pages keep hidden copies of many fields, and the first match is often one of those
|
|
|
|
|
|
|
| 594 |
return this.page.getByLabel(new RegExp(`^\\s*${label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(\\s*\\(Required\\))?\\s*$`))
|
| 595 |
-
.filter({ visible: true }).first();
|
| 596 |
}
|
| 597 |
|
| 598 |
/** Type a value (or choose it in a drop-down list) and leave the field, so Fusion runs its own logic (look-ups,
|
|
@@ -816,6 +848,117 @@ export class FusionUi {
|
|
| 816 |
await this.expectStatus('Canceled', number);
|
| 817 |
}
|
| 818 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 819 |
/** A business unit without a default currency leaves Invoice Currency empty, and Fusion then refuses the lines ("the
|
| 820 |
* invoice header is incomplete"). Choose the pod's own invoice currency (its records' most used); nothing to do when
|
| 821 |
* Fusion filled it, or when the screen has no such list. */
|
|
@@ -1804,7 +1947,7 @@ export class FusionUi {
|
|
| 1804 |
* pod's candidates where it leaves one empty), one debit and one credit of `amount` on the same account (the first
|
| 1805 |
* of the pod's accounts Fusion takes), then Save. Returns the values on the screen. */
|
| 1806 |
async createJournal(j: { batch: string; amount: string; ledger: string[]; category: string[]; period: string[]; account: string[];
|
| 1807 |
-
date?: string }): Promise<Record<string, string>> {
|
| 1808 |
await this.openTaskOf('General Accounting', 'Journals', ['Create Journal']);
|
| 1809 |
const batch = await this.labelOf(['Journal Batch', 'Batch', 'Batch Name']);
|
| 1810 |
if (!batch) throw new Error('Create Journal shows no Journal Batch field: the screen changed (verify Create Journal on the pod)');
|
|
@@ -1816,12 +1959,44 @@ export class FusionUi {
|
|
| 1816 |
const date = await this.labelOf(['Accounting Date'], 3_000);
|
| 1817 |
if (date && !(await this.value(date))) await this.put(date, j.date || fusionDate());
|
| 1818 |
chosen.accounting_period = await this.ensureFilled(['Accounting Period', 'Period'], j.period, ['GL', 'accounting_period'], { required: false });
|
| 1819 |
-
chosen.category = await this.ensureFilled(['Category', 'Journal Category'], j.category, ['GL', 'category']);
|
|
|
|
| 1820 |
chosen.account = await this.journalLines(j.amount, j.account);
|
| 1821 |
await this.saveDocument('journal');
|
| 1822 |
return chosen;
|
| 1823 |
}
|
| 1824 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1825 |
/** A balanced pair of journal lines: a debit of `amount` on the first of `accounts` Fusion takes, and a credit of the
|
| 1826 |
* same amount on that same account, so even a posted test journal leaves every balance as it was. The inputs are
|
| 1827 |
* found by their names ("Debit" or "Entered Debit", ": <row>" up to 26C) in row order, not by row (26D nests tables
|
|
@@ -1947,12 +2122,14 @@ export class FusionUi {
|
|
| 1947 |
* (what Fusion defaults is kept, the candidates are tried where it leaves a field empty); the test's tag goes into the
|
| 1948 |
* Comments, then Save (the transaction stays Incomplete). Returns the values on the screen. */
|
| 1949 |
async createTransaction(t: { tag: string; description: string; amount: string; bu: string[]; source: string[]; type: string[];
|
| 1950 |
-
customer: string[]; memo: string[] }): Promise<Record<string, string>> {
|
| 1951 |
await this.openTaskIn('Receivables', ['Billing'], ['Create Transaction']);
|
| 1952 |
const chosen: Record<string, string> = {};
|
| 1953 |
chosen.business_unit = await this.ensureFilled(['Business Unit'], t.bu, ['AR', 'business_unit'], { required: false });
|
| 1954 |
-
chosen.transaction_source = await this.
|
| 1955 |
-
|
|
|
|
|
|
|
| 1956 |
chosen.customer = await this.ensureFilled(['Bill-to Name', 'Bill-to Customer', 'Customer Name', 'Customer', 'Bill-to Account'], t.customer, ['AR', 'customer']);
|
| 1957 |
await this.ensureFilled(['Payment Terms', 'Terms'], [], ['AR', 'payment_terms'], { required: false });
|
| 1958 |
const comments = await this.labelOf(['Comments'], 3_000);
|
|
@@ -1967,6 +2144,20 @@ export class FusionUi {
|
|
| 1967 |
return chosen;
|
| 1968 |
}
|
| 1969 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1970 |
/** The transaction number the page shows, '' when it shows none. */
|
| 1971 |
transactionNumberOnPage = () => this.numberOnPage(['Transaction Number', 'Number']);
|
| 1972 |
|
|
|
|
| 1 |
import * as fs from 'fs';
|
| 2 |
import { expect, test, type Locator, type Page } from '@playwright/test';
|
| 3 |
import { dateFormat, FALLBACK_FORMATS, formatDate, formatFromHint, inferDateFormat, parseDate, reformat, setDateFormat } from './dates';
|
| 4 |
+
import { navLink, parseNavLinks } from './nav';
|
| 5 |
import { parseHeals, pick, type HealHow, type HealKind, type HealRule } from './heal';
|
| 6 |
|
| 7 |
/** A text as a literal inside a regular expression. */
|
| 8 |
const esc = (s: string) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
| 9 |
|
| 10 |
+
/** What a form field can be: what a user types into, picks from or ticks (never a button, link or heading). */
|
| 11 |
+
const FORM_CONTROL = 'input:not([type=button]):not([type=submit]):not([type=reset]):not([type=hidden]), textarea, select, '
|
| 12 |
+
+ '[role=textbox], [role=combobox], [role=spinbutton], [role=checkbox], [role=radio], [contenteditable=true]';
|
| 13 |
+
|
| 14 |
/** Where the tests run and as whom. Set by the co-worker from the pod registration and its vault (never in code). */
|
| 15 |
export const fusionEnv = () => ({
|
| 16 |
baseUrl: (process.env.FUSION_BASE_URL || '').replace(/\/$/, ''),
|
|
|
|
| 106 |
return healCache.rules;
|
| 107 |
};
|
| 108 |
|
| 109 |
+
/** The pod's navigation links (FPT_NAV_LINKS, set by the co-worker), parsed once per value. */
|
| 110 |
+
let navCache: { raw?: string; links: Record<string, string> } = { links: {} };
|
| 111 |
+
const navLinks = (): Record<string, string> => {
|
| 112 |
+
const raw = process.env.FPT_NAV_LINKS;
|
| 113 |
+
if (raw !== navCache.raw) navCache = { raw, links: parseNavLinks(raw) };
|
| 114 |
+
return navCache.links;
|
| 115 |
+
};
|
| 116 |
+
|
| 117 |
/** A note on the test in Playwright's report (outside a test, e.g. a script, nothing is recorded). The report keeps it
|
| 118 |
* with the step, so a healed step is never silent; the same note twice is kept once. */
|
| 119 |
function note(type: string, description: string): void {
|
|
|
|
| 511 |
/** Open a work area ("Group > Page"): from the home page's springboard, as a user does; through Fusion's Navigator
|
| 512 |
* menu when the springboard does not show the group (pods and roles differ in what the home page offers). */
|
| 513 |
async openWorkArea(group: string, pageName: string) {
|
| 514 |
+
// an address a consultant saved for this pod (menus differ per role and setup): tried first; the menus are the fallback
|
| 515 |
+
const link = navLink(navLinks(), group, pageName);
|
| 516 |
+
if (link) {
|
| 517 |
+
const host = (() => { try { return new URL(fusionEnv().baseUrl).host; } catch { return ''; } })();
|
| 518 |
+
let same = false;
|
| 519 |
+
try { same = new URL(link).host === host; } catch { /* not an address */ } // never another host, whatever was saved
|
| 520 |
+
if (same) {
|
| 521 |
+
await this.page.goto(link, { waitUntil: 'domcontentloaded' }).catch(() => {});
|
| 522 |
+
await this.settle(3000);
|
| 523 |
+
await this.closeDialogs();
|
| 524 |
+
if (!(await this.onSignInPage())) {
|
| 525 |
+
note('nav-link', `${group} > ${pageName} opened by its link`);
|
| 526 |
+
this.workArea = `${group} > ${pageName}`;
|
| 527 |
+
return;
|
| 528 |
+
}
|
| 529 |
+
}
|
| 530 |
+
}
|
| 531 |
const shown = await this.openGroup(group).catch(() => [] as string[]);
|
| 532 |
if (shown.length) {
|
| 533 |
// the group's work area entries are Fusion's "itemNode_..." elements; any visible target otherwise
|
|
|
|
| 620 |
|
| 621 |
/** A form field by its visible label; Fusion adds "(Required)" to the label of required fields. */
|
| 622 |
field(label: string): Locator {
|
| 623 |
+
// the visible one: Fusion pages keep hidden copies of many fields, and the first match is often one of those; and a
|
| 624 |
+
// form control only: a section's collapse button can carry the name of a field in it ("Journal Batch" on 26D's
|
| 625 |
+
// Create Journal), and typing into the button failed as "read-only"
|
| 626 |
return this.page.getByLabel(new RegExp(`^\\s*${label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(\\s*\\(Required\\))?\\s*$`))
|
| 627 |
+
.and(this.page.locator(FORM_CONTROL)).filter({ visible: true }).first();
|
| 628 |
}
|
| 629 |
|
| 630 |
/** Type a value (or choose it in a drop-down list) and leave the field, so Fusion runs its own logic (look-ups,
|
|
|
|
| 848 |
await this.expectStatus('Canceled', number);
|
| 849 |
}
|
| 850 |
|
| 851 |
+
/** Business action create_payment: a quick payment of the validated invoice `number`, as a clerk pays it from the invoice:
|
| 852 |
+
* Invoice Actions > Pay in Full (the page's Actions menu on the Invoice Details panel), then the window's bank account,
|
| 853 |
+
* payment document and payment process profile when Fusion leaves them empty (the pod's candidates first, else the first
|
| 854 |
+
* choice its list offers), the payment method when the window has the field (else the invoice's own method stays), and OK.
|
| 855 |
+
* Fusion's answers are settled (an error fails the step in its words). Returns the payment number Fusion named ('' when
|
| 856 |
+
* it named none) and what it said. The labels are the ones 26D Pay in Full is known by; verify them on the pod. */
|
| 857 |
+
async createPayment(p: { invoice: string; method?: string; bank: string[]; document: string[]; profile: string[] }): Promise<{ number: string; said: string[] }> {
|
| 858 |
+
if (!(await this.invoiceOpen(p.invoice))) await this.openInvoice(p.invoice);
|
| 859 |
+
await this.menuFirst(['Invoice Actions', 'Actions'], ['Pay in Full', 'Pay'], `paying invoice ${p.invoice}`);
|
| 860 |
+
if (!(await this.dialogs()).length && !(await this.labelOf(['Bank Account', 'Payment Process Profile', 'Payment Document', 'Payment Method'], 15_000))) {
|
| 861 |
+
throw new Error(`Pay in Full opened no window for invoice ${p.invoice}: the screen changed (verify Pay in Full on the pod)`);
|
| 862 |
+
}
|
| 863 |
+
if (p.method) { // the window may offer the method; when it does not, the invoice's own method is what is paid with
|
| 864 |
+
const label = await this.labelOf(['Payment Method'], 3_000);
|
| 865 |
+
if (label && (await this.value(label)).toLowerCase() !== p.method.toLowerCase() && await this.field(label).isEditable().catch(() => false)) await this.put(label, p.method);
|
| 866 |
+
}
|
| 867 |
+
await this.ensureFilled(['Bank Account', 'Disbursement Bank Account'], p.bank, ['AP', 'bank_account'], { required: false });
|
| 868 |
+
await this.ensureFilled(['Payment Process Profile'], p.profile, ['AP', 'payment_process_profile'], { required: false });
|
| 869 |
+
await this.ensureFilled(['Payment Document'], p.document, ['AP', 'payment_document'], { required: false });
|
| 870 |
+
await this.answerWindow(['OK', 'Submit', 'Pay', 'Yes']);
|
| 871 |
+
const said = await this.settleWindows(`paying invoice ${p.invoice}`);
|
| 872 |
+
const named = /\bPayment\s+(?:Number\s+)?#?(\d[\w-]*)\b/i.exec(said.join(' '));
|
| 873 |
+
return { number: named?.[1] ?? '', said };
|
| 874 |
+
}
|
| 875 |
+
|
| 876 |
+
/** Business action find_payment: Payables > Payments > Manage Payments, searched by the payment's number: exactly it must
|
| 877 |
+
* be listed ("Payment Number", or "Number" on layouts that shorten it). */
|
| 878 |
+
async findPayment(number: string) {
|
| 879 |
+
await this.openTaskIn('Payables', ['Payments'], ['Manage Payments']);
|
| 880 |
+
await this.searchOnce([[['Payment Number', 'Number'], number]], [number], 'Manage Payments');
|
| 881 |
+
}
|
| 882 |
+
|
| 883 |
+
/** Business action void_payment: the payment `number` opened from Manage Payments, Actions > Void Payment (Void), the window's
|
| 884 |
+
* own defaults kept (the void date, its accounting date) and its reason filled when it asks one, then OK. Fusion's
|
| 885 |
+
* answers are settled. REST then shows the status Voided (steps.ts waits for it). */
|
| 886 |
+
async voidPayment(number: string): Promise<string[]> {
|
| 887 |
+
await this.findPayment(number);
|
| 888 |
+
await this.openResult([number]);
|
| 889 |
+
await this.menuFirst(['Actions', 'Payment Actions'], ['Void Payment', 'Void'], `voiding payment ${number}`);
|
| 890 |
+
await this.answerWindow(['OK', 'Void', 'Submit', 'Yes'], CANCEL_REASON);
|
| 891 |
+
return this.settleWindows(`voiding payment ${number}`);
|
| 892 |
+
}
|
| 893 |
+
|
| 894 |
+
/** Run an entry of a submenu: open the first of `menus` the page has, then the first of each level of `path` the open menu offers
|
| 895 |
+
* (Invoice Actions > Approval > Initiate: levels [['Approval'], ['Initiate', 'Initiate Approval']]). A release that shows the last
|
| 896 |
+
* level's entry straight in the menu (no submenu) is run by that name. Fails in words naming what the menus did offer; never
|
| 897 |
+
* presses a disabled entry (pressEnabled says why it is disabled). Returns the names pressed, joined with " > ". */
|
| 898 |
+
async menuPath(menus: string[], path: string[][], what: string): Promise<string> {
|
| 899 |
+
const named = (names: string[]) => this.page.getByRole('menuitem', { name: new RegExp('^\\s*(' + names.map(esc).join('|') + ')\\s*$', 'i') }).filter({ visible: true }).first();
|
| 900 |
+
const offered: string[] = [];
|
| 901 |
+
for (const m of menus) {
|
| 902 |
+
const opener = this.page.getByRole('button', { name: m, exact: true }).or(this.page.getByRole('link', { name: m, exact: true }))
|
| 903 |
+
.or(this.page.getByText(m, { exact: true })).filter({ visible: true }).first();
|
| 904 |
+
if (!(await opener.isVisible().catch(() => false))) continue;
|
| 905 |
+
await opener.click();
|
| 906 |
+
await this.settle(1500);
|
| 907 |
+
const done: string[] = [m];
|
| 908 |
+
for (const [i, level] of path.entries()) {
|
| 909 |
+
const item = named(level);
|
| 910 |
+
if (!(await item.isVisible().catch(() => false))) {
|
| 911 |
+
// no submenu level: the last entry straight in the menu
|
| 912 |
+
const flat = named(path[path.length - 1]);
|
| 913 |
+
if (i < path.length - 1 && await flat.isVisible().catch(() => false)) {
|
| 914 |
+
const name = (await flat.innerText().catch(() => '')).replace(/\s+/g, ' ').trim();
|
| 915 |
+
await this.pressEnabled(flat, `${m} > ${name}`);
|
| 916 |
+
await this.settle(5000);
|
| 917 |
+
return `${m} > ${name}`;
|
| 918 |
+
}
|
| 919 |
+
break;
|
| 920 |
+
}
|
| 921 |
+
const name = (await item.innerText().catch(() => '')).replace(/\s+/g, ' ').trim();
|
| 922 |
+
done.push(name);
|
| 923 |
+
if (i < path.length - 1) { await item.click(); await this.settle(1000); } else {
|
| 924 |
+
await this.pressEnabled(item, done.join(' > '));
|
| 925 |
+
await this.settle(5000);
|
| 926 |
+
return done.join(' > ');
|
| 927 |
+
}
|
| 928 |
+
}
|
| 929 |
+
offered.push(...(await this.menuEntries()).map((t) => `${m} > ${t}`));
|
| 930 |
+
await this.page.keyboard.press('Escape').catch(() => {});
|
| 931 |
+
await this.settle(500);
|
| 932 |
+
}
|
| 933 |
+
throw new Error(`${what}: the screen offers none of ${path.map((l) => l.map((e) => `"${e}"`).join('/')).join(' > ')}` +
|
| 934 |
+
(offered.length ? ` (its menus offer ${offered.slice(0, 15).join(', ')})` : ' (none of its menus is there)'));
|
| 935 |
+
}
|
| 936 |
+
|
| 937 |
+
/** Business action initiate_approval: Invoice Actions > Approval > Initiate on the validated invoice `number` (opened from
|
| 938 |
+
* Manage Invoices when it is not on the page; the Invoice Details panel's menu is "Actions"), Fusion's answers settled (an error
|
| 939 |
+
* fails the step in its words). A pod whose invoice approval is not set up offers no such entry: the step then fails saying
|
| 940 |
+
* so, it never pretends. The labels are the ones 26D is known by (Approval, Initiate / Initiate Approval); verify them on the pod. */
|
| 941 |
+
async initiateApproval(number: string): Promise<string[]> {
|
| 942 |
+
if (!(await this.invoiceOpen(number))) await this.openInvoice(number);
|
| 943 |
+
try {
|
| 944 |
+
await this.menuPath(['Invoice Actions', 'Actions'], [['Approval', 'Approvals', 'Manage Approvals'], ['Initiate', 'Initiate Approval']], `sending invoice ${number} for approval`);
|
| 945 |
+
} catch (e) {
|
| 946 |
+
throw new Error(`${String((e as Error).message || e)}: invoice approval is probably not set up for this invoice's business unit (or the invoice needs none); `
|
| 947 |
+
+ 'set up the Payables invoice approval rules on the pod, then run again');
|
| 948 |
+
}
|
| 949 |
+
await this.answerWindow(['OK', 'Yes', 'Submit', 'Initiate']);
|
| 950 |
+
return this.settleWindows(`sending invoice ${number} for approval`);
|
| 951 |
+
}
|
| 952 |
+
|
| 953 |
+
/** Withdraw the approval of the invoice `number` (Invoice Actions > Approval > Withdraw), the clean-up of an invoice sent for
|
| 954 |
+
* approval: Fusion does not cancel an invoice while its approval is under way. A window that asks a reason is answered. */
|
| 955 |
+
async withdrawApproval(number: string): Promise<string[]> {
|
| 956 |
+
if (!(await this.invoiceOpen(number))) await this.openInvoice(number);
|
| 957 |
+
await this.menuPath(['Invoice Actions', 'Actions'], [['Approval', 'Approvals', 'Manage Approvals'], ['Withdraw', 'Withdraw Approval']], `withdrawing the approval of invoice ${number}`);
|
| 958 |
+
await this.answerWindow(['OK', 'Yes', 'Submit', 'Withdraw'], CANCEL_REASON);
|
| 959 |
+
return this.settleWindows(`withdrawing the approval of invoice ${number}`);
|
| 960 |
+
}
|
| 961 |
+
|
| 962 |
/** A business unit without a default currency leaves Invoice Currency empty, and Fusion then refuses the lines ("the
|
| 963 |
* invoice header is incomplete"). Choose the pod's own invoice currency (its records' most used); nothing to do when
|
| 964 |
* Fusion filled it, or when the screen has no such list. */
|
|
|
|
| 1947 |
* pod's candidates where it leaves one empty), one debit and one credit of `amount` on the same account (the first
|
| 1948 |
* of the pod's accounts Fusion takes), then Save. Returns the values on the screen. */
|
| 1949 |
async createJournal(j: { batch: string; amount: string; ledger: string[]; category: string[]; period: string[]; account: string[];
|
| 1950 |
+
date?: string; categoryWanted?: boolean; source?: string }): Promise<Record<string, string>> {
|
| 1951 |
await this.openTaskOf('General Accounting', 'Journals', ['Create Journal']);
|
| 1952 |
const batch = await this.labelOf(['Journal Batch', 'Batch', 'Batch Name']);
|
| 1953 |
if (!batch) throw new Error('Create Journal shows no Journal Batch field: the screen changed (verify Create Journal on the pod)');
|
|
|
|
| 1959 |
const date = await this.labelOf(['Accounting Date'], 3_000);
|
| 1960 |
if (date && !(await this.value(date))) await this.put(date, j.date || fusionDate());
|
| 1961 |
chosen.accounting_period = await this.ensureFilled(['Accounting Period', 'Period'], j.period, ['GL', 'accounting_period'], { required: false });
|
| 1962 |
+
chosen.category = j.categoryWanted ? await this.journalCategory(j.category) : await this.ensureFilled(['Category', 'Journal Category'], j.category, ['GL', 'category']);
|
| 1963 |
+
if (j.source) chosen.source = await this.journalSource(j.source);
|
| 1964 |
chosen.account = await this.journalLines(j.amount, j.account);
|
| 1965 |
await this.saveDocument('journal');
|
| 1966 |
return chosen;
|
| 1967 |
}
|
| 1968 |
|
| 1969 |
+
/** The category the scenario asks for (Adjustment, Accrual ...), put over the one Fusion defaulted: the first of
|
| 1970 |
+
* `candidates` Fusion takes. A value Fusion refuses is another category name on this pod, so the next is tried; none
|
| 1971 |
+
* taken fails naming them. */
|
| 1972 |
+
private async journalCategory(candidates: string[]): Promise<string> {
|
| 1973 |
+
const label = await this.labelOf(['Category', 'Journal Category']);
|
| 1974 |
+
if (!label) throw new Error('Create Journal shows no Category field: the screen changed (verify Create Journal on the pod)');
|
| 1975 |
+
const tried: string[] = [];
|
| 1976 |
+
for (const v of candidates.filter((x, i, all) => x && all.indexOf(x) === i).slice(0, 6)) {
|
| 1977 |
+
try {
|
| 1978 |
+
if ((await this.value(label)).toLowerCase() !== v.toLowerCase()) await this.put(label, v);
|
| 1979 |
+
return v;
|
| 1980 |
+
} catch (e) {
|
| 1981 |
+
if (!(e instanceof ValueRefused)) throw e;
|
| 1982 |
+
tried.push(v);
|
| 1983 |
+
}
|
| 1984 |
+
}
|
| 1985 |
+
throw new Error(`Create Journal: Fusion took none of the journal categories asked for (${tried.join(', ') || 'none given'}); use a category this pod has ` +
|
| 1986 |
+
'or set GL category on the Test environments page (Test data)');
|
| 1987 |
+
}
|
| 1988 |
+
|
| 1989 |
+
/** The Source of a manual journal: Manual, which Fusion fills itself on Create Journal; put only where the field shows
|
| 1990 |
+
* something else and takes input. Returns what the field holds ('' when the page has no Source field). */
|
| 1991 |
+
private async journalSource(source: string): Promise<string> {
|
| 1992 |
+
const label = await this.labelOf(['Source', 'Journal Source'], 3_000);
|
| 1993 |
+
if (!label) return '';
|
| 1994 |
+
const now = await this.value(label);
|
| 1995 |
+
if (now.toLowerCase() === source.toLowerCase() || !(await this.field(label).isEditable().catch(() => false))) return now;
|
| 1996 |
+
await this.put(label, source);
|
| 1997 |
+
return source;
|
| 1998 |
+
}
|
| 1999 |
+
|
| 2000 |
/** A balanced pair of journal lines: a debit of `amount` on the first of `accounts` Fusion takes, and a credit of the
|
| 2001 |
* same amount on that same account, so even a posted test journal leaves every balance as it was. The inputs are
|
| 2002 |
* found by their names ("Debit" or "Entered Debit", ": <row>" up to 26C) in row order, not by row (26D nests tables
|
|
|
|
| 2122 |
* (what Fusion defaults is kept, the candidates are tried where it leaves a field empty); the test's tag goes into the
|
| 2123 |
* Comments, then Save (the transaction stays Incomplete). Returns the values on the screen. */
|
| 2124 |
async createTransaction(t: { tag: string; description: string; amount: string; bu: string[]; source: string[]; type: string[];
|
| 2125 |
+
customer: string[]; memo: string[]; typeIs?: string; sourceIs?: string }): Promise<Record<string, string>> {
|
| 2126 |
await this.openTaskIn('Receivables', ['Billing'], ['Create Transaction']);
|
| 2127 |
const chosen: Record<string, string> = {};
|
| 2128 |
chosen.business_unit = await this.ensureFilled(['Business Unit'], t.bu, ['AR', 'business_unit'], { required: false });
|
| 2129 |
+
chosen.transaction_source = t.sourceIs ? await this.setTransactionField(['Transaction Source', 'Source'], t.sourceIs, 'transaction source')
|
| 2130 |
+
: await this.ensureFilled(['Transaction Source', 'Source'], t.source, ['AR', 'transaction_source'], { required: false });
|
| 2131 |
+
chosen.transaction_type = t.typeIs ? await this.setTransactionField(['Transaction Type', 'Type'], t.typeIs, 'transaction type')
|
| 2132 |
+
: await this.ensureFilled(['Transaction Type', 'Type'], t.type, ['AR', 'transaction_type']);
|
| 2133 |
chosen.customer = await this.ensureFilled(['Bill-to Name', 'Bill-to Customer', 'Customer Name', 'Customer', 'Bill-to Account'], t.customer, ['AR', 'customer']);
|
| 2134 |
await this.ensureFilled(['Payment Terms', 'Terms'], [], ['AR', 'payment_terms'], { required: false });
|
| 2135 |
const comments = await this.labelOf(['Comments'], 3_000);
|
|
|
|
| 2144 |
return chosen;
|
| 2145 |
}
|
| 2146 |
|
| 2147 |
+
/** A transaction field the step names (the type or source it is about): set to exactly that value, whatever Fusion defaulted,
|
| 2148 |
+
* and Fusion's refusal fails the step in a sentence (the pod has no such type or source, or not for this user). */
|
| 2149 |
+
private async setTransactionField(labels: string[], value: string, what: string): Promise<string> {
|
| 2150 |
+
const label = await this.labelOf(labels, 10_000);
|
| 2151 |
+
if (!label) throw new Error(`Create Transaction shows no ${labels[0]} field to set the ${what} "${value}" in: the screen changed (verify Create Transaction on the pod)`);
|
| 2152 |
+
if ((await this.value(label)).toLowerCase() !== value.toLowerCase()) {
|
| 2153 |
+
try { await this.put(label, value); } catch (e) {
|
| 2154 |
+
if (e instanceof ValueRefused) throw new Error(`Fusion does not take the ${what} "${value}" on Create Transaction: the pod has no such ${what} for this user (${e.message})`);
|
| 2155 |
+
throw e;
|
| 2156 |
+
}
|
| 2157 |
+
}
|
| 2158 |
+
return (await this.value(label)) || value;
|
| 2159 |
+
}
|
| 2160 |
+
|
| 2161 |
/** The transaction number the page shows, '' when it shows none. */
|
| 2162 |
transactionNumberOnPage = () => this.numberOnPage(['Transaction Number', 'Number']);
|
| 2163 |
|
automation/tests/fusion/steps/AP-FUS-020.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AP-FUS-020 (YAML: tests/cases/AP-FUS-020.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('AP-FUS-020', ['@AP-FUS-020','@AP','@P2']);
|
automation/tests/fusion/steps/AP-FUS-021.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AP-FUS-021 (YAML: tests/cases/AP-FUS-021.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('AP-FUS-021', ['@AP-FUS-021','@AP','@P2']);
|
automation/tests/fusion/steps/AP-FUS-022.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AP-FUS-022 (YAML: tests/cases/AP-FUS-022.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('AP-FUS-022', ['@AP-FUS-022','@AP','@P2']);
|
automation/tests/fusion/steps/AP-FUS-023.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AP-FUS-023 (YAML: tests/cases/AP-FUS-023.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('AP-FUS-023', ['@AP-FUS-023','@AP','@P2']);
|
automation/tests/fusion/steps/AP-FUS-024.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AP-FUS-024 (YAML: tests/cases/AP-FUS-024.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('AP-FUS-024', ['@AP-FUS-024','@AP','@P2']);
|
automation/tests/fusion/steps/AP-FUS-025.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AP-FUS-025 (YAML: tests/cases/AP-FUS-025.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('AP-FUS-025', ['@AP-FUS-025','@AP','@P2']);
|
automation/tests/fusion/steps/AP-FUS-026.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AP-FUS-026 (YAML: tests/cases/AP-FUS-026.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('AP-FUS-026', ['@AP-FUS-026','@AP','@P2']);
|
automation/tests/fusion/steps/AP-FUS-027.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AP-FUS-027 (YAML: tests/cases/AP-FUS-027.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('AP-FUS-027', ['@AP-FUS-027','@AP','@P2']);
|
automation/tests/fusion/steps/AR-FUS-001.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AR-FUS-001 (YAML: tests/cases/AR-FUS-001.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('AR-FUS-001', ['@AR-FUS-001','@AR','@P1']);
|
automation/tests/fusion/steps/AR-FUS-002.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AR-FUS-002 (YAML: tests/cases/AR-FUS-002.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('AR-FUS-002', ['@AR-FUS-002','@AR','@P2']);
|
automation/tests/fusion/steps/AR-FUS-003.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AR-FUS-003 (YAML: tests/cases/AR-FUS-003.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('AR-FUS-003', ['@AR-FUS-003','@AR','@P2']);
|
automation/tests/fusion/steps/AR-FUS-004.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AR-FUS-004 (YAML: tests/cases/AR-FUS-004.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('AR-FUS-004', ['@AR-FUS-004','@AR','@P1']);
|
automation/tests/fusion/steps/AR-FUS-005.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AR-FUS-005 (YAML: tests/cases/AR-FUS-005.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('AR-FUS-005', ['@AR-FUS-005','@AR','@P2']);
|
automation/tests/fusion/steps/AR-FUS-006.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// AR-FUS-006 (YAML: tests/cases/AR-FUS-006.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('AR-FUS-006', ['@AR-FUS-006','@AR','@P2']);
|
automation/tests/fusion/steps/GL-FUS-002.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// GL-FUS-002 (YAML: tests/cases/GL-FUS-002.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('GL-FUS-002', ['@GL-FUS-002','@GL','@P1']);
|
automation/tests/fusion/steps/GL-FUS-003.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// GL-FUS-003 (YAML: tests/cases/GL-FUS-003.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('GL-FUS-003', ['@GL-FUS-003','@GL','@P1']);
|
automation/tests/fusion/steps/GL-FUS-004.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// GL-FUS-004 (YAML: tests/cases/GL-FUS-004.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('GL-FUS-004', ['@GL-FUS-004','@GL','@P2']);
|
automation/tests/fusion/steps/GL-FUS-005.spec.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// GL-FUS-005 (YAML: tests/cases/GL-FUS-005.yaml, runner: steps). Generated by scripts/gen-fusion-steps.js; edit the YAML, not this file.
|
| 2 |
+
import { stepsTest } from '../../../src/fusion/steps';
|
| 3 |
+
|
| 4 |
+
stepsTest('GL-FUS-005', ['@GL-FUS-005','@GL','@P2']);
|
coworker/adapters/remote_runner.py
CHANGED
|
@@ -28,7 +28,7 @@ from .playwright import AUTOMATION, testdata_used_file
|
|
| 28 |
log = logging.getLogger("fpt.remote_runner")
|
| 29 |
|
| 30 |
ENV_KEYS = ("FUSION_BASE_URL", "FUSION_USERNAME", "FUSION_PASSWORD", "FUSION_TESTDATA", "FUSION_TESTDATA_CANDIDATES",
|
| 31 |
-
"FPT_FUSION_WORKERS", "FPT_BROWSER_SLOWMO_MS", "FPT_SIGN_IN_MODE", "FPT_HEALS")
|
| 32 |
JOB_FILE = "remote-job.json"
|
| 33 |
JOB_ID = re.compile(r"job_[0-9a-f]{12}")
|
| 34 |
# a job's last states; "failed" (the runner's own error) and "lost" (it restarted mid-job) come from runners that keep
|
|
|
|
| 28 |
log = logging.getLogger("fpt.remote_runner")
|
| 29 |
|
| 30 |
ENV_KEYS = ("FUSION_BASE_URL", "FUSION_USERNAME", "FUSION_PASSWORD", "FUSION_TESTDATA", "FUSION_TESTDATA_CANDIDATES",
|
| 31 |
+
"FPT_FUSION_WORKERS", "FPT_BROWSER_SLOWMO_MS", "FPT_SIGN_IN_MODE", "FPT_HEALS", "FPT_NAV_LINKS")
|
| 32 |
JOB_FILE = "remote-job.json"
|
| 33 |
JOB_ID = re.compile(r"job_[0-9a-f]{12}")
|
| 34 |
# a job's last states; "failed" (the runner's own error) and "lost" (it restarted mid-job) come from runners that keep
|
coworker/api/routes/pods.py
CHANGED
|
@@ -9,7 +9,7 @@ from fastapi import APIRouter, Depends, Request
|
|
| 9 |
from ...platform.pods import PodError, PodRegistry
|
| 10 |
from ..auth import Principal, require
|
| 11 |
from ..errors import ApiError
|
| 12 |
-
from ..schemas import (PodCoverage, PodCredentialIn, PodIn, PodRow, PodScreensIn, PodTestDataIn, PodTestResult, PodUpdate, PodUsage,
|
| 13 |
PodUsageIn)
|
| 14 |
|
| 15 |
router = APIRouter(tags=["pods"])
|
|
@@ -122,6 +122,26 @@ def set_test_data(pod_id: int, body: PodTestDataIn, request: Request, user: Prin
|
|
| 122 |
raise _err(e) from e
|
| 123 |
|
| 124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
@router.post("/pods/{pod_id}/screens/read", response_model=PodRow, status_code=202)
|
| 126 |
def read_screens(pod_id: int, body: PodScreensIn, request: Request, user: Principal = Depends(require("admin"))):
|
| 127 |
"""Read the screens of the pod's business areas in a real browser (labels only, nothing saved on the pod). Runs in the
|
|
|
|
| 9 |
from ...platform.pods import PodError, PodRegistry
|
| 10 |
from ..auth import Principal, require
|
| 11 |
from ..errors import ApiError
|
| 12 |
+
from ..schemas import (PodCoverage, PodCredentialIn, PodIn, PodNavLinks, PodNavLinksIn, PodRow, PodScreensIn, PodTestDataIn, PodTestResult, PodUpdate, PodUsage,
|
| 13 |
PodUsageIn)
|
| 14 |
|
| 15 |
router = APIRouter(tags=["pods"])
|
|
|
|
| 122 |
raise _err(e) from e
|
| 123 |
|
| 124 |
|
| 125 |
+
@router.get("/pods/{pod_id}/nav-links", response_model=PodNavLinks)
|
| 126 |
+
def get_nav_links(pod_id: int, request: Request, user: Principal = Depends(require("read"))):
|
| 127 |
+
r = reg(request)
|
| 128 |
+
try:
|
| 129 |
+
r.get(pod_id)
|
| 130 |
+
return {"pod_id": pod_id, "links": r.nav_links(pod_id)}
|
| 131 |
+
except PodError as e:
|
| 132 |
+
raise _err(e) from e
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
@router.put("/pods/{pod_id}/nav-links", response_model=PodNavLinks)
|
| 136 |
+
def set_nav_links(pod_id: int, body: PodNavLinksIn, request: Request, user: Principal = Depends(require("admin"))):
|
| 137 |
+
"""Work areas a consultant opened by hand in Fusion and pasted here; a run opens them by address when the menus do not
|
| 138 |
+
show them. Same host as the pod only."""
|
| 139 |
+
try:
|
| 140 |
+
return {"pod_id": pod_id, "links": reg(request).set_nav_links(pod_id, body.links, user.username)}
|
| 141 |
+
except PodError as e:
|
| 142 |
+
raise _err(e) from e
|
| 143 |
+
|
| 144 |
+
|
| 145 |
@router.post("/pods/{pod_id}/screens/read", response_model=PodRow, status_code=202)
|
| 146 |
def read_screens(pod_id: int, body: PodScreensIn, request: Request, user: Principal = Depends(require("admin"))):
|
| 147 |
"""Read the screens of the pod's business areas in a real browser (labels only, nothing saved on the pod). Runs in the
|
coworker/api/schemas.py
CHANGED
|
@@ -184,6 +184,15 @@ class PodTestDataIn(Strict):
|
|
| 184 |
overrides: dict[str, dict[str, str | None]] = Field(default_factory=dict) # {"AP": {"supplier": "..."}}; empty removes
|
| 185 |
|
| 186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
class PodCredentialIn(Strict):
|
| 188 |
module: str = Field(min_length=2, max_length=10)
|
| 189 |
username: str = Field(min_length=1, max_length=120)
|
|
@@ -216,6 +225,7 @@ class PodRow(BaseModel):
|
|
| 216 |
screens: dict | None = None # {state, started_at, finished_at, progress, error, areas: {code: {work_areas, captured, failed}}} # Fusion: the business areas a run may target on this pod (discovery)
|
| 217 |
test_data: dict[str, dict[str, str]] = Field(default_factory=dict) # per area: the values the test runner uses
|
| 218 |
test_data_overrides: dict[str, dict[str, str]] = Field(default_factory=dict) # per area: values an admin set by hand
|
|
|
|
| 219 |
last_check_at: str | None = None
|
| 220 |
last_check_ok: bool | None = None
|
| 221 |
last_check_detail: str | None = None
|
|
|
|
| 184 |
overrides: dict[str, dict[str, str | None]] = Field(default_factory=dict) # {"AP": {"supplier": "..."}}; empty removes
|
| 185 |
|
| 186 |
|
| 187 |
+
class PodNavLinksIn(Strict):
|
| 188 |
+
links: dict[str, str] = Field(default_factory=dict) # {"Procurement > Purchase Orders": "https://<pod host>/fscmUI/..."}; replaces the set
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
class PodNavLinks(BaseModel):
|
| 192 |
+
pod_id: int
|
| 193 |
+
links: dict[str, str] = Field(default_factory=dict)
|
| 194 |
+
|
| 195 |
+
|
| 196 |
class PodCredentialIn(Strict):
|
| 197 |
module: str = Field(min_length=2, max_length=10)
|
| 198 |
username: str = Field(min_length=1, max_length=120)
|
|
|
|
| 225 |
screens: dict | None = None # {state, started_at, finished_at, progress, error, areas: {code: {work_areas, captured, failed}}} # Fusion: the business areas a run may target on this pod (discovery)
|
| 226 |
test_data: dict[str, dict[str, str]] = Field(default_factory=dict) # per area: the values the test runner uses
|
| 227 |
test_data_overrides: dict[str, dict[str, str]] = Field(default_factory=dict) # per area: values an admin set by hand
|
| 228 |
+
nav_links: dict[str, str] = Field(default_factory=dict) # "Group > Page" -> address of the work area, opened directly by runs
|
| 229 |
last_check_at: str | None = None
|
| 230 |
last_check_ok: bool | None = None
|
| 231 |
last_check_detail: str | None = None
|
coworker/llm/prompts/write_steps.md
CHANGED
|
@@ -56,6 +56,9 @@ Rules:
|
|
| 56 |
`create_receipt` (applied to the transaction created earlier; `applies_to` names it when it was remembered under
|
| 57 |
another name), `find_receipt` and `expect_receipt` (`status` Applied or Unapplied). The transaction is remembered
|
| 58 |
as {{saved.transaction_number}}, the receipt as {{saved.receipt_number}}.
|
|
|
|
|
|
|
|
|
|
| 59 |
- In every area, use low-level steps only where the business actions do not reach: a field-level check or a negative
|
| 60 |
case (a required field left empty, an unbalanced journal, a line Fusion must refuse). A scenario that only needs a
|
| 61 |
document to exist starts with the business action that creates it and checks the outcome with an `expect_` action.
|
|
|
|
| 56 |
`create_receipt` (applied to the transaction created earlier; `applies_to` names it when it was remembered under
|
| 57 |
another name), `find_receipt` and `expect_receipt` (`status` Applied or Unapplied). The transaction is remembered
|
| 58 |
as {{saved.transaction_number}}, the receipt as {{saved.receipt_number}}.
|
| 59 |
+
`create_transaction` also takes `transaction_type` (Invoice by default; Credit Memo with a negative amount, Debit Memo
|
| 60 |
+
with a positive one, or the pod's own type) and `transaction_source` (Manual, or the pod's own); `expect_transaction`
|
| 61 |
+
checks them. An import source (Receivables Import) is not made from a screen: never write a scenario for it.
|
| 62 |
- In every area, use low-level steps only where the business actions do not reach: a field-level check or a negative
|
| 63 |
case (a required field left empty, an unbalanced journal, a line Fusion must refuse). A scenario that only needs a
|
| 64 |
document to exist starts with the business action that creates it and checks the outcome with an `expect_` action.
|
coworker/llm/schemas.py
CHANGED
|
@@ -107,10 +107,17 @@ class StepModel(_M):
|
|
| 107 |
canceled: bool | None = None
|
| 108 |
posted: bool | None = None
|
| 109 |
applies_to: str | None = None
|
|
|
|
|
|
|
| 110 |
quantity: str | None = None
|
| 111 |
price: str | None = None
|
| 112 |
invoice_type: str | None = None # create_invoice, expect_invoice: Standard, Credit memo, Debit memo, Prepayment
|
| 113 |
payment_method: str | None = None # create_invoice, expect_invoice: the pod's payment method (Check, Electronic, Wire ...)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
@field_validator("value", "amount", "amount_at_least", "quantity", "price", mode="before")
|
| 116 |
@classmethod
|
|
|
|
| 107 |
canceled: bool | None = None
|
| 108 |
posted: bool | None = None
|
| 109 |
applies_to: str | None = None
|
| 110 |
+
transaction_type: str | None = None # create_transaction, expect_transaction: Invoice, Credit Memo, Debit Memo or the pod's own type
|
| 111 |
+
transaction_source: str | None = None # create_transaction, expect_transaction: Manual or the pod's own source
|
| 112 |
quantity: str | None = None
|
| 113 |
price: str | None = None
|
| 114 |
invoice_type: str | None = None # create_invoice, expect_invoice: Standard, Credit memo, Debit memo, Prepayment
|
| 115 |
payment_method: str | None = None # create_invoice, expect_invoice: the pod's payment method (Check, Electronic, Wire ...)
|
| 116 |
+
category: str | None = None # create_journal, expect_journal: the journal category (Adjustment, Accrual ...)
|
| 117 |
+
source: str | None = None # create_journal, expect_journal: Manual, the only source a person enters
|
| 118 |
+
payment_type: str | None = None # create_payment, expect_payment: Quick, Manual, Refund, Payment Process Request
|
| 119 |
+
approval_status: str | None = None # expect_invoice: Not required, Required, Approved ...
|
| 120 |
+
validation_status: str | None = None # expect_invoice: Validated, Not validated, Needs revalidation
|
| 121 |
|
| 122 |
@field_validator("value", "amount", "amount_at_least", "quantity", "price", mode="before")
|
| 123 |
@classmethod
|
coworker/platform/cleanup.py
CHANGED
|
@@ -78,6 +78,8 @@ def _cancel_one(svc, base_url: str, auth: tuple[str, str], e: dict, run_id: str)
|
|
| 78 |
return "not saved, nothing to clean up"
|
| 79 |
if inv.get("CanceledFlag"):
|
| 80 |
return "already cancelled"
|
|
|
|
|
|
|
| 81 |
supplier = inv.get("Supplier") or e.get("supplier")
|
| 82 |
r = svc.egress.fusion_request(base_url, "POST", f"{API}/invoices/action/cancelInvoice", auth=auth, purpose="cleanup", run_id=run_id,
|
| 83 |
json_body={"InvoiceNumber": e["number"], "BusinessUnit": inv.get("BusinessUnit") or e.get("businessUnit"),
|
|
@@ -90,6 +92,16 @@ def _cancel_one(svc, base_url: str, auth: tuple[str, str], e: dict, run_id: str)
|
|
| 90 |
return "cancelled by the co-worker's clean-up"
|
| 91 |
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
def _status(s) -> str:
|
| 94 |
"""A status as REST and the screens both mean it: case and spacing ignored, the British "Cancelled" too."""
|
| 95 |
return " ".join(str(s or "").lower().replace("_", " ").split()).replace("cancelled", "canceled")
|
|
@@ -249,7 +261,42 @@ def _clean_po_receipt(svc, base_url: str, auth, e: dict, run_id: str) -> str:
|
|
| 249 |
return "not saved, nothing to clean up"
|
| 250 |
|
| 251 |
|
| 252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
"ar_transaction": _clean_transaction, "ar_receipt": _clean_receipt, "po_receipt": _clean_po_receipt}
|
| 254 |
RECEIPT_RESOURCES = ("receivingReceiptRequests", "receivingReceiptTransactions")
|
| 255 |
|
|
@@ -266,7 +313,7 @@ def sweep(svc, run_id: str, reason: str) -> dict | None:
|
|
| 266 |
reg = PodRegistry(svc.db, svc.vault, svc.cfg, svc.egress, svc.audit)
|
| 267 |
cleaned, remaining = [], []
|
| 268 |
received: set[str] = set() # orders whose receipt a person has to undo (the receipts go first, see below)
|
| 269 |
-
left.sort(key=lambda x: x.get("kind") != "po_receipt")
|
| 270 |
try:
|
| 271 |
pod = reg.get(pid)
|
| 272 |
auth = reg.fusion_auth(pid)
|
|
|
|
| 78 |
return "not saved, nothing to clean up"
|
| 79 |
if inv.get("CanceledFlag"):
|
| 80 |
return "already cancelled"
|
| 81 |
+
if _in_approval(inv): # Fusion does not cancel an invoice in approval, and REST has no withdraw: left for a person
|
| 82 |
+
raise RuntimeError(f"invoice {e['number']} is in approval ({_in_approval(inv)}) and Fusion does not cancel it: {APPROVAL_TODO}")
|
| 83 |
supplier = inv.get("Supplier") or e.get("supplier")
|
| 84 |
r = svc.egress.fusion_request(base_url, "POST", f"{API}/invoices/action/cancelInvoice", auth=auth, purpose="cleanup", run_id=run_id,
|
| 85 |
json_body={"InvoiceNumber": e["number"], "BusinessUnit": inv.get("BusinessUnit") or e.get("businessUnit"),
|
|
|
|
| 92 |
return "cancelled by the co-worker's clean-up"
|
| 93 |
|
| 94 |
|
| 95 |
+
def _in_approval(inv: dict) -> str:
|
| 96 |
+
"""The invoice's approval status when its approval is under way (Initiated), else '': such an invoice is not cancelled until the
|
| 97 |
+
approval is withdrawn (mirror of rest.ts invoiceInApproval)."""
|
| 98 |
+
status = _status(next((inv[k] for k in ("ApprovalStatus", "WFapprovalStatus", "ApprovalStatusMeaning") if inv.get(k) not in (None, "")), ""))
|
| 99 |
+
return status if status in ("initiated", "in process", "in progress", "pending", "pending approval") else ""
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
APPROVAL_TODO = "withdraw the approval on Payables > Invoices > Manage Invoices (Invoice Actions > Approval > Withdraw), then cancel the invoice"
|
| 103 |
+
|
| 104 |
+
|
| 105 |
def _status(s) -> str:
|
| 106 |
"""A status as REST and the screens both mean it: case and spacing ignored, the British "Cancelled" too."""
|
| 107 |
return " ".join(str(s or "").lower().replace("_", " ").split()).replace("cancelled", "canceled")
|
|
|
|
| 261 |
return "not saved, nothing to clean up"
|
| 262 |
|
| 263 |
|
| 264 |
+
def _clean_payment(svc, base_url: str, auth, e: dict, run_id: str) -> str:
|
| 265 |
+
"""Mirror of rest.ts cleanPayment: the test payment of an invoice (the ledger's number is "<invoice>-PAY"; "payment" is its own
|
| 266 |
+
number once Fusion made it). Voiding is done on the screens, never by REST, so a payment that is not voided is left for a person,
|
| 267 |
+
and the invoice stays until it is."""
|
| 268 |
+
todo = "void it on Payables > Payments > Manage Payments (Actions > Void Payment), then cancel the invoice"
|
| 269 |
+
number = str(e.get("payment") or "")
|
| 270 |
+
if number:
|
| 271 |
+
p = _first(svc, base_url, auth, run_id, "payablesPayments", f"PaymentNumber={_q(number)}", f"PaymentNumber='{_q(number)}'")
|
| 272 |
+
if not p:
|
| 273 |
+
return f"payment {number} not in Fusion, nothing to clean up"
|
| 274 |
+
status = _status(p.get("PaymentStatus") or p.get("PaymentStatusCode") or p.get("Status"))
|
| 275 |
+
if status == "voided":
|
| 276 |
+
return f"payment {number} already voided"
|
| 277 |
+
raise RuntimeError(f"payment {number} is {status or 'not voided'}: {todo}")
|
| 278 |
+
invoice = str(e["number"]).removesuffix("-PAY")
|
| 279 |
+
inv = _first(svc, base_url, auth, run_id, "invoices", f"InvoiceNumber='{_q(invoice)}'")
|
| 280 |
+
if not inv or _status(inv.get("PaymentStatus") or inv.get("PaymentStatusCode")) not in ("paid", "partially paid", "y", "p"):
|
| 281 |
+
return "no payment made, nothing to clean up"
|
| 282 |
+
raise RuntimeError(f"invoice {invoice} is paid and its payment's number is not known: {todo}")
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
def _clean_approval(svc, base_url: str, auth, e: dict, run_id: str) -> str:
|
| 286 |
+
"""Mirror of rest.ts cleanApproval: a test invoice sent for approval (the ledger's number is "<invoice>-APR"). The approval is
|
| 287 |
+
withdrawn on the screens only, so one still under way is left for a person (the invoice stays until it is withdrawn)."""
|
| 288 |
+
invoice = str(e["number"]).removesuffix("-APR")
|
| 289 |
+
inv = _first(svc, base_url, auth, run_id, "invoices", f"InvoiceNumber='{_q(invoice)}'")
|
| 290 |
+
if not inv:
|
| 291 |
+
return f"invoice {invoice} not in Fusion, no approval to withdraw"
|
| 292 |
+
if inv.get("CanceledFlag"):
|
| 293 |
+
return f"invoice {invoice} already cancelled, no approval to withdraw"
|
| 294 |
+
if _in_approval(inv):
|
| 295 |
+
raise RuntimeError(f"invoice {invoice} is in approval ({_in_approval(inv)}): {APPROVAL_TODO}")
|
| 296 |
+
return f"invoice {invoice}: approval not under way, nothing to withdraw"
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
CLEANERS = {"ap_approval": _clean_approval, "ap_payment": _clean_payment, "ap_invoice": _cancel_one, "po_requisition": _clean_requisition, "po_order": _clean_order, "gl_journal": _clean_journal,
|
| 300 |
"ar_transaction": _clean_transaction, "ar_receipt": _clean_receipt, "po_receipt": _clean_po_receipt}
|
| 301 |
RECEIPT_RESOURCES = ("receivingReceiptRequests", "receivingReceiptTransactions")
|
| 302 |
|
|
|
|
| 313 |
reg = PodRegistry(svc.db, svc.vault, svc.cfg, svc.egress, svc.audit)
|
| 314 |
cleaned, remaining = [], []
|
| 315 |
received: set[str] = set() # orders whose receipt a person has to undo (the receipts go first, see below)
|
| 316 |
+
left.sort(key=lambda x: (x.get("kind") != "ap_payment", x.get("kind") != "po_receipt")) # a payment is voided before its invoice is cancelled
|
| 317 |
try:
|
| 318 |
pod = reg.get(pid)
|
| 319 |
auth = reg.fusion_auth(pid)
|
coworker/platform/left_on_pod.py
CHANGED
|
@@ -25,13 +25,15 @@ from .rundb import now_iso
|
|
| 25 |
|
| 26 |
log = logging.getLogger("fpt.left_on_pod")
|
| 27 |
|
| 28 |
-
KINDS = ("ap_invoice", "po_requisition", "po_order", "po_receipt", "gl_journal", "ar_transaction", "ar_receipt")
|
| 29 |
STATES = ("open", "done", "dismissed")
|
| 30 |
STILL, RESOLVED, UNKNOWN = "still_on_pod", "looks_resolved", "unknown"
|
| 31 |
|
| 32 |
# what a person does when the clean-up's own sentence ("<why>: <what to do>") does not say
|
| 33 |
TODO = {
|
| 34 |
"ap_invoice": "Cancel it on Payables > Invoices > Manage Invoices (Actions > Cancel Invoice).",
|
|
|
|
|
|
|
| 35 |
"po_requisition": "Cancel it on Purchasing > Manage Requisitions.",
|
| 36 |
"po_order": "Open it on Purchasing > Manage Orders, then cancel it (withdraw it first when it is pending approval).",
|
| 37 |
"po_receipt": "Correct or return the receipt on Receiving > Manage Receipts, then cancel or close the order.",
|
|
@@ -239,6 +241,20 @@ def _check(svc, base_url: str, auth, row: dict) -> tuple[str, str]:
|
|
| 239 |
if not inv:
|
| 240 |
return RESOLVED, gone
|
| 241 |
return STILL, "it is on the pod, cancelled" if inv.get("CanceledFlag") else "it is on the pod, not cancelled"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
if kind == "po_receipt":
|
| 243 |
answered = False
|
| 244 |
for resource in cleanup.RECEIPT_RESOURCES:
|
|
|
|
| 25 |
|
| 26 |
log = logging.getLogger("fpt.left_on_pod")
|
| 27 |
|
| 28 |
+
KINDS = ("ap_invoice", "ap_payment", "ap_approval", "po_requisition", "po_order", "po_receipt", "gl_journal", "ar_transaction", "ar_receipt")
|
| 29 |
STATES = ("open", "done", "dismissed")
|
| 30 |
STILL, RESOLVED, UNKNOWN = "still_on_pod", "looks_resolved", "unknown"
|
| 31 |
|
| 32 |
# what a person does when the clean-up's own sentence ("<why>: <what to do>") does not say
|
| 33 |
TODO = {
|
| 34 |
"ap_invoice": "Cancel it on Payables > Invoices > Manage Invoices (Actions > Cancel Invoice).",
|
| 35 |
+
"ap_payment": "Void it on Payables > Payments > Manage Payments (Actions > Void Payment), then cancel its invoice.",
|
| 36 |
+
"ap_approval": "Withdraw the approval on Payables > Invoices > Manage Invoices (Invoice Actions > Approval > Withdraw), then cancel the invoice.",
|
| 37 |
"po_requisition": "Cancel it on Purchasing > Manage Requisitions.",
|
| 38 |
"po_order": "Open it on Purchasing > Manage Orders, then cancel it (withdraw it first when it is pending approval).",
|
| 39 |
"po_receipt": "Correct or return the receipt on Receiving > Manage Receipts, then cancel or close the order.",
|
|
|
|
| 241 |
if not inv:
|
| 242 |
return RESOLVED, gone
|
| 243 |
return STILL, "it is on the pod, cancelled" if inv.get("CanceledFlag") else "it is on the pod, not cancelled"
|
| 244 |
+
if kind == "ap_payment":
|
| 245 |
+
look_up = look("invoices", f"InvoiceNumber='{tag.removesuffix('-PAY')}'")
|
| 246 |
+
if not look_up:
|
| 247 |
+
return RESOLVED, gone
|
| 248 |
+
paid = _status(look_up.get("PaymentStatus") or look_up.get("PaymentStatusCode")) in ("paid", "partially paid", "y", "p")
|
| 249 |
+
return (STILL, "its invoice is on the pod, paid") if paid else (RESOLVED, "its invoice is on the pod, not paid: no payment stands")
|
| 250 |
+
if kind == "ap_approval":
|
| 251 |
+
look_up = look("invoices", f"InvoiceNumber='{tag.removesuffix('-APR')}'")
|
| 252 |
+
if not look_up:
|
| 253 |
+
return RESOLVED, gone
|
| 254 |
+
if look_up.get("CanceledFlag"):
|
| 255 |
+
return RESOLVED, "its invoice is on the pod, cancelled"
|
| 256 |
+
under_way = cleanup._in_approval(look_up)
|
| 257 |
+
return (STILL, f"its invoice is on the pod, in approval ({under_way})") if under_way else (RESOLVED, "its invoice is on the pod, its approval is not under way")
|
| 258 |
if kind == "po_receipt":
|
| 259 |
answered = False
|
| 260 |
for resource in cleanup.RECEIPT_RESOURCES:
|
coworker/platform/migrations/031_pod_nav_links.sql
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-- 031: per-pod Fusion navigation links (platform/pods.py set_nav_links). Fusion menus differ per role and setup, so a
|
| 2 |
+
-- consultant pastes the address of a work area Astra cannot reach through the menus; runs open it directly (FPT_NAV_LINKS).
|
| 3 |
+
-- JSON {"Group > Page": "https://<pod host>/fscmUI/..."}.
|
| 4 |
+
ALTER TABLE pods ADD COLUMN nav_links TEXT;
|
coworker/platform/pods.py
CHANGED
|
@@ -30,6 +30,7 @@ RELEASE_RE = re.compile(r"\d{2}[A-D]")
|
|
| 30 |
FLAG_WORDS = frozenset({"yes", "no", "true", "false", "none", "all", "on", "off", "y", "n"})
|
| 31 |
_PROD_HOST = re.compile(r"(^|[.-])prod(uction)?([.-]|\d|$)", re.I)
|
| 32 |
SIGN_IN_MODES = ("password", "assisted")
|
|
|
|
| 33 |
ASSISTED_WORDS = "Assisted sign-in: a person signs in at the start of the run."
|
| 34 |
ASSISTED_NO_REST = ("this pod uses assisted sign-in (a person signs in through the company's identity provider at the start "
|
| 35 |
"of each run), so there is no test user password for Fusion REST")
|
|
@@ -175,6 +176,7 @@ class PodRegistry:
|
|
| 175 |
return {**r, "modules": mods, "sign_in_mode": r.get("sign_in_mode") or "password", "from_server_settings": self.is_env_pod(r), "enabled": bool(r["enabled"]), "is_default": bool(r["is_default"]),
|
| 176 |
"discovery": disc, "test_data": discovery.merged_test_data(*self._test_data_sources(r["id"])),
|
| 177 |
"test_data_overrides": _json(r.get("test_data_overrides"), {}),
|
|
|
|
| 178 |
"run_areas": self.run_areas({"kind": r["kind"], "discovery": disc}),
|
| 179 |
"screens": _json(r.get("screens"), None),
|
| 180 |
"last_check_ok": None if r["last_check_ok"] is None else bool(r["last_check_ok"]),
|
|
@@ -363,9 +365,11 @@ class PodRegistry:
|
|
| 363 |
first = {**p["test_data"], **{a: {**(p["test_data"].get(a) or {}), **{k: v[0] for k, v in keys.items() if v}} for a, keys in cands.items()}}
|
| 364 |
mode = {"FPT_SIGN_IN_MODE": "assisted"} if assisted(p) else {}
|
| 365 |
from .healing import heal_map
|
|
|
|
| 366 |
heals = heal_map(self.db, pod_id) # names a person approved for controls Oracle relabelled (ui.ts tries them first)
|
| 367 |
return {"FUSION_BASE_URL": p["base_url"], "FUSION_USERNAME": auth[0], "FUSION_PASSWORD": auth[1], **mode,
|
| 368 |
**({"FPT_HEALS": json.dumps(heals)} if heals else {}),
|
|
|
|
| 369 |
"FUSION_TESTDATA": json.dumps(first), # {{pod.<area>.<key>}} in test steps (automation/src/fusion/ui.ts)
|
| 370 |
# the values to try in order when Fusion refuses one (not in this user's list)
|
| 371 |
"FUSION_TESTDATA_CANDIDATES": json.dumps(cands),
|
|
@@ -476,7 +480,9 @@ class PodRegistry:
|
|
| 476 |
return _json((self.db.one("SELECT usage FROM pods WHERE id=?", (pod_id,)) or {}).get("usage"), None)
|
| 477 |
|
| 478 |
def coverage(self, pod_id: int, scenarios: list[dict]) -> dict:
|
| 479 |
-
|
|
|
|
|
|
|
| 480 |
|
| 481 |
def set_test_data(self, pod_id: int, overrides: dict, actor: str) -> dict:
|
| 482 |
"""The admin's own test data values, by area and key; they win over discovered ones. An empty value removes one."""
|
|
@@ -495,6 +501,44 @@ class PodRegistry:
|
|
| 495 |
payload={"pod_id": pod_id, "keys": {a: sorted(v) for a, v in clean.items()}})
|
| 496 |
return self.get(pod_id)
|
| 497 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 498 |
# ------------------------------------------------------------ screens (read-only, in a real browser)
|
| 499 |
def screens_dir(self, pod_id: int):
|
| 500 |
return self.cfg.home / "screens" / str(int(pod_id))
|
|
|
|
| 30 |
FLAG_WORDS = frozenset({"yes", "no", "true", "false", "none", "all", "on", "off", "y", "n"})
|
| 31 |
_PROD_HOST = re.compile(r"(^|[.-])prod(uction)?([.-]|\d|$)", re.I)
|
| 32 |
SIGN_IN_MODES = ("password", "assisted")
|
| 33 |
+
NAV_LINKS_MAX = 30
|
| 34 |
ASSISTED_WORDS = "Assisted sign-in: a person signs in at the start of the run."
|
| 35 |
ASSISTED_NO_REST = ("this pod uses assisted sign-in (a person signs in through the company's identity provider at the start "
|
| 36 |
"of each run), so there is no test user password for Fusion REST")
|
|
|
|
| 176 |
return {**r, "modules": mods, "sign_in_mode": r.get("sign_in_mode") or "password", "from_server_settings": self.is_env_pod(r), "enabled": bool(r["enabled"]), "is_default": bool(r["is_default"]),
|
| 177 |
"discovery": disc, "test_data": discovery.merged_test_data(*self._test_data_sources(r["id"])),
|
| 178 |
"test_data_overrides": _json(r.get("test_data_overrides"), {}),
|
| 179 |
+
"nav_links": _json(r.get("nav_links"), {}) or {},
|
| 180 |
"run_areas": self.run_areas({"kind": r["kind"], "discovery": disc}),
|
| 181 |
"screens": _json(r.get("screens"), None),
|
| 182 |
"last_check_ok": None if r["last_check_ok"] is None else bool(r["last_check_ok"]),
|
|
|
|
| 365 |
first = {**p["test_data"], **{a: {**(p["test_data"].get(a) or {}), **{k: v[0] for k, v in keys.items() if v}} for a, keys in cands.items()}}
|
| 366 |
mode = {"FPT_SIGN_IN_MODE": "assisted"} if assisted(p) else {}
|
| 367 |
from .healing import heal_map
|
| 368 |
+
links = self.nav_links(pod_id) # work areas a consultant opened by hand; ui.ts opens them by address (FPT_NAV_LINKS)
|
| 369 |
heals = heal_map(self.db, pod_id) # names a person approved for controls Oracle relabelled (ui.ts tries them first)
|
| 370 |
return {"FUSION_BASE_URL": p["base_url"], "FUSION_USERNAME": auth[0], "FUSION_PASSWORD": auth[1], **mode,
|
| 371 |
**({"FPT_HEALS": json.dumps(heals)} if heals else {}),
|
| 372 |
+
**({"FPT_NAV_LINKS": json.dumps(links)} if links else {}),
|
| 373 |
"FUSION_TESTDATA": json.dumps(first), # {{pod.<area>.<key>}} in test steps (automation/src/fusion/ui.ts)
|
| 374 |
# the values to try in order when Fusion refuses one (not in this user's list)
|
| 375 |
"FUSION_TESTDATA_CANDIDATES": json.dumps(cands),
|
|
|
|
| 480 |
return _json((self.db.one("SELECT usage FROM pods WHERE id=?", (pod_id,)) or {}).get("usage"), None)
|
| 481 |
|
| 482 |
def coverage(self, pod_id: int, scenarios: list[dict]) -> dict:
|
| 483 |
+
# the pod's own test data (kept here): a dimension that says where the client works is covered by the scenarios that run with it
|
| 484 |
+
return {"pod_id": pod_id, **usage.coverage(self.usage(pod_id), scenarios, self.cfg.home,
|
| 485 |
+
test_data=discovery.merged_test_data(*self._test_data_sources(pod_id)))}
|
| 486 |
|
| 487 |
def set_test_data(self, pod_id: int, overrides: dict, actor: str) -> dict:
|
| 488 |
"""The admin's own test data values, by area and key; they win over discovered ones. An empty value removes one."""
|
|
|
|
| 501 |
payload={"pod_id": pod_id, "keys": {a: sorted(v) for a, v in clean.items()}})
|
| 502 |
return self.get(pod_id)
|
| 503 |
|
| 504 |
+
def nav_links(self, pod_id: int) -> dict[str, str]:
|
| 505 |
+
"""The pod's saved navigation links, {"Group > Page": address}."""
|
| 506 |
+
return _json((self.db.one("SELECT nav_links FROM pods WHERE id=?", (pod_id,)) or {}).get("nav_links"), {}) or {}
|
| 507 |
+
|
| 508 |
+
def set_nav_links(self, pod_id: int, links: dict, actor: str) -> dict[str, str]:
|
| 509 |
+
"""Replace the pod's navigation links. An address is opened in the run's signed-in browser, so it must be this pod's
|
| 510 |
+
own (same host and port, https, no credentials, under a Fusion UI path): never another site."""
|
| 511 |
+
pod = self.get(pod_id)
|
| 512 |
+
base = urlparse(pod["base_url"])
|
| 513 |
+
if len(links or {}) > NAV_LINKS_MAX:
|
| 514 |
+
raise PodError("BAD_NAV_LINK", f"at most {NAV_LINKS_MAX} navigation links per pod")
|
| 515 |
+
clean: dict[str, str] = {}
|
| 516 |
+
for key, url in (links or {}).items():
|
| 517 |
+
k = " > ".join(" ".join(part.split()) for part in str(key).split(">"))
|
| 518 |
+
if not re.fullmatch(r"[^>\s][^>]{0,59} > [^>\s][^>]{0,79}", k):
|
| 519 |
+
raise PodError("BAD_NAV_LINK", f"{key!r} is not of the form 'Group > Page'")
|
| 520 |
+
u = str(url or "").strip()
|
| 521 |
+
try:
|
| 522 |
+
pu = urlparse(u)
|
| 523 |
+
port = pu.port
|
| 524 |
+
except ValueError:
|
| 525 |
+
raise PodError("BAD_NAV_LINK", f"{k}: not a web address") from None
|
| 526 |
+
if len(u) > 2000 or re.search(r"[\x00-\x20\\]", u) or pu.scheme != "https":
|
| 527 |
+
raise PodError("BAD_NAV_LINK", f"{k}: the address must start with https:// and hold no spaces")
|
| 528 |
+
if pu.username or pu.password or "@" in pu.netloc:
|
| 529 |
+
raise PodError("BAD_NAV_LINK", f"{k}: the address must not hold a user name or password")
|
| 530 |
+
if (pu.hostname or "").lower() != (base.hostname or "").lower() or (port or 443) != (base.port or 443):
|
| 531 |
+
raise PodError("BAD_NAV_LINK", f"{k}: the address must be on this pod's own host ({base.hostname})")
|
| 532 |
+
if not re.match(r"/(fscmUI|hcmUI|crmUI)/", pu.path) or ".." in pu.path.split("/"):
|
| 533 |
+
raise PodError("BAD_NAV_LINK", f"{k}: the address must be a Fusion page (under /fscmUI/, /hcmUI/ or /crmUI/)")
|
| 534 |
+
clean[k] = u
|
| 535 |
+
if len({k.lower() for k in clean}) != len(clean):
|
| 536 |
+
raise PodError("BAD_NAV_LINK", "the same work area is listed twice")
|
| 537 |
+
self.db.update("pods", "id", pod_id, nav_links=json.dumps(clean), updated_at=now_iso())
|
| 538 |
+
self.audit.append("pod.nav_links_set", actor=actor, summary=f"pod {pod_id}: {len(clean)} navigation link(s)",
|
| 539 |
+
payload={"pod_id": pod_id, "work_areas": sorted(clean)}) # names only; the addresses stay on the pod
|
| 540 |
+
return clean
|
| 541 |
+
|
| 542 |
# ------------------------------------------------------------ screens (read-only, in a real browser)
|
| 543 |
def screens_dir(self, pod_id: int):
|
| 544 |
return self.cfg.home / "screens" / str(int(pod_id))
|
coworker/platform/step_writer.py
CHANGED
|
@@ -84,12 +84,42 @@ ALLOWED_ACTIONS: dict[str, str] = {
|
|
| 84 |
"exists and, when given, status = its status (one of Validated, Not validated, Needs revalidation, "
|
| 85 |
"Never validated, Canceled), amount = its exact amount, amount_at_least = at least this amount "
|
| 86 |
"(use it after validate_invoice: the pod may add tax), canceled = true or false, invoice_type = its "
|
| 87 |
-
"type (Standard, Credit memo, Debit memo, Prepayment), payment_method = its payment method
|
|
|
|
|
|
|
| 88 |
"remembered number's name (default invoice_number)",
|
| 89 |
"expect_hold": "Payables business action, a check in Fusion itself: the invoice created earlier carries a hold that "
|
| 90 |
"is not released. value = the hold's name. name = the remembered number's name (default invoice_number)",
|
| 91 |
"expect_no_holds": "Payables business action, a check in Fusion itself: the invoice created earlier carries no hold "
|
| 92 |
"that is not released. name = the remembered number's name (default invoice_number)",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
# Purchasing business actions, checked on the pod by tests/cases/CANARY-PO.yaml before every run
|
| 94 |
"create_requisition": "Purchasing business action, opens its own screen (no open_task before it): creates a requisition "
|
| 95 |
"of one noncatalog line (the pod's requisitioning BU, category, unit of measure and charge account "
|
|
@@ -148,8 +178,10 @@ ALLOWED_ACTIONS: dict[str, str] = {
|
|
| 148 |
"journal batch with a new test name, the ledger, period and category Fusion defaults (the pod's own "
|
| 149 |
"where it leaves one empty) and one debit and one credit of the same amount on the same account of "
|
| 150 |
"the pod, so balances do not change. value = the amount (default {{tv.amount}}); name = what to "
|
| 151 |
-
"remember the batch name as (default journal_batch, then {{saved.journal_batch}})
|
| 152 |
-
"
|
|
|
|
|
|
|
| 153 |
"post_journal": "General Ledger business action: posts the journal batch created (or remembered) earlier, opening it "
|
| 154 |
"first if it is not on the page, and waits until Fusion has posted it (or sent it for approval). "
|
| 155 |
"name = the remembered batch name's name (default journal_batch)",
|
|
@@ -158,8 +190,8 @@ ALLOWED_ACTIONS: dict[str, str] = {
|
|
| 158 |
"name's name (default journal_batch)",
|
| 159 |
"expect_journal": "General Ledger business action, a check in Fusion itself: the journal batch created (or remembered) "
|
| 160 |
"earlier exists and, when given, status = its status (one of Unposted, Posted, Selected for "
|
| 161 |
-
"posting, Posting in process), posted = true or false
|
| 162 |
-
"(default journal_batch)",
|
| 163 |
"reverse_journal": "General Ledger business action: reverses the posted journal batch created (or remembered) earlier "
|
| 164 |
"and checks that Fusion made its reversal; use it after post_journal. name = the remembered batch "
|
| 165 |
"name's name (default journal_batch)",
|
|
@@ -168,7 +200,10 @@ ALLOWED_ACTIONS: dict[str, str] = {
|
|
| 168 |
"(Incomplete) a transaction of type Invoice with one line, the pod's business unit, transaction "
|
| 169 |
"source and customer. value = the line amount (default {{tv.amount}}); name = what to remember "
|
| 170 |
"its number as (default transaction_number, then {{saved.transaction_number}}). Fails if "
|
| 171 |
-
"Fusion shows an error
|
|
|
|
|
|
|
|
|
|
| 172 |
"complete_transaction": "Receivables business action: completes the transaction created (or remembered) earlier, "
|
| 173 |
"opening it first if it is not on the page, and checks that Fusion takes it out of Incomplete. "
|
| 174 |
"name = the remembered number's name (default transaction_number)",
|
|
@@ -178,7 +213,8 @@ ALLOWED_ACTIONS: dict[str, str] = {
|
|
| 178 |
"expect_transaction": "Receivables business action, a check in Fusion itself: the transaction created (or remembered) "
|
| 179 |
"earlier exists and, when given, status = its status (one of Incomplete, Complete, Open, "
|
| 180 |
"Closed), amount = its exact amount, amount_at_least = at least this amount (the pod may add "
|
| 181 |
-
"tax)
|
|
|
|
| 182 |
"create_receipt": "Receivables business action, opens its own screen (no open_task before it): creates and saves a "
|
| 183 |
"standard receipt for the customer of the transaction created earlier, numbered with the test's tag, "
|
| 184 |
"and applies it to that transaction (left unapplied when none was created). value = the receipt "
|
|
@@ -197,7 +233,7 @@ ALLOWED_ACTIONS: dict[str, str] = {
|
|
| 197 |
BUSINESS_AREAS: dict[str, dict] = {
|
| 198 |
"AP": {"name": "Payables", "screens": ("payables",),
|
| 199 |
"actions": ("create_invoice", "validate_invoice", "find_invoice", "cancel_invoice", "expect_invoice", "expect_hold",
|
| 200 |
-
"expect_no_holds")},
|
| 201 |
"PO": {"name": "Purchasing", "screens": ("procurement", "purchasing", "receiving"),
|
| 202 |
"actions": ("create_requisition", "expect_requisition", "cancel_requisition", "create_purchase_order",
|
| 203 |
"submit_purchase_order", "find_purchase_order", "expect_purchase_order", "cancel_purchase_order",
|
|
@@ -210,14 +246,17 @@ BUSINESS_AREAS: dict[str, dict] = {
|
|
| 210 |
}
|
| 211 |
BUSINESS_ACTIONS = tuple(a for x in BUSINESS_AREAS.values() for a in x["actions"])
|
| 212 |
# actions that leave a document only a person can undo (a receipt is corrected or returned, a closed order reopened): they
|
| 213 |
-
# run in scenarios a client has agreed to, are listed in the run's test data, and are never in a canary (it runs before every run)
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
| 215 |
# what close_purchase_order closes an order as (the value, as Fusion's Close action names it) and the order status that follows
|
| 216 |
CLOSE_WAYS = ("Close for Receiving", "Close for Invoicing", "Close", "Finally Close")
|
| 217 |
CLOSE_ACTIONS = dict(zip((w.lower() for w in CLOSE_WAYS), ("Closed for Receiving", "Closed for Invoicing", "Closed", "Finally Closed")))
|
| 218 |
ACTION_AREA = {a: code for code, x in BUSINESS_AREAS.items() for a in x["actions"]}
|
| 219 |
# actions that open their own screen, so no open_task comes before them: the screen each leaves open
|
| 220 |
-
OWN_SCREEN_ACTIONS = {"create_invoice": "payables > invoices > create invoice", "find_invoice": "payables > invoices > manage invoices",
|
| 221 |
"create_requisition": "procurement > purchase requisitions > create noncatalog request",
|
| 222 |
"cancel_requisition": "procurement > purchase requisitions > manage requisitions",
|
| 223 |
"create_purchase_order": "procurement > purchase orders > create order",
|
|
@@ -236,7 +275,8 @@ DOC_KINDS = {"invoice": ("invoice_number", "create_invoice", "an invoice"),
|
|
| 236 |
"journal": ("journal_batch", "create_journal", "a journal"),
|
| 237 |
"transaction": ("transaction_number", "create_transaction", "a transaction"),
|
| 238 |
"receipt": ("receipt_number", "create_receipt", "a receipt"),
|
| 239 |
-
"po_receipt": ("po_receipt_number", "create_receipt_for_order", "a receipt of a purchase order")
|
|
|
|
| 240 |
CREATES = {creator: kind for kind, (_n, creator, _w) in DOC_KINDS.items()}
|
| 241 |
# actions that work on a document created or remembered earlier ({{saved.<name>}})
|
| 242 |
DOC_ACTIONS = {"find_invoice": "invoice", "cancel_invoice": "invoice", "expect_invoice": "invoice", "expect_hold": "invoice",
|
|
@@ -245,9 +285,14 @@ DOC_ACTIONS = {"find_invoice": "invoice", "cancel_invoice": "invoice", "expect_i
|
|
| 245 |
"expect_purchase_order": "purchase_order", "cancel_purchase_order": "purchase_order", "post_journal": "journal",
|
| 246 |
"find_journal": "journal", "expect_journal": "journal", "reverse_journal": "journal",
|
| 247 |
"complete_transaction": "transaction", "find_transaction": "transaction", "expect_transaction": "transaction",
|
| 248 |
-
"find_receipt": "receipt", "expect_receipt": "receipt", "expect_receipt_of_order": "po_receipt"
|
|
|
|
| 249 |
INVOICE_ACTIONS = tuple(a for a, k in DOC_ACTIONS.items() if k == "invoice")
|
| 250 |
INVOICE_STATUSES = ("Validated", "Not validated", "Needs revalidation", "Never validated", "Canceled")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
# the statuses each expect_ action may ask for (compared without regard to case)
|
| 252 |
STATUSES = {"expect_invoice": INVOICE_STATUSES,
|
| 253 |
"expect_requisition": ("Incomplete", "Pending approval", "Approved", "Rejected", "Withdrawn", "Returned", "Canceled"),
|
|
@@ -255,16 +300,36 @@ STATUSES = {"expect_invoice": INVOICE_STATUSES,
|
|
| 255 |
"Closed for Invoicing", "Closed", "Finally Closed", "On Hold", "Canceled"),
|
| 256 |
"expect_journal": ("Unposted", "Posted", "Selected for posting", "Posting in process"),
|
| 257 |
"expect_transaction": ("Incomplete", "Complete", "Open", "Closed"),
|
| 258 |
-
"expect_receipt": ("Applied", "Unapplied", "Partially applied", "Reversed")
|
|
|
|
| 259 |
# the business actions' own step fields, and the actions each belongs to
|
| 260 |
-
STEP_KEYS = {"status": tuple(STATUSES
|
|
|
|
| 261 |
"amount_at_least": ("expect_invoice", "expect_purchase_order", "expect_transaction"),
|
| 262 |
"canceled": ("expect_invoice", "expect_requisition", "expect_purchase_order"), "posted": ("expect_journal",),
|
|
|
|
| 263 |
"quantity": ("create_requisition", "create_purchase_order", "create_receipt_for_order", "expect_receipt_of_order"),
|
| 264 |
"price": ("create_requisition", "create_purchase_order"),
|
| 265 |
"lines": ("create_invoice",), "applies_to": ("create_receipt", "create_receipt_for_order", "expect_receipt_of_order"),
|
| 266 |
-
"invoice_type": ("create_invoice", "expect_invoice"), "payment_method": ("create_invoice", "expect_invoice")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
NUMBER_KEYS = ("amount", "amount_at_least", "quantity", "price")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
# the invoice types create_invoice enters and expect_invoice checks (Fusion's Type list); a credit or debit memo is entered
|
| 269 |
# with a negative amount, a standard invoice and a prepayment with a positive one
|
| 270 |
INVOICE_TYPES = ("Standard", "Credit memo", "Debit memo", "Prepayment")
|
|
@@ -368,7 +433,8 @@ CHECK_ACTIONS = ("expect_filled", "expect_value", "expect_status", "expect_no_er
|
|
| 368 |
"find_invoice", "cancel_invoice", "expect_invoice", "expect_hold", "expect_no_holds",
|
| 369 |
"expect_requisition", "cancel_requisition", "find_purchase_order", "expect_purchase_order",
|
| 370 |
"cancel_purchase_order", "find_journal", "expect_journal", "reverse_journal", "find_transaction",
|
| 371 |
-
"expect_transaction", "find_receipt", "expect_receipt", "expect_receipt_of_order"
|
|
|
|
| 372 |
# a pod placeholder belongs to one kind of field: the supplier's name never goes into Supplier Site, and so on
|
| 373 |
PLACEHOLDER_FIELDS = {"pod.ap.business_unit": "business unit", "pod.ap.supplier": "supplier", "pod.ap.account": "account"}
|
| 374 |
# a pod value fits a field whose name holds its words and no qualifier it lacks: the customer goes into "Bill-to
|
|
@@ -410,6 +476,40 @@ def _screen_facts(inv: dict) -> SimpleNamespace:
|
|
| 410 |
has_number="number" in labels)
|
| 411 |
|
| 412 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
def check_steps(draft: StepsDraft | dict, inv: dict, intent_type: str = "happy", flow: list[dict] | None = None,
|
| 414 |
pod_keys: set[str] | None = None) -> list[str]:
|
| 415 |
"""Every problem that would make the step runner fail or guess. Empty list = the steps may be drafted.
|
|
@@ -435,7 +535,15 @@ def check_steps(draft: StepsDraft | dict, inv: dict, intent_type: str = "happy",
|
|
| 435 |
orders_made: set[str] = set() # purchase orders create_purchase_order made, by remembered name
|
| 436 |
orders_submitted: set[str] = set() # ... and the ones submit_purchase_order submitted
|
| 437 |
orders_closed: set[str] = set() # ... and the ones close_purchase_order closed
|
|
|
|
|
|
|
|
|
|
| 438 |
invoice_made: dict[str, tuple[str, str]] = {} # per remembered invoice name: the type and payment method create_invoice gave it
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
|
| 440 |
# the catalog's test data, and whatever else this pod offers for the area (`pod_keys`: values read from its screens)
|
| 441 |
allowed_pod = pod_placeholders() | set(pod_keys or ())
|
|
@@ -494,7 +602,7 @@ def check_steps(draft: StepsDraft | dict, inv: dict, intent_type: str = "happy",
|
|
| 494 |
problems.append(f"step {i}: {a} needs {words} created ({creator}) or remembered (remember) earlier as "
|
| 495 |
f"'{s.name or default}'")
|
| 496 |
for k, owners in STEP_KEYS.items():
|
| 497 |
-
if getattr(s, k) not in (None, "", []) and a not in owners:
|
| 498 |
# the owners of the step's own area are named (status on create_invoice: expect_invoice)
|
| 499 |
mine = [o for o in owners if ACTION_AREA.get(o) == area] or list(owners)
|
| 500 |
problems.append(f"step {i}: {k} belongs to {' or '.join(mine)}, not {a}")
|
|
@@ -503,7 +611,7 @@ def check_steps(draft: StepsDraft | dict, inv: dict, intent_type: str = "happy",
|
|
| 503 |
problems.append(f"step {i}: {a} status '{s.status}' is not {DOC_KINDS[DOC_ACTIONS[a]][2]} status ({', '.join(STATUSES[a])})")
|
| 504 |
for k in NUMBER_KEYS:
|
| 505 |
v = getattr(s, k)
|
| 506 |
-
if a in STEP_KEYS[k] and v not in (None, "") and not AMOUNT_RE.fullmatch(str(v)):
|
| 507 |
problems.append(f"step {i}: {a} {k} must be a number or a placeholder, got '{v}'")
|
| 508 |
if a in ("create_invoice", "expect_invoice"):
|
| 509 |
kind = " ".join((s.invoice_type or "").lower().split())
|
|
@@ -535,6 +643,91 @@ def check_steps(draft: StepsDraft | dict, inv: dict, intent_type: str = "happy",
|
|
| 535 |
problems.append(f"step {i}: create_invoice {what} '{fig[0]}': a {kind} invoice has a positive amount "
|
| 536 |
"(a negative one is a credit or debit memo: invoice_type)")
|
| 537 |
invoice_made[s.name or DOC_KINDS["invoice"][0]] = (kind, (s.payment_method or "").strip())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 538 |
if a in ("create_requisition", "create_purchase_order") and not (s.price or "").strip() \
|
| 539 |
and not {"price", "amount"} & set(d.test_values):
|
| 540 |
problems.append(f"step {i}: {a} needs a price: price, or the test value 'price' ({{{{tv.price}}}})")
|
|
@@ -649,7 +842,10 @@ def check_steps(draft: StepsDraft | dict, inv: dict, intent_type: str = "happy",
|
|
| 649 |
"there; use a placeholder or let Fusion default it (check it with expect_filled)")
|
| 650 |
placeholders(i, s.value)
|
| 651 |
placeholders(i, s.field)
|
| 652 |
-
for x in [s.status, s.amount, s.amount_at_least, s.quantity, s.price, s.invoice_type, s.payment_method,
|
|
|
|
|
|
|
|
|
|
| 653 |
placeholders(i, x)
|
| 654 |
if not opened:
|
| 655 |
problems.append("the scenario never opens the screen (open_task)")
|
|
@@ -849,10 +1045,11 @@ def to_case_yaml(intent: dict, steps: dict, case_id: str, written_by: str = "mod
|
|
| 849 |
for n, s in enumerate(d.steps, start=1):
|
| 850 |
row: dict = {"n": n, "action": s.action}
|
| 851 |
for k in ("field", "fields", "value", "name", "lines", "quantity", "price", "status", "amount", "amount_at_least", "canceled",
|
| 852 |
-
"posted", "applies_to", "invoice_type", "payment_method", "expected"):
|
| 853 |
v = getattr(s, k)
|
| 854 |
if v not in (None, "", []) or (k == "value" and v == "" and s.action == "expect_value"):
|
| 855 |
row[k] = v
|
|
|
|
| 856 |
step_list.append(row)
|
| 857 |
doc = {
|
| 858 |
"id": case_id,
|
|
|
|
| 84 |
"exists and, when given, status = its status (one of Validated, Not validated, Needs revalidation, "
|
| 85 |
"Never validated, Canceled), amount = its exact amount, amount_at_least = at least this amount "
|
| 86 |
"(use it after validate_invoice: the pod may add tax), canceled = true or false, invoice_type = its "
|
| 87 |
+
"type (Standard, Credit memo, Debit memo, Prepayment), payment_method = its payment method, "
|
| 88 |
+
"approval_status = its approval status (Not required, Required, Approved ...), validation_status = "
|
| 89 |
+
"its validation status (Validated, Not validated, Needs revalidation). name = the "
|
| 90 |
"remembered number's name (default invoice_number)",
|
| 91 |
"expect_hold": "Payables business action, a check in Fusion itself: the invoice created earlier carries a hold that "
|
| 92 |
"is not released. value = the hold's name. name = the remembered number's name (default invoice_number)",
|
| 93 |
"expect_no_holds": "Payables business action, a check in Fusion itself: the invoice created earlier carries no hold "
|
| 94 |
"that is not released. name = the remembered number's name (default invoice_number)",
|
| 95 |
+
# Payments of invoices: not in the canary (a payment is made by a scenario, which voids it or leaves it to the clean-up)
|
| 96 |
+
"create_payment": "Payables business action, it opens the invoice from Manage Invoices when it is not on the page: pays the validated invoice "
|
| 97 |
+
"created (or remembered) earlier in full with a quick payment (Invoice Actions > Pay in Full), with the "
|
| 98 |
+
"pod's bank account, payment document and payment process profile. applies_to = the name the invoice "
|
| 99 |
+
"was remembered as (default invoice_number); payment_method = the method of the payment (the "
|
| 100 |
+
"invoice's own: Check, Electronic, Wire ...); payment_type = Quick (the default, the only one "
|
| 101 |
+
"created); name = what to remember the payment number as (default payment_number, then "
|
| 102 |
+
"{{saved.payment_number}}). The invoice must be validated first (validate_invoice). Clean-up "
|
| 103 |
+
"voids the payment before it cancels the invoice. Fails if Fusion shows an error",
|
| 104 |
+
"find_payment": "Payables business action, opens its own screen: searches Manage Payments for the payment created (or "
|
| 105 |
+
"remembered) earlier and checks that exactly that payment is found. name = the remembered number's name "
|
| 106 |
+
"(default payment_number)",
|
| 107 |
+
"expect_payment": "Payables business action, a check in Fusion itself: the payment created (or remembered) earlier exists "
|
| 108 |
+
"and, when given, status = its status (one of Negotiable, Voided, Issued, Cleared, Reconciled, Stopped), "
|
| 109 |
+
"amount = its exact amount, amount_at_least = at least this amount, payment_method = its payment method, "
|
| 110 |
+
"payment_type = its type (Quick, Manual, Refund, Payment Process Request). name = the remembered "
|
| 111 |
+
"number's name (default payment_number)",
|
| 112 |
+
# Invoice approval: a scenario's own (not in the canary: a pod's approval rules are its own)
|
| 113 |
+
"initiate_approval": "Payables business action, it opens the invoice from Manage Invoices when it is not on the page: sends the "
|
| 114 |
+
"validated invoice created (or remembered) earlier for approval (Invoice Actions > Approval > Initiate) "
|
| 115 |
+
"and checks Fusion shows its approval Initiated. name = the remembered number's name (default "
|
| 116 |
+
"invoice_number). The invoice must be validated first (validate_invoice). Fails, saying so, "
|
| 117 |
+
"when the pod's invoice approval is not set up (the menu offers no Initiate). Clean-up withdraws the "
|
| 118 |
+
"approval before it cancels the invoice; one it cannot withdraw is listed in the run's test data. "
|
| 119 |
+
"Check the approval status before it with expect_invoice approval_status = Required, after it Initiated",
|
| 120 |
+
"void_payment": "Payables business action: Actions > Void Payment on the payment created (or remembered) earlier, opened from "
|
| 121 |
+
"Manage Payments, and checks Fusion shows it Voided; the invoice is unpaid again. name = the remembered "
|
| 122 |
+
"number's name (default payment_number)",
|
| 123 |
# Purchasing business actions, checked on the pod by tests/cases/CANARY-PO.yaml before every run
|
| 124 |
"create_requisition": "Purchasing business action, opens its own screen (no open_task before it): creates a requisition "
|
| 125 |
"of one noncatalog line (the pod's requisitioning BU, category, unit of measure and charge account "
|
|
|
|
| 178 |
"journal batch with a new test name, the ledger, period and category Fusion defaults (the pod's own "
|
| 179 |
"where it leaves one empty) and one debit and one credit of the same amount on the same account of "
|
| 180 |
"the pod, so balances do not change. value = the amount (default {{tv.amount}}); name = what to "
|
| 181 |
+
"remember the batch name as (default journal_batch, then {{saved.journal_batch}}); category = the "
|
| 182 |
+
"journal category (Adjustment, Accrual, Allocation, Reclass ... or {{pod.gl.category}}, the pod's own "
|
| 183 |
+
"value), default the one Fusion fills; source = Manual, the only source a person can enter (the "
|
| 184 |
+
"subledger sources come from Create Accounting and are never entered). Fails if Fusion shows an error",
|
| 185 |
"post_journal": "General Ledger business action: posts the journal batch created (or remembered) earlier, opening it "
|
| 186 |
"first if it is not on the page, and waits until Fusion has posted it (or sent it for approval). "
|
| 187 |
"name = the remembered batch name's name (default journal_batch)",
|
|
|
|
| 190 |
"name's name (default journal_batch)",
|
| 191 |
"expect_journal": "General Ledger business action, a check in Fusion itself: the journal batch created (or remembered) "
|
| 192 |
"earlier exists and, when given, status = its status (one of Unposted, Posted, Selected for "
|
| 193 |
+
"posting, Posting in process), posted = true or false, category = the journal's category, source = "
|
| 194 |
+
"Manual. name = the remembered batch name's name (default journal_batch)",
|
| 195 |
"reverse_journal": "General Ledger business action: reverses the posted journal batch created (or remembered) earlier "
|
| 196 |
"and checks that Fusion made its reversal; use it after post_journal. name = the remembered batch "
|
| 197 |
"name's name (default journal_batch)",
|
|
|
|
| 200 |
"(Incomplete) a transaction of type Invoice with one line, the pod's business unit, transaction "
|
| 201 |
"source and customer. value = the line amount (default {{tv.amount}}); name = what to remember "
|
| 202 |
"its number as (default transaction_number, then {{saved.transaction_number}}). Fails if "
|
| 203 |
+
"Fusion shows an error. transaction_type = Invoice (default), Credit Memo, Debit Memo or the "
|
| 204 |
+
"pod's own type (a credit memo is entered with a negative amount, an invoice or a debit memo "
|
| 205 |
+
"with a positive one); transaction_source = the pod's source, Manual for a transaction keyed in "
|
| 206 |
+
"on the screen (the pod's default when not given; an import is not made from a screen)",
|
| 207 |
"complete_transaction": "Receivables business action: completes the transaction created (or remembered) earlier, "
|
| 208 |
"opening it first if it is not on the page, and checks that Fusion takes it out of Incomplete. "
|
| 209 |
"name = the remembered number's name (default transaction_number)",
|
|
|
|
| 213 |
"expect_transaction": "Receivables business action, a check in Fusion itself: the transaction created (or remembered) "
|
| 214 |
"earlier exists and, when given, status = its status (one of Incomplete, Complete, Open, "
|
| 215 |
"Closed), amount = its exact amount, amount_at_least = at least this amount (the pod may add "
|
| 216 |
+
"tax), transaction_type = its type (Invoice, Credit Memo, Debit Memo ...), transaction_source = "
|
| 217 |
+
"its source (Manual ...). name = the remembered number's name (default transaction_number)",
|
| 218 |
"create_receipt": "Receivables business action, opens its own screen (no open_task before it): creates and saves a "
|
| 219 |
"standard receipt for the customer of the transaction created earlier, numbered with the test's tag, "
|
| 220 |
"and applies it to that transaction (left unapplied when none was created). value = the receipt "
|
|
|
|
| 233 |
BUSINESS_AREAS: dict[str, dict] = {
|
| 234 |
"AP": {"name": "Payables", "screens": ("payables",),
|
| 235 |
"actions": ("create_invoice", "validate_invoice", "find_invoice", "cancel_invoice", "expect_invoice", "expect_hold",
|
| 236 |
+
"expect_no_holds", "create_payment", "find_payment", "expect_payment", "void_payment", "initiate_approval")},
|
| 237 |
"PO": {"name": "Purchasing", "screens": ("procurement", "purchasing", "receiving"),
|
| 238 |
"actions": ("create_requisition", "expect_requisition", "cancel_requisition", "create_purchase_order",
|
| 239 |
"submit_purchase_order", "find_purchase_order", "expect_purchase_order", "cancel_purchase_order",
|
|
|
|
| 246 |
}
|
| 247 |
BUSINESS_ACTIONS = tuple(a for x in BUSINESS_AREAS.values() for a in x["actions"])
|
| 248 |
# actions that leave a document only a person can undo (a receipt is corrected or returned, a closed order reopened): they
|
| 249 |
+
# run in scenarios a client has agreed to, are listed in the run's test data, and are never in a canary (it runs before every run).
|
| 250 |
+
# The payment actions are scenario-only too, but a payment is not left: the clean-up voids it (on the screens) before it cancels the invoice
|
| 251 |
+
# (a payment Fusion does not let the clean-up void is listed in the run's test data like the others)
|
| 252 |
+
SCENARIO_ONLY_ACTIONS = ("create_receipt_for_order", "expect_receipt_of_order", "close_purchase_order",
|
| 253 |
+
"create_payment", "find_payment", "expect_payment", "void_payment", "initiate_approval")
|
| 254 |
# what close_purchase_order closes an order as (the value, as Fusion's Close action names it) and the order status that follows
|
| 255 |
CLOSE_WAYS = ("Close for Receiving", "Close for Invoicing", "Close", "Finally Close")
|
| 256 |
CLOSE_ACTIONS = dict(zip((w.lower() for w in CLOSE_WAYS), ("Closed for Receiving", "Closed for Invoicing", "Closed", "Finally Closed")))
|
| 257 |
ACTION_AREA = {a: code for code, x in BUSINESS_AREAS.items() for a in x["actions"]}
|
| 258 |
# actions that open their own screen, so no open_task comes before them: the screen each leaves open
|
| 259 |
+
OWN_SCREEN_ACTIONS = {"create_invoice": "payables > invoices > create invoice", "find_invoice": "payables > invoices > manage invoices", "find_payment": "payables > payments > manage payments",
|
| 260 |
"create_requisition": "procurement > purchase requisitions > create noncatalog request",
|
| 261 |
"cancel_requisition": "procurement > purchase requisitions > manage requisitions",
|
| 262 |
"create_purchase_order": "procurement > purchase orders > create order",
|
|
|
|
| 275 |
"journal": ("journal_batch", "create_journal", "a journal"),
|
| 276 |
"transaction": ("transaction_number", "create_transaction", "a transaction"),
|
| 277 |
"receipt": ("receipt_number", "create_receipt", "a receipt"),
|
| 278 |
+
"po_receipt": ("po_receipt_number", "create_receipt_for_order", "a receipt of a purchase order"),
|
| 279 |
+
"payment": ("payment_number", "create_payment", "a payment")}
|
| 280 |
CREATES = {creator: kind for kind, (_n, creator, _w) in DOC_KINDS.items()}
|
| 281 |
# actions that work on a document created or remembered earlier ({{saved.<name>}})
|
| 282 |
DOC_ACTIONS = {"find_invoice": "invoice", "cancel_invoice": "invoice", "expect_invoice": "invoice", "expect_hold": "invoice",
|
|
|
|
| 285 |
"expect_purchase_order": "purchase_order", "cancel_purchase_order": "purchase_order", "post_journal": "journal",
|
| 286 |
"find_journal": "journal", "expect_journal": "journal", "reverse_journal": "journal",
|
| 287 |
"complete_transaction": "transaction", "find_transaction": "transaction", "expect_transaction": "transaction",
|
| 288 |
+
"find_receipt": "receipt", "expect_receipt": "receipt", "expect_receipt_of_order": "po_receipt",
|
| 289 |
+
"find_payment": "payment", "expect_payment": "payment", "void_payment": "payment", "initiate_approval": "invoice"}
|
| 290 |
INVOICE_ACTIONS = tuple(a for a, k in DOC_ACTIONS.items() if k == "invoice")
|
| 291 |
INVOICE_STATUSES = ("Validated", "Not validated", "Needs revalidation", "Never validated", "Canceled")
|
| 292 |
+
VALIDATION_STATUSES = INVOICE_STATUSES[:4]
|
| 293 |
+
APPROVAL_STATUSES = ("Not required", "Required", "Approved", "Initiated", "Rejected", "Manually approved", "Workflow approved", "Withdrawn")
|
| 294 |
+
PAYMENT_STATUSES = ("Negotiable", "Voided", "Issued", "Cleared", "Reconciled", "Stopped")
|
| 295 |
+
PAYMENT_TYPES = ("Quick", "Manual", "Refund", "Payment Process Request")
|
| 296 |
# the statuses each expect_ action may ask for (compared without regard to case)
|
| 297 |
STATUSES = {"expect_invoice": INVOICE_STATUSES,
|
| 298 |
"expect_requisition": ("Incomplete", "Pending approval", "Approved", "Rejected", "Withdrawn", "Returned", "Canceled"),
|
|
|
|
| 300 |
"Closed for Invoicing", "Closed", "Finally Closed", "On Hold", "Canceled"),
|
| 301 |
"expect_journal": ("Unposted", "Posted", "Selected for posting", "Posting in process"),
|
| 302 |
"expect_transaction": ("Incomplete", "Complete", "Open", "Closed"),
|
| 303 |
+
"expect_receipt": ("Applied", "Unapplied", "Partially applied", "Reversed"),
|
| 304 |
+
"expect_payment": PAYMENT_STATUSES}
|
| 305 |
# the business actions' own step fields, and the actions each belongs to
|
| 306 |
+
STEP_KEYS = {"status": tuple(a for a in STATUSES if a != "expect_payment"),
|
| 307 |
+
"amount": ("expect_invoice", "expect_purchase_order", "expect_transaction", "expect_receipt"),
|
| 308 |
"amount_at_least": ("expect_invoice", "expect_purchase_order", "expect_transaction"),
|
| 309 |
"canceled": ("expect_invoice", "expect_requisition", "expect_purchase_order"), "posted": ("expect_journal",),
|
| 310 |
+
"category": ("create_journal", "expect_journal"), "source": ("create_journal", "expect_journal"),
|
| 311 |
"quantity": ("create_requisition", "create_purchase_order", "create_receipt_for_order", "expect_receipt_of_order"),
|
| 312 |
"price": ("create_requisition", "create_purchase_order"),
|
| 313 |
"lines": ("create_invoice",), "applies_to": ("create_receipt", "create_receipt_for_order", "expect_receipt_of_order"),
|
| 314 |
+
"invoice_type": ("create_invoice", "expect_invoice"), "payment_method": ("create_invoice", "expect_invoice"),
|
| 315 |
+
"payment_type": ("create_payment", "expect_payment"), "approval_status": ("expect_invoice",),
|
| 316 |
+
"validation_status": ("expect_invoice",)}
|
| 317 |
+
# the payment actions that also take some of those fields (named apart so the messages about the other actions stay as they were)
|
| 318 |
+
STEP_KEYS_OF_PAYMENTS = {"status": ("expect_payment",), "amount": ("expect_payment",), "amount_at_least": ("expect_payment",),
|
| 319 |
+
"applies_to": ("create_payment",), "payment_method": ("create_payment", "expect_payment")}
|
| 320 |
NUMBER_KEYS = ("amount", "amount_at_least", "quantity", "price")
|
| 321 |
+
# journal categories and the one source a person can enter: the other sources (Payables, Receivables, Projects, Payroll, Cash
|
| 322 |
+
# Management ...) are made by Create Accounting and transfers, never entered, so no step asks for them
|
| 323 |
+
JOURNAL_CATEGORY_RE = re.compile(r"[A-Za-z][A-Za-z0-9 &/_.()-]{0,39}")
|
| 324 |
+
JOURNAL_SOURCES = ("Manual",)
|
| 325 |
+
# Receivables: the transaction type and source create_transaction enters and expect_transaction checks (a pod's own types and
|
| 326 |
+
# sources are written as they are, or as a {{tv.<key>}}); a credit memo is entered with a negative amount, an invoice or a
|
| 327 |
+
# debit memo with a positive one. An import (Receivables Import) is a scheduled process, not keyed in on a screen.
|
| 328 |
+
TRANSACTION_TYPES = ("Invoice", "Credit Memo", "Debit Memo")
|
| 329 |
+
TRANSACTION_NAME_RE = re.compile(r"[A-Za-z][A-Za-z0-9 &/_.()-]{0,59}") # a type's or source's name as the pod writes it
|
| 330 |
+
IMPORT_SOURCE_RE = re.compile(r"\b(import|imported|autoinvoice)\b", re.I)
|
| 331 |
+
AR_STEP_FIELDS = ("transaction_type", "transaction_source")
|
| 332 |
+
STEP_KEYS.update({k: ("create_transaction", "expect_transaction") for k in AR_STEP_FIELDS})
|
| 333 |
# the invoice types create_invoice enters and expect_invoice checks (Fusion's Type list); a credit or debit memo is entered
|
| 334 |
# with a negative amount, a standard invoice and a prepayment with a positive one
|
| 335 |
INVOICE_TYPES = ("Standard", "Credit memo", "Debit memo", "Prepayment")
|
|
|
|
| 433 |
"find_invoice", "cancel_invoice", "expect_invoice", "expect_hold", "expect_no_holds",
|
| 434 |
"expect_requisition", "cancel_requisition", "find_purchase_order", "expect_purchase_order",
|
| 435 |
"cancel_purchase_order", "find_journal", "expect_journal", "reverse_journal", "find_transaction",
|
| 436 |
+
"expect_transaction", "find_receipt", "expect_receipt", "expect_receipt_of_order", "find_payment", "expect_payment",
|
| 437 |
+
"void_payment")
|
| 438 |
# a pod placeholder belongs to one kind of field: the supplier's name never goes into Supplier Site, and so on
|
| 439 |
PLACEHOLDER_FIELDS = {"pod.ap.business_unit": "business unit", "pod.ap.supplier": "supplier", "pod.ap.account": "account"}
|
| 440 |
# a pod value fits a field whose name holds its words and no qualifier it lacks: the customer goes into "Bill-to
|
|
|
|
| 476 |
has_number="number" in labels)
|
| 477 |
|
| 478 |
|
| 479 |
+
def _transaction_problems(i: int, s, test_values: dict, made: dict[str, tuple[str, str]]) -> list[str]:
|
| 480 |
+
"""The checks of create_transaction's and expect_transaction's transaction_type and transaction_source: a name as the pod
|
| 481 |
+
writes it, a source keyed in on the screen, the sign Fusion enforces on the amount, and no expectation the transaction
|
| 482 |
+
was not created with. `made` remembers per transaction name what create_transaction gave it."""
|
| 483 |
+
a, out = s.action, []
|
| 484 |
+
kind = " ".join((s.transaction_type or "").lower().split())
|
| 485 |
+
source = " ".join((s.transaction_source or "").lower().split())
|
| 486 |
+
for what, text in (("transaction_type", s.transaction_type), ("transaction_source", s.transaction_source)):
|
| 487 |
+
t = (text or "").strip()
|
| 488 |
+
if text is not None and not (PH_RE.search(t) or TRANSACTION_NAME_RE.fullmatch(t)):
|
| 489 |
+
out.append(f"step {i}: {a} {what} must be a name as the pod writes it ({', '.join(TRANSACTION_TYPES)} or another of the "
|
| 490 |
+
f"pod's types; the source Manual or another of the pod's), got '{text}'")
|
| 491 |
+
if source and IMPORT_SOURCE_RE.search(source) and not PH_RE.search(source):
|
| 492 |
+
out.append(f"step {i}: {a} transaction_source '{s.transaction_source}': an import is a scheduled process, it cannot be "
|
| 493 |
+
"keyed in on Create Transaction, so no scenario of the screens tests it")
|
| 494 |
+
name = s.name or DOC_KINDS["transaction"][0]
|
| 495 |
+
if a == "create_transaction":
|
| 496 |
+
for what, text in [("value", s.value)] if (s.value or "").strip() else [("test value 'amount'", "{{tv.amount}}")]:
|
| 497 |
+
fig = _figure(text, test_values)
|
| 498 |
+
if fig and kind == "credit memo" and fig[1] != -1:
|
| 499 |
+
out.append(f"step {i}: create_transaction {what} '{fig[0]}': a credit memo is entered with a negative amount in Fusion")
|
| 500 |
+
elif fig and kind in ("", "invoice", "debit memo") and fig[1] == -1:
|
| 501 |
+
out.append(f"step {i}: create_transaction {what} '{fig[0]}': {kind or 'invoice'} has a positive amount "
|
| 502 |
+
"(a negative one is a credit memo: transaction_type)")
|
| 503 |
+
made[name] = (kind or "invoice", source)
|
| 504 |
+
elif name in made:
|
| 505 |
+
if kind and kind != made[name][0]:
|
| 506 |
+
out.append(f"step {i}: expect_transaction transaction_type '{s.transaction_type}': the transaction was created as {made[name][0]}")
|
| 507 |
+
if source and made[name][1] and source != made[name][1]:
|
| 508 |
+
out.append(f"step {i}: expect_transaction transaction_source '{s.transaction_source}': the transaction was created from "
|
| 509 |
+
f"{made[name][1]}")
|
| 510 |
+
return out
|
| 511 |
+
|
| 512 |
+
|
| 513 |
def check_steps(draft: StepsDraft | dict, inv: dict, intent_type: str = "happy", flow: list[dict] | None = None,
|
| 514 |
pod_keys: set[str] | None = None) -> list[str]:
|
| 515 |
"""Every problem that would make the step runner fail or guess. Empty list = the steps may be drafted.
|
|
|
|
| 535 |
orders_made: set[str] = set() # purchase orders create_purchase_order made, by remembered name
|
| 536 |
orders_submitted: set[str] = set() # ... and the ones submit_purchase_order submitted
|
| 537 |
orders_closed: set[str] = set() # ... and the ones close_purchase_order closed
|
| 538 |
+
journals_made: set[str] = set() # journals create_journal made, by remembered name
|
| 539 |
+
journals_posted: set[str] = set() # journals post_journal posted, by remembered name
|
| 540 |
+
transaction_made: dict[str, tuple[str, str]] = {} # per remembered transaction name: the type and source it was created with
|
| 541 |
invoice_made: dict[str, tuple[str, str]] = {} # per remembered invoice name: the type and payment method create_invoice gave it
|
| 542 |
+
last_invoice = DOC_KINDS["invoice"][0] # the invoice create_invoice saved last: the one validate_invoice validates
|
| 543 |
+
invoices_validated: set[str] = set() # the invoices validate_invoice validated
|
| 544 |
+
payments_made: dict[str, tuple[str, str]] = {} # per remembered payment name: its invoice's name and the payment method
|
| 545 |
+
payments_open: set[str] = set() # the payments create_payment made and void_payment has not voided
|
| 546 |
+
invoices_in_approval: set[str] = set() # the invoices initiate_approval sent for approval
|
| 547 |
|
| 548 |
# the catalog's test data, and whatever else this pod offers for the area (`pod_keys`: values read from its screens)
|
| 549 |
allowed_pod = pod_placeholders() | set(pod_keys or ())
|
|
|
|
| 602 |
problems.append(f"step {i}: {a} needs {words} created ({creator}) or remembered (remember) earlier as "
|
| 603 |
f"'{s.name or default}'")
|
| 604 |
for k, owners in STEP_KEYS.items():
|
| 605 |
+
if getattr(s, k) not in (None, "", []) and a not in owners and a not in STEP_KEYS_OF_PAYMENTS.get(k, ()):
|
| 606 |
# the owners of the step's own area are named (status on create_invoice: expect_invoice)
|
| 607 |
mine = [o for o in owners if ACTION_AREA.get(o) == area] or list(owners)
|
| 608 |
problems.append(f"step {i}: {k} belongs to {' or '.join(mine)}, not {a}")
|
|
|
|
| 611 |
problems.append(f"step {i}: {a} status '{s.status}' is not {DOC_KINDS[DOC_ACTIONS[a]][2]} status ({', '.join(STATUSES[a])})")
|
| 612 |
for k in NUMBER_KEYS:
|
| 613 |
v = getattr(s, k)
|
| 614 |
+
if (a in STEP_KEYS[k] or a in STEP_KEYS_OF_PAYMENTS.get(k, ())) and v not in (None, "") and not AMOUNT_RE.fullmatch(str(v)):
|
| 615 |
problems.append(f"step {i}: {a} {k} must be a number or a placeholder, got '{v}'")
|
| 616 |
if a in ("create_invoice", "expect_invoice"):
|
| 617 |
kind = " ".join((s.invoice_type or "").lower().split())
|
|
|
|
| 643 |
problems.append(f"step {i}: create_invoice {what} '{fig[0]}': a {kind} invoice has a positive amount "
|
| 644 |
"(a negative one is a credit or debit memo: invoice_type)")
|
| 645 |
invoice_made[s.name or DOC_KINDS["invoice"][0]] = (kind, (s.payment_method or "").strip())
|
| 646 |
+
last_invoice = s.name or DOC_KINDS["invoice"][0]
|
| 647 |
+
if a == "validate_invoice":
|
| 648 |
+
invoices_validated.add(last_invoice)
|
| 649 |
+
if a == "expect_invoice":
|
| 650 |
+
if s.validation_status and not PH_RE.search(s.validation_status) \
|
| 651 |
+
and s.validation_status.strip().lower() not in {x.lower() for x in VALIDATION_STATUSES}:
|
| 652 |
+
problems.append(f"step {i}: expect_invoice validation_status '{s.validation_status}' is not a validation status "
|
| 653 |
+
f"({', '.join(VALIDATION_STATUSES)})")
|
| 654 |
+
if s.approval_status and not PH_RE.search(s.approval_status) \
|
| 655 |
+
and s.approval_status.strip().lower() not in {x.lower() for x in APPROVAL_STATUSES}:
|
| 656 |
+
problems.append(f"step {i}: expect_invoice approval_status '{s.approval_status}' is not an approval status "
|
| 657 |
+
f"({', '.join(APPROVAL_STATUSES)})")
|
| 658 |
+
if s.status and s.validation_status and not PH_RE.search(s.status + s.validation_status) \
|
| 659 |
+
and s.status.strip().lower() != s.validation_status.strip().lower():
|
| 660 |
+
problems.append(f"step {i}: expect_invoice status '{s.status}' and validation_status '{s.validation_status}' both name the "
|
| 661 |
+
"validation status and differ: give one")
|
| 662 |
+
if a == "initiate_approval":
|
| 663 |
+
name_ = s.name or DOC_KINDS["invoice"][0]
|
| 664 |
+
if name_ in invoice_made and name_ not in invoices_validated:
|
| 665 |
+
problems.append(f"step {i}: initiate_approval: only a validated invoice is sent for approval; validate_invoice '{name_}' before it")
|
| 666 |
+
if invoice_made.get(name_, ("", ""))[0] in ("credit memo", "debit memo", "prepayment"):
|
| 667 |
+
problems.append(f"step {i}: initiate_approval: send a standard invoice for approval (the invoice was created as {invoice_made[name_][0]})")
|
| 668 |
+
invoices_in_approval.add(name_)
|
| 669 |
+
if a == "cancel_invoice" and (s.name or DOC_KINDS["invoice"][0]) in invoices_in_approval:
|
| 670 |
+
problems.append(f"step {i}: cancel_invoice: the invoice was sent for approval (initiate_approval) and Fusion does not cancel an invoice "
|
| 671 |
+
"while its approval is under way; the clean-up withdraws the approval and cancels it, so leave the cancel to it")
|
| 672 |
+
if a == "cancel_invoice":
|
| 673 |
+
paid = [n for n in payments_open if payments_made[n][0] == (s.name or DOC_KINDS["invoice"][0])]
|
| 674 |
+
if paid:
|
| 675 |
+
problems.append(f"step {i}: cancel_invoice: the invoice was paid (create_payment '{paid[0]}') and Fusion does not cancel a paid "
|
| 676 |
+
f"invoice: void_payment '{paid[0]}' first")
|
| 677 |
+
if a == "create_payment":
|
| 678 |
+
inv = s.applies_to or DOC_KINDS["invoice"][0]
|
| 679 |
+
kind_ = " ".join((s.payment_type or "quick").lower().split())
|
| 680 |
+
if kind_ != "quick" and not PH_RE.search(kind_):
|
| 681 |
+
problems.append(f"step {i}: create_payment payment_type '{s.payment_type}': only a Quick payment is created "
|
| 682 |
+
f"(Manual, Refund and Payment Process Request payments are checked with expect_payment, not made)")
|
| 683 |
+
if inv not in docs["invoice"]:
|
| 684 |
+
problems.append(f"step {i}: create_payment applies_to '{inv}': no invoice is created (create_invoice) or remembered "
|
| 685 |
+
"(remember) earlier under that name")
|
| 686 |
+
elif inv in invoice_made and inv not in invoices_validated:
|
| 687 |
+
problems.append(f"step {i}: create_payment: only a validated invoice is paid; validate_invoice '{inv}' before it")
|
| 688 |
+
made_ = invoice_made.get(inv)
|
| 689 |
+
if made_ and made_[0] in ("credit memo", "debit memo"):
|
| 690 |
+
problems.append(f"step {i}: create_payment: a {made_[0]} is not paid with a quick payment; pay a standard invoice")
|
| 691 |
+
method_ = (s.payment_method or "").strip()
|
| 692 |
+
if made_ and made_[1] and method_ and not PH_RE.search(method_) and method_.lower() != made_[1].lower():
|
| 693 |
+
problems.append(f"step {i}: create_payment payment_method '{method_}': the invoice was created with {made_[1]} and is paid "
|
| 694 |
+
"with its own method")
|
| 695 |
+
payments_made[s.name or DOC_KINDS["payment"][0]] = (inv, method_ or (made_[1] if made_ else ""))
|
| 696 |
+
payments_open.add(s.name or DOC_KINDS["payment"][0])
|
| 697 |
+
if a == "expect_payment":
|
| 698 |
+
made_p = payments_made.get(s.name or DOC_KINDS["payment"][0])
|
| 699 |
+
kind_ = " ".join((s.payment_type or "").lower().split())
|
| 700 |
+
if kind_ and not PH_RE.search(kind_) and kind_ not in {t.lower() for t in PAYMENT_TYPES}:
|
| 701 |
+
problems.append(f"step {i}: expect_payment payment_type '{s.payment_type}' is not a payment type ({', '.join(PAYMENT_TYPES)})")
|
| 702 |
+
elif kind_ and made_p and kind_ != "quick":
|
| 703 |
+
problems.append(f"step {i}: expect_payment payment_type '{s.payment_type}': the payment was made as a Quick payment")
|
| 704 |
+
method_ = (s.payment_method or "").strip()
|
| 705 |
+
if method_ and not (PH_RE.search(method_) or PAYMENT_METHOD_RE.fullmatch(method_)):
|
| 706 |
+
problems.append(f"step {i}: expect_payment payment_method must be a payment method's name (Check, Electronic, Wire or "
|
| 707 |
+
f"another of the pod's), got '{s.payment_method}'")
|
| 708 |
+
elif method_ and made_p and made_p[1] and method_.lower() != made_p[1].lower():
|
| 709 |
+
problems.append(f"step {i}: expect_payment payment_method '{method_}': the payment was made with {made_p[1]}")
|
| 710 |
+
if a == "void_payment":
|
| 711 |
+
payments_open.discard(s.name or DOC_KINDS["payment"][0])
|
| 712 |
+
if a in ("create_journal", "expect_journal"):
|
| 713 |
+
kind = (s.category or "").strip()
|
| 714 |
+
if s.category is not None and not (PH_RE.search(kind) or JOURNAL_CATEGORY_RE.fullmatch(kind)):
|
| 715 |
+
problems.append(f"step {i}: {a} category must be a journal category's name (Adjustment, Accrual, Allocation, Reclass "
|
| 716 |
+
f"or another of the pod's) or a placeholder, got '{s.category}'")
|
| 717 |
+
origin = " ".join((s.source or "").split())
|
| 718 |
+
if s.source is not None and not PH_RE.search(origin) and origin.lower() not in {x.lower() for x in JOURNAL_SOURCES}:
|
| 719 |
+
problems.append(f"step {i}: {a} source '{s.source}': a person enters only {' or '.join(JOURNAL_SOURCES)} journals; "
|
| 720 |
+
"the subledger sources (Payables, Receivables, Projects, Payroll, Cash Management) come from Create "
|
| 721 |
+
"Accounting and are tested as interfaces, not by a scenario")
|
| 722 |
+
journal = s.name or DOC_KINDS["journal"][0]
|
| 723 |
+
if (a == "reverse_journal" or (a == "expect_journal" and (s.posted or (s.status or "").lower() == "posted"))) and journal in journals_made and journal not in journals_posted:
|
| 724 |
+
problems.append(f"step {i}: {a}: the journal is not posted by then; post_journal '{journal}' before it")
|
| 725 |
+
if a == "create_journal":
|
| 726 |
+
journals_made.add(journal)
|
| 727 |
+
if a == "post_journal":
|
| 728 |
+
journals_posted.add(journal)
|
| 729 |
+
if a in ("create_transaction", "expect_transaction"):
|
| 730 |
+
problems += _transaction_problems(i, s, d.test_values, transaction_made)
|
| 731 |
if a in ("create_requisition", "create_purchase_order") and not (s.price or "").strip() \
|
| 732 |
and not {"price", "amount"} & set(d.test_values):
|
| 733 |
problems.append(f"step {i}: {a} needs a price: price, or the test value 'price' ({{{{tv.price}}}})")
|
|
|
|
| 842 |
"there; use a placeholder or let Fusion default it (check it with expect_filled)")
|
| 843 |
placeholders(i, s.value)
|
| 844 |
placeholders(i, s.field)
|
| 845 |
+
for x in [s.status, s.amount, s.amount_at_least, s.quantity, s.price, s.invoice_type, s.payment_method, s.payment_type,
|
| 846 |
+
s.approval_status, s.validation_status, s.category, s.source, *(s.lines or [])]:
|
| 847 |
+
placeholders(i, x)
|
| 848 |
+
for x in (s.transaction_type, s.transaction_source):
|
| 849 |
placeholders(i, x)
|
| 850 |
if not opened:
|
| 851 |
problems.append("the scenario never opens the screen (open_task)")
|
|
|
|
| 1045 |
for n, s in enumerate(d.steps, start=1):
|
| 1046 |
row: dict = {"n": n, "action": s.action}
|
| 1047 |
for k in ("field", "fields", "value", "name", "lines", "quantity", "price", "status", "amount", "amount_at_least", "canceled",
|
| 1048 |
+
"posted", "applies_to", "invoice_type", "payment_method", "category", "source", "expected"):
|
| 1049 |
v = getattr(s, k)
|
| 1050 |
if v not in (None, "", []) or (k == "value" and v == "" and s.action == "expect_value"):
|
| 1051 |
row[k] = v
|
| 1052 |
+
row.update({k: getattr(s, k) for k in AR_STEP_FIELDS if getattr(s, k)})
|
| 1053 |
step_list.append(row)
|
| 1054 |
doc = {
|
| 1055 |
"id": case_id,
|
coworker/platform/usage.py
CHANGED
|
@@ -47,16 +47,26 @@ class SignInRefused(RuntimeError):
|
|
| 47 |
pass
|
| 48 |
|
| 49 |
|
| 50 |
-
def _dim(key: str, label: str, field, standard=(), words: dict | None = None, labels: dict | None = None) -> dict:
|
| 51 |
"""One usage dimension: a field (or candidate field names, pods and releases differ), Oracle's standard values of it
|
| 52 |
(the only ones a model may see) and, per value, the words a scenario about that value uses. `labels` names the codes a
|
| 53 |
-
field holds instead of words ("P": "Posted"), exactly as stored (case counts: Fusion uses both).
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
|
| 57 |
PAY_METHODS = ("Check", "Electronic", "Wire", "Clearing", "Bills Payable", "Outsourced Check", "EFT")
|
| 58 |
PAY_WORDS = {"check": ["cheque", "check payment", "printed check"], "electronic": ["electronic payment", "eft"],
|
| 59 |
"eft": ["electronic payment", "eft"], "outsourced check": ["outsourced check"]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
USAGE: dict[str, list[dict]] = {
|
| 62 |
"AP": [
|
|
@@ -75,7 +85,8 @@ USAGE: dict[str, list[dict]] = {
|
|
| 75 |
_dim("payment_method", "Payment method", ["PaymentMethod", "PaymentMethodCode"], PAY_METHODS, PAY_WORDS),
|
| 76 |
_dim("approval_status", "Approval status", "ApprovalStatus",
|
| 77 |
("Approved", "Initiated", "Required", "Not required", "Rejected", "Manually approved", "Workflow approved", "Withdrawn"),
|
| 78 |
-
{"approved": ["approv"], "initiated": ["approval
|
|
|
|
| 79 |
"rejected": ["reject"], "manually approved": ["force approv", "manually approv"],
|
| 80 |
"workflow approved": ["approval workflow", "workflow approv", "invoice approval"], "withdrawn": ["withdraw"]}),
|
| 81 |
_dim("validation_status", "Validation status", "ValidationStatus", ("Validated", "Not validated", "Needs revalidation", "Canceled"),
|
|
@@ -88,9 +99,11 @@ USAGE: dict[str, list[dict]] = {
|
|
| 88 |
"words": {"with holds": ["hold"], "without holds": ["no holds", "without holds", "no hold"]}},
|
| 89 |
"dimensions": [
|
| 90 |
_dim("hold_name", "Hold", "HoldName",
|
| 91 |
-
("Line Variance", "Dist Variance", "Qty Ord", "Qty Rec", "Amt Ord", "Amt Rec", "Price", "Need Rate", "No Rate",
|
| 92 |
"Funds Hold", "Matching Required", "Max Ship Amount", "Tax Variance"),
|
| 93 |
{"line variance": ["line variance", "lines do not equal", "one cent short"], "dist variance": ["distribution variance"],
|
|
|
|
|
|
|
| 94 |
"qty ord": ["quantity ordered", "qty ord"], "qty rec": ["quantity received", "qty rec"], "amt ord": ["amount ordered"],
|
| 95 |
"amt rec": ["amount received"], "price": ["price hold", "price variance"], "need rate": ["conversion rate", "exchange rate"],
|
| 96 |
"no rate": ["conversion rate", "exchange rate"], "funds hold": ["funds"], "matching required": ["matching required", "matched to a purchase order"]}),
|
|
@@ -99,7 +112,7 @@ USAGE: dict[str, list[dict]] = {
|
|
| 99 |
_dim("payment_type", "Payment type", "PaymentType", ("Quick", "Manual", "Refund", "Payment Process Request"),
|
| 100 |
{"quick": ["quick payment", "create payment", "payment of a validated invoice"], "manual": ["manual payment"],
|
| 101 |
"refund": ["refund"], "payment process request": ["payment process request"]}),
|
| 102 |
-
_dim("payment_method", "Payment method", ["PaymentMethod", "PaymentMethodCode"], PAY_METHODS,
|
| 103 |
_dim("status", "Payment status", ["PaymentStatus", "Status"], ("Negotiable", "Voided", "Cleared", "Reconciled", "Issued", "Stopped"),
|
| 104 |
{"voided": ["void"], "cleared": ["clear"], "reconciled": ["reconcil"], "stopped": ["stop payment"]}),
|
| 105 |
]},
|
|
@@ -107,7 +120,9 @@ USAGE: dict[str, list[dict]] = {
|
|
| 107 |
"PO": [
|
| 108 |
{"resource": "purchaseOrders", "label": "Purchase orders", "key_field": "POHeaderId", "dimensions": [
|
| 109 |
_dim("document_style", "Document style", ["DocumentStyle", "Style"], ("Purchase Order",), {"purchase order": ["purchase order"]}),
|
| 110 |
-
|
|
|
|
|
|
|
| 111 |
_dim("status", "Order status", ["Status", "StatusCode"],
|
| 112 |
("Open", "Closed", "Closed for Receiving", "Closed for Invoicing", "Finally Closed", "Pending Approval", "Incomplete",
|
| 113 |
"Canceled", "On Hold", "Rejected"),
|
|
@@ -157,7 +172,7 @@ USAGE: dict[str, list[dict]] = {
|
|
| 157 |
"AutoCopy", "Closing Journal", "Consolidation", "Intercompany", "Expenses", "Cash Management", "Receipt Accounting"),
|
| 158 |
{"manual": ["create journal", "manual journal", "balanced journal", "journal entry"], "spreadsheet": ["spreadsheet", "adfdi"],
|
| 159 |
"payables": ["payables", "subledger"], "receivables": ["receivables", "subledger"], "assets": ["assets"],
|
| 160 |
-
"revaluation": ["revaluat"], "allocation": ["
|
| 161 |
"consolidation": ["consolidat"], "intercompany": ["intercompany"]}),
|
| 162 |
# journalBatches gives the status as a code; only the codes whose meaning is certain are named (seen on a 26D pod:
|
| 163 |
# P, U, u, M; the others stay "Status code <x>" rather than a guess)
|
|
@@ -473,10 +488,21 @@ def _match(phrases: list[str], text: dict[str, str]) -> str | None:
|
|
| 473 |
return None
|
| 474 |
|
| 475 |
|
| 476 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 477 |
"""Each used variant (area, dimension, value) against the scenario library: covered (a scenario that runs on Fusion
|
| 478 |
matches), practice_only (only practice-app scenarios match) or not_covered; with the matches and why. Weighted by
|
| 479 |
-
volume: a variant's weight is its share of its dimension times its resource's volume in the window.
|
|
|
|
|
|
|
|
|
|
| 480 |
from . import fusion_catalog
|
| 481 |
cat = {a["code"]: a for a in fusion_catalog.areas(home)}
|
| 482 |
texts: dict[int, dict[str, str]] = {} # read once, and only for the scenarios of the areas profiled
|
|
@@ -501,6 +527,12 @@ def coverage(prof: dict | None, scenarios: list[dict], home=None) -> dict:
|
|
| 501 |
why = _match(phrases, t)
|
| 502 |
if why:
|
| 503 |
hits.append({"id": c["id"], "title": c.get("title") or "", "target": c.get("target") or "practice", "why": why})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 504 |
fusion = [h for h in hits if h["target"] == "fusion"]
|
| 505 |
state = "covered" if fusion else "practice_only" if hits else "not_covered"
|
| 506 |
av.append({"area": code, "dimension": d["key"], "label": d["label"], "value": v["value"], "standard": v["standard"],
|
|
|
|
| 47 |
pass
|
| 48 |
|
| 49 |
|
| 50 |
+
def _dim(key: str, label: str, field, standard=(), words: dict | None = None, labels: dict | None = None, org_key: str | None = None) -> dict:
|
| 51 |
"""One usage dimension: a field (or candidate field names, pods and releases differ), Oracle's standard values of it
|
| 52 |
(the only ones a model may see) and, per value, the words a scenario about that value uses. `labels` names the codes a
|
| 53 |
+
field holds instead of words ("P": "Posted"), exactly as stored (case counts: Fusion uses both). `org_key` marks a dimension that
|
| 54 |
+
says WHERE the client works (its procurement BU), not a behaviour: it names the area's test data key holding the pod's own value
|
| 55 |
+
for it, and coverage then counts the value covered by the area's Fusion scenarios when the pod's test data has that value."""
|
| 56 |
+
return {"key": key, "label": label, "field": field, "standard": list(standard), "words": dict(words or {}), "labels": dict(labels or {}),
|
| 57 |
+
**({"org_key": org_key} if org_key else {})}
|
| 58 |
|
| 59 |
|
| 60 |
PAY_METHODS = ("Check", "Electronic", "Wire", "Clearing", "Bills Payable", "Outsourced Check", "EFT")
|
| 61 |
PAY_WORDS = {"check": ["cheque", "check payment", "printed check"], "electronic": ["electronic payment", "eft"],
|
| 62 |
"eft": ["electronic payment", "eft"], "outsourced check": ["outsourced check"]}
|
| 63 |
+
# a payment's own method: only a scenario that makes a payment by it says so (an invoice entered "for electronic payment" does not
|
| 64 |
+
# pay anything, and the bare name of a method is a word a title may use for its invoice)
|
| 65 |
+
PAID_WORDS = {"check": ["quick payment by check", "payment by check", "paid by check"],
|
| 66 |
+
"electronic": ["quick payment by electronic", "payment by electronic", "paid by electronic"],
|
| 67 |
+
"wire": ["quick payment by wire", "payment by wire", "paid by wire"], "clearing": ["payment by clearing"],
|
| 68 |
+
"bills payable": ["payment by bills payable"], "outsourced check": ["payment by outsourced check"],
|
| 69 |
+
"eft": ["quick payment by eft", "payment by eft"]}
|
| 70 |
|
| 71 |
USAGE: dict[str, list[dict]] = {
|
| 72 |
"AP": [
|
|
|
|
| 85 |
_dim("payment_method", "Payment method", ["PaymentMethod", "PaymentMethodCode"], PAY_METHODS, PAY_WORDS),
|
| 86 |
_dim("approval_status", "Approval status", "ApprovalStatus",
|
| 87 |
("Approved", "Initiated", "Required", "Not required", "Rejected", "Manually approved", "Workflow approved", "Withdrawn"),
|
| 88 |
+
{"approved": ["approv"], "initiated": ["approval initiated", "sent for approval"],
|
| 89 |
+
"required": ["approval required", "needs approval", "requires approval"], "not required": ["approval not required", "no approval"],
|
| 90 |
"rejected": ["reject"], "manually approved": ["force approv", "manually approv"],
|
| 91 |
"workflow approved": ["approval workflow", "workflow approv", "invoice approval"], "withdrawn": ["withdraw"]}),
|
| 92 |
_dim("validation_status", "Validation status", "ValidationStatus", ("Validated", "Not validated", "Needs revalidation", "Canceled"),
|
|
|
|
| 99 |
"words": {"with holds": ["hold"], "without holds": ["no holds", "without holds", "no hold"]}},
|
| 100 |
"dimensions": [
|
| 101 |
_dim("hold_name", "Hold", "HoldName",
|
| 102 |
+
("Line Variance", "Dist Variance", "Distribution Variance", "Qty Ord", "Qty Rec", "Amt Ord", "Amt Rec", "Price", "Need Rate", "No Rate",
|
| 103 |
"Funds Hold", "Matching Required", "Max Ship Amount", "Tax Variance"),
|
| 104 |
{"line variance": ["line variance", "lines do not equal", "one cent short"], "dist variance": ["distribution variance"],
|
| 105 |
+
# the pod writes the hold's name in full (seen on a 26D pod): the same words under the name as it is written
|
| 106 |
+
"distribution variance": ["distribution variance"],
|
| 107 |
"qty ord": ["quantity ordered", "qty ord"], "qty rec": ["quantity received", "qty rec"], "amt ord": ["amount ordered"],
|
| 108 |
"amt rec": ["amount received"], "price": ["price hold", "price variance"], "need rate": ["conversion rate", "exchange rate"],
|
| 109 |
"no rate": ["conversion rate", "exchange rate"], "funds hold": ["funds"], "matching required": ["matching required", "matched to a purchase order"]}),
|
|
|
|
| 112 |
_dim("payment_type", "Payment type", "PaymentType", ("Quick", "Manual", "Refund", "Payment Process Request"),
|
| 113 |
{"quick": ["quick payment", "create payment", "payment of a validated invoice"], "manual": ["manual payment"],
|
| 114 |
"refund": ["refund"], "payment process request": ["payment process request"]}),
|
| 115 |
+
_dim("payment_method", "Payment method", ["PaymentMethod", "PaymentMethodCode"], PAY_METHODS, PAID_WORDS),
|
| 116 |
_dim("status", "Payment status", ["PaymentStatus", "Status"], ("Negotiable", "Voided", "Cleared", "Reconciled", "Issued", "Stopped"),
|
| 117 |
{"voided": ["void"], "cleared": ["clear"], "reconciled": ["reconcil"], "stopped": ["stop payment"]}),
|
| 118 |
]},
|
|
|
|
| 120 |
"PO": [
|
| 121 |
{"resource": "purchaseOrders", "label": "Purchase orders", "key_field": "POHeaderId", "dimensions": [
|
| 122 |
_dim("document_style", "Document style", ["DocumentStyle", "Style"], ("Purchase Order",), {"purchase order": ["purchase order"]}),
|
| 123 |
+
# the client's own units: shown here, never sent to a model; where the client works, so a scenario of the area that runs
|
| 124 |
+
# with the pod's own business unit covers it (coverage's test_data)
|
| 125 |
+
_dim("procurement_bu", "Procurement BU", "ProcurementBU", org_key="business_unit"),
|
| 126 |
_dim("status", "Order status", ["Status", "StatusCode"],
|
| 127 |
("Open", "Closed", "Closed for Receiving", "Closed for Invoicing", "Finally Closed", "Pending Approval", "Incomplete",
|
| 128 |
"Canceled", "On Hold", "Rejected"),
|
|
|
|
| 172 |
"AutoCopy", "Closing Journal", "Consolidation", "Intercompany", "Expenses", "Cash Management", "Receipt Accounting"),
|
| 173 |
{"manual": ["create journal", "manual journal", "balanced journal", "journal entry"], "spreadsheet": ["spreadsheet", "adfdi"],
|
| 174 |
"payables": ["payables", "subledger"], "receivables": ["receivables", "subledger"], "assets": ["assets"],
|
| 175 |
+
"revaluation": ["revaluat"], "allocation": ["generate allocation", "mass allocation", "allocation rule"], "autocopy": ["copy"], "closing journal": ["closing journal"],
|
| 176 |
"consolidation": ["consolidat"], "intercompany": ["intercompany"]}),
|
| 177 |
# journalBatches gives the status as a code; only the codes whose meaning is certain are named (seen on a 26D pod:
|
| 178 |
# P, U, u, M; the others stay "Status code <x>" rather than a guess)
|
|
|
|
| 488 |
return None
|
| 489 |
|
| 490 |
|
| 491 |
+
def _own_value(test_data: dict | None, area: str, key: str) -> str:
|
| 492 |
+
"""The pod's own test data value of `key` in `area` (the first one a run tries), '' when it has none. Kept on the pod: it only
|
| 493 |
+
ever goes into a comparison here, never into a result's wording and never to a model."""
|
| 494 |
+
v = ((test_data or {}).get(area) or (test_data or {}).get(area.upper()) or {}).get(key)
|
| 495 |
+
v = v[0] if isinstance(v, (list, tuple)) and v else v
|
| 496 |
+
return norm(v) if isinstance(v, str) else ""
|
| 497 |
+
|
| 498 |
+
|
| 499 |
+
def coverage(prof: dict | None, scenarios: list[dict], home=None, test_data: dict | None = None) -> dict:
|
| 500 |
"""Each used variant (area, dimension, value) against the scenario library: covered (a scenario that runs on Fusion
|
| 501 |
matches), practice_only (only practice-app scenarios match) or not_covered; with the matches and why. Weighted by
|
| 502 |
+
volume: a variant's weight is its share of its dimension times its resource's volume in the window.
|
| 503 |
+
`test_data` ({area: {key: value}}: the pod's own test data, see discovery.merged_test_data) lets a dimension that says where the
|
| 504 |
+
client works (a procurement BU: `org_key`) count as covered when a Fusion scenario of that area runs with a test data value
|
| 505 |
+
equal to it; without it such a value is matched by words only, as before."""
|
| 506 |
from . import fusion_catalog
|
| 507 |
cat = {a["code"]: a for a in fusion_catalog.areas(home)}
|
| 508 |
texts: dict[int, dict[str, str]] = {} # read once, and only for the scenarios of the areas profiled
|
|
|
|
| 527 |
why = _match(phrases, t)
|
| 528 |
if why:
|
| 529 |
hits.append({"id": c["id"], "title": c.get("title") or "", "target": c.get("target") or "practice", "why": why})
|
| 530 |
+
org = spec.get("org_key")
|
| 531 |
+
if org and _own_value(test_data, code, org) == norm(v["value"]):
|
| 532 |
+
seen = {h["id"] for h in hits}
|
| 533 |
+
hits += [{"id": c["id"], "title": c.get("title") or "", "target": "fusion",
|
| 534 |
+
"why": f"it is a Fusion scenario of this area and runs with the pod's test data for '{org}', which is this value"}
|
| 535 |
+
for c, _t in mine if c.get("target") == "fusion" and str(c.get("module") or "").upper() == code and c["id"] not in seen]
|
| 536 |
fusion = [h for h in hits if h["target"] == "fusion"]
|
| 537 |
state = "covered" if fusion else "practice_only" if hits else "not_covered"
|
| 538 |
av.append({"area": code, "dimension": d["key"], "label": d["label"], "value": v["value"], "standard": v["standard"],
|
coworker/tests/test_cov_ap_pay.py
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Payables payments and statuses (AP-FUS-020..026): the scenarios load as Fusion scenarios, use only allowed actions, pass the
|
| 2 |
+
step checks, keep payments out of the canary, and make exactly the variants they test covered in the usage coverage (a scenario
|
| 3 |
+
that creates an invoice with a method does not cover a payment by it, and the other way round)."""
|
| 4 |
+
from __future__ import annotations
|
| 5 |
+
|
| 6 |
+
import unittest
|
| 7 |
+
|
| 8 |
+
import yaml
|
| 9 |
+
|
| 10 |
+
from ..config import ROOT
|
| 11 |
+
from ..platform import step_writer as sw
|
| 12 |
+
from ..platform import usage
|
| 13 |
+
from .test_business_actions import runner_actions, yaml_draft
|
| 14 |
+
from .test_gap_scenarios import dimension_spec, library
|
| 15 |
+
from .test_po_gl_business_actions import AP_INV
|
| 16 |
+
|
| 17 |
+
PAYMENT_ACTIONS = ("create_payment", "find_payment", "expect_payment", "void_payment")
|
| 18 |
+
NEW = ("AP-FUS-020", "AP-FUS-021", "AP-FUS-022", "AP-FUS-023", "AP-FUS-024", "AP-FUS-025", "AP-FUS-026")
|
| 19 |
+
METHOD_OF = {"AP-FUS-020": "Electronic", "AP-FUS-021": "Check", "AP-FUS-022": "Wire"}
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def profile(by_dim: dict[tuple[str, str], list[str]]) -> dict:
|
| 23 |
+
"""A Payables profile in which each (resource, dimension) holds these values (ten records each)."""
|
| 24 |
+
dims = []
|
| 25 |
+
for (resource, key), values in by_dim.items():
|
| 26 |
+
d = dimension_spec("AP", key, resource)
|
| 27 |
+
items = [{f: v for f in ([d["field"]] if isinstance(d["field"], str) else d["field"][:1])} for v in values for _ in range(10)]
|
| 28 |
+
dims.append(usage.count_dimension(d, items, resource))
|
| 29 |
+
return {"read_at": "2026-11-22T00:00:00Z", "days": 90, "since": "2026-08-24", "areas": [
|
| 30 |
+
{"code": "AP", "name": "Payables", "status": "read", "dimensions": dims,
|
| 31 |
+
"resources": [{"resource": r, "status": "read", "total": 100} for r in {r for r, _ in by_dim}]}]}
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def covered_by(cov: dict, dimension: str, value: str) -> tuple[str, set[str]]:
|
| 35 |
+
v = next(x for x in cov["variants"] if (x["dimension"], x["value"]) == (dimension, value))
|
| 36 |
+
return v["status"], {m["id"] for m in v["matches"]}
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
class TestScenarios(unittest.TestCase):
|
| 40 |
+
def test_each_loads_as_a_fusion_scenario_uses_allowed_actions_and_passes_the_step_checks(self):
|
| 41 |
+
lib, known = library(), runner_actions()
|
| 42 |
+
for cid in NEW:
|
| 43 |
+
self.assertEqual((lib[cid]["target"], lib[cid]["module"]), ("fusion", "AP"), cid)
|
| 44 |
+
d = yaml_draft(cid)
|
| 45 |
+
acts = {s["action"] for s in d["steps"]}
|
| 46 |
+
self.assertTrue(acts <= set(sw.ALLOWED_ACTIONS) and acts <= known, (cid, acts - set(sw.ALLOWED_ACTIONS)))
|
| 47 |
+
self.assertEqual(sw.check_steps(d, AP_INV), [], cid)
|
| 48 |
+
doc = yaml.safe_load((sw.CASES_DIR / f"{cid}.yaml").read_text(encoding="utf-8"))
|
| 49 |
+
self.assertEqual((doc["runner"], bool(doc.get("canary"))), ("steps", False), cid)
|
| 50 |
+
entry = (ROOT / "automation" / "tests" / "fusion" / "steps" / f"{cid}.spec.ts").read_text(encoding="utf-8")
|
| 51 |
+
self.assertIn(f"stepsTest('{cid}', ['@{cid}','@AP','@P2'])", entry)
|
| 52 |
+
|
| 53 |
+
def test_the_payment_actions_are_payables_scenario_only_actions_the_runner_has(self):
|
| 54 |
+
known = runner_actions()
|
| 55 |
+
for a in PAYMENT_ACTIONS:
|
| 56 |
+
self.assertIn(a, sw.SCENARIO_ONLY_ACTIONS)
|
| 57 |
+
self.assertIn(a, sw.BUSINESS_AREAS["AP"]["actions"])
|
| 58 |
+
self.assertIn("Payables business action", sw.ALLOWED_ACTIONS[a])
|
| 59 |
+
self.assertIn(a, known)
|
| 60 |
+
|
| 61 |
+
def test_payments_are_never_in_a_canary(self):
|
| 62 |
+
for f in (sw.CASES_DIR).glob("CANARY-*.yaml"):
|
| 63 |
+
acts = {s["action"] for s in yaml.safe_load(f.read_text(encoding="utf-8"))["steps"]}
|
| 64 |
+
self.assertFalse(acts & set(sw.SCENARIO_ONLY_ACTIONS), f.name)
|
| 65 |
+
self.assertFalse({a for a in PAYMENT_ACTIONS} & set(yaml_draft("CANARY-AP") and {s["action"] for s in yaml_draft("CANARY-AP")["steps"]}))
|
| 66 |
+
|
| 67 |
+
def test_every_payment_is_made_with_the_invoices_method_and_the_invoice_is_validated_first(self):
|
| 68 |
+
for cid, method in METHOD_OF.items():
|
| 69 |
+
steps = yaml_draft(cid)["steps"]
|
| 70 |
+
acts = [s["action"] for s in steps]
|
| 71 |
+
self.assertLess(acts.index("validate_invoice"), acts.index("create_payment"), cid)
|
| 72 |
+
by = {s["action"]: s for s in steps}
|
| 73 |
+
self.assertEqual((by["create_invoice"]["payment_method"], by["create_payment"]["payment_method"],
|
| 74 |
+
by["expect_payment"]["payment_method"]), (method,) * 3, cid)
|
| 75 |
+
self.assertEqual(by["expect_payment"]["payment_type"], "Quick")
|
| 76 |
+
self.assertEqual([s["action"] for s in yaml_draft("AP-FUS-023")["steps"]][-2:], ["void_payment", "expect_payment"])
|
| 77 |
+
self.assertEqual(yaml_draft("AP-FUS-023")["steps"][-1]["status"], "Voided")
|
| 78 |
+
|
| 79 |
+
def test_the_status_checks_assert_what_their_title_says(self):
|
| 80 |
+
assert_on = {"AP-FUS-024": ("approval_status", "Not required"), "AP-FUS-025": ("validation_status", "Not validated"),
|
| 81 |
+
"AP-FUS-026": ("validation_status", "Needs revalidation")}
|
| 82 |
+
for cid, (key, value) in assert_on.items():
|
| 83 |
+
self.assertIn(value, [s.get(key) for s in yaml_draft(cid)["steps"] if s["action"] == "expect_invoice"], cid)
|
| 84 |
+
# a validated invoice is only "Needs revalidation" after the change is saved
|
| 85 |
+
acts = [s["action"] for s in yaml_draft("AP-FUS-026")["steps"]]
|
| 86 |
+
self.assertEqual(acts[-3:], ["enter", "save", "expect_invoice"])
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
class TestStepChecks(unittest.TestCase):
|
| 90 |
+
def check(self, *steps, **over):
|
| 91 |
+
d = {"test_values": {"amount": "100"}, "expected_result": "Done.", "steps": [{"action": "sign_in"}, *steps]} | over
|
| 92 |
+
return sw.check_steps(d, AP_INV)
|
| 93 |
+
|
| 94 |
+
CREATE = {"action": "create_invoice", "value": "{{tv.amount}}", "payment_method": "Check"}
|
| 95 |
+
VALIDATE = {"action": "validate_invoice"}
|
| 96 |
+
PAY = {"action": "create_payment", "payment_method": "Check"}
|
| 97 |
+
|
| 98 |
+
def test_a_good_payment_flow_passes(self):
|
| 99 |
+
self.assertEqual(self.check(self.CREATE, self.VALIDATE, self.PAY, {"action": "find_payment"},
|
| 100 |
+
{"action": "expect_payment", "status": "Negotiable", "payment_method": "Check", "payment_type": "Quick"},
|
| 101 |
+
{"action": "void_payment"}, {"action": "expect_payment", "status": "Voided"}), [])
|
| 102 |
+
|
| 103 |
+
def test_a_payment_needs_a_validated_invoice_of_the_same_method(self):
|
| 104 |
+
self.assertTrue(any("validate_invoice" in p for p in self.check(self.CREATE, self.PAY, {"action": "expect_payment"})))
|
| 105 |
+
wrong = self.check(self.CREATE, self.VALIDATE, {**self.PAY, "payment_method": "Wire"}, {"action": "expect_payment"})
|
| 106 |
+
self.assertTrue(any("created with Check" in p for p in wrong), wrong)
|
| 107 |
+
self.assertTrue(any("no invoice is created" in p for p in self.check({"action": "create_payment"}, {"action": "expect_payment"})))
|
| 108 |
+
|
| 109 |
+
def test_only_a_quick_payment_is_made_and_a_paid_invoice_is_not_cancelled(self):
|
| 110 |
+
manual = self.check(self.CREATE, self.VALIDATE, {**self.PAY, "payment_type": "Manual"}, {"action": "expect_payment"})
|
| 111 |
+
self.assertTrue(any("only a Quick payment is created" in p for p in manual), manual)
|
| 112 |
+
paid = self.check(self.CREATE, self.VALIDATE, self.PAY, {"action": "cancel_invoice"})
|
| 113 |
+
self.assertTrue(any("void_payment" in p for p in paid), paid)
|
| 114 |
+
voided = self.check(self.CREATE, self.VALIDATE, self.PAY, {"action": "void_payment"}, {"action": "cancel_invoice"},
|
| 115 |
+
{"action": "expect_payment", "status": "Voided"})
|
| 116 |
+
self.assertEqual(voided, [])
|
| 117 |
+
|
| 118 |
+
def test_payment_and_invoice_status_words_are_checked(self):
|
| 119 |
+
self.assertTrue(self.check(self.CREATE, self.VALIDATE, self.PAY, {"action": "expect_payment", "status": "Maybe"}))
|
| 120 |
+
self.assertTrue(self.check(self.CREATE, {"action": "expect_payment", "status": "Voided"}, {"action": "find_invoice", "payment_method": "Check"}))
|
| 121 |
+
self.assertTrue(self.check(self.CREATE, {"action": "expect_invoice", "approval_status": "Whenever"}))
|
| 122 |
+
self.assertTrue(self.check(self.CREATE, {"action": "expect_invoice", "validation_status": "Sort of"}))
|
| 123 |
+
self.assertTrue(self.check(self.CREATE, {"action": "expect_invoice", "status": "Validated", "validation_status": "Not validated"}))
|
| 124 |
+
self.assertEqual(self.check(self.CREATE, {"action": "expect_invoice", "approval_status": "Not required", "validation_status": "Not validated"}), [])
|
| 125 |
+
self.assertTrue(self.check(self.CREATE, {"action": "expect_hold", "value": "x", "approval_status": "Required"})) # belongs to expect_invoice
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
class TestCoverage(unittest.TestCase):
|
| 129 |
+
def test_a_payment_method_is_covered_only_by_the_scenario_that_pays_with_it(self):
|
| 130 |
+
lib = library()
|
| 131 |
+
cov = usage.coverage(profile({("payablesPayments", "payment_method"): ["Electronic", "Check", "Wire"],
|
| 132 |
+
("payablesPayments", "payment_type"): ["Quick", "Manual"],
|
| 133 |
+
("payablesPayments", "status"): ["Voided", "Negotiable"]}), list(lib.values()))
|
| 134 |
+
for cid, method in METHOD_OF.items():
|
| 135 |
+
status, ids = covered_by(cov, "payment_method", method)
|
| 136 |
+
self.assertEqual(status, "covered")
|
| 137 |
+
self.assertIn(cid, ids) # (the bare word "wire" also matches AP-FUS-022, which does enter its invoice with Wire)
|
| 138 |
+
status, ids = covered_by(cov, "payment_type", "Quick")
|
| 139 |
+
self.assertEqual((status, ids), ("covered", {"AP-FUS-020", "AP-FUS-021", "AP-FUS-022", "AP-FUS-023"}))
|
| 140 |
+
self.assertEqual(covered_by(cov, "status", "Voided"), ("covered", {"AP-FUS-023"}))
|
| 141 |
+
# nothing makes a Manual payment: a title does not claim more than the steps do (Negotiable: tests/test_cov_final.py)
|
| 142 |
+
self.assertNotEqual(covered_by(cov, "payment_type", "Manual")[0], "covered")
|
| 143 |
+
|
| 144 |
+
def test_the_invoice_statuses_are_covered_by_the_scenarios_that_assert_them(self):
|
| 145 |
+
lib = library()
|
| 146 |
+
cov = usage.coverage(profile({("invoices", "approval_status"): ["Not required", "Required", "Initiated"],
|
| 147 |
+
("invoices", "validation_status"): ["Not validated", "Needs revalidation"],
|
| 148 |
+
("invoices", "payment_method"): ["Electronic", "Check", "Wire"]}), list(lib.values()))
|
| 149 |
+
self.assertEqual(covered_by(cov, "approval_status", "Not required"), ("covered", {"AP-FUS-024"}))
|
| 150 |
+
self.assertNotIn("AP-FUS-024", covered_by(cov, "approval_status", "Required")[1]) # "approval not required" is not "approval required"
|
| 151 |
+
self.assertNotIn("AP-FUS-024", covered_by(cov, "approval_status", "Initiated")[1])
|
| 152 |
+
self.assertIn("AP-FUS-025", covered_by(cov, "validation_status", "Not validated")[1])
|
| 153 |
+
self.assertEqual(covered_by(cov, "validation_status", "Needs revalidation"), ("covered", {"AP-FUS-026"}))
|
| 154 |
+
# an invoice's payment method is covered by the scenarios whose titles say they enter it (AP-FUS-017..019), not by a payment's title
|
| 155 |
+
for cid, method in {"AP-FUS-017": "Electronic", "AP-FUS-018": "Check", "AP-FUS-019": "Wire"}.items():
|
| 156 |
+
status, ids = covered_by(cov, "payment_method", method)
|
| 157 |
+
self.assertEqual(status, "covered")
|
| 158 |
+
self.assertIn(cid, ids) # (the bare word "wire" also matches AP-FUS-022, which does enter its invoice with Wire)
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
if __name__ == "__main__":
|
| 162 |
+
unittest.main()
|
coworker/tests/test_cov_ar.py
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Receivables scenarios written for the client's real usage (AR-FUS-001..006): transaction type (Invoice, Credit Memo, Debit
|
| 2 |
+
Memo), transaction source Manual, receipt state Applied and Unapplied. Each loads as a Fusion scenario, uses only business
|
| 3 |
+
actions the runner has, passes the step checks, has its spec, and makes the variants it really creates and checks covered
|
| 4 |
+
in the usage coverage. The source "Receivables Import" is an import, not something a screen does: it stays uncovered, and
|
| 5 |
+
create_transaction refuses to be asked for it."""
|
| 6 |
+
from __future__ import annotations
|
| 7 |
+
|
| 8 |
+
import copy
|
| 9 |
+
import re
|
| 10 |
+
import unittest
|
| 11 |
+
|
| 12 |
+
import yaml
|
| 13 |
+
|
| 14 |
+
from ..adapters import cases as cases_adapter
|
| 15 |
+
from ..config import ROOT
|
| 16 |
+
from ..platform import step_writer as sw
|
| 17 |
+
from ..platform import usage
|
| 18 |
+
from .test_ar_business_actions import AR_INV
|
| 19 |
+
from .test_business_actions import runner_actions, yaml_draft
|
| 20 |
+
|
| 21 |
+
NEW = ("AR-FUS-001", "AR-FUS-002", "AR-FUS-003", "AR-FUS-004", "AR-FUS-005", "AR-FUS-006")
|
| 22 |
+
T, R = "receivablesInvoices", "standardReceipts"
|
| 23 |
+
# the variants each scenario is about: (dimension key, resource, value as the pod stores it)
|
| 24 |
+
INTENDED = {
|
| 25 |
+
"AR-FUS-001": [("transaction_type", T, "Invoice"), ("transaction_source", T, "Manual")],
|
| 26 |
+
"AR-FUS-002": [("transaction_type", T, "Credit Memo"), ("transaction_source", T, "Manual")],
|
| 27 |
+
"AR-FUS-003": [("transaction_type", T, "Debit Memo"), ("transaction_source", T, "Manual")],
|
| 28 |
+
"AR-FUS-004": [("transaction_type", T, "Invoice"), ("state", R, "Applied")],
|
| 29 |
+
"AR-FUS-005": [("state", R, "Unapplied")],
|
| 30 |
+
"AR-FUS-006": [("transaction_type", T, "Invoice"), ("transaction_source", T, "Manual")],
|
| 31 |
+
}
|
| 32 |
+
# used variants no screen creates: the scenarios must not claim them (an import is a scheduled process; a chargeback and a
|
| 33 |
+
# reversal have no action; a type of the pod's own is only covered by a scenario that names it)
|
| 34 |
+
NOT_COVERABLE = [("transaction_source", T, "Receivables Import"), ("transaction_type", T, "PA Invoice"),
|
| 35 |
+
("transaction_type", T, "Chargeback"), ("state", R, "Reversed")]
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def library() -> dict[str, dict]:
|
| 39 |
+
return {c["id"]: c for c in cases_adapter.load_cases()}
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def sample_profile() -> dict:
|
| 43 |
+
"""A profile in which every variant above is used (counts are small samples of a client's records)."""
|
| 44 |
+
by_dim: dict[tuple[str, str], list[str]] = {}
|
| 45 |
+
for key, resource, value in [*(x for xs in INTENDED.values() for x in xs), *NOT_COVERABLE]:
|
| 46 |
+
values = by_dim.setdefault((resource, key), [])
|
| 47 |
+
if value not in values:
|
| 48 |
+
values.append(value)
|
| 49 |
+
dims = []
|
| 50 |
+
for (resource, key), values in by_dim.items():
|
| 51 |
+
spec = next(s for s in usage.USAGE["AR"] if s["resource"] == resource)
|
| 52 |
+
d = next(x for x in spec["dimensions"] if x["key"] == key)
|
| 53 |
+
field = d["field"] if isinstance(d["field"], str) else d["field"][0]
|
| 54 |
+
dims.append(usage.count_dimension(d, [{field: v} for v in values for _ in range(10)], resource))
|
| 55 |
+
return {"read_at": "2026-11-21T00:00:00Z", "days": 90, "since": "2026-08-23",
|
| 56 |
+
"areas": [{"code": "AR", "name": "Receivables", "status": "read", "dimensions": dims,
|
| 57 |
+
"resources": [{"resource": r, "status": "read", "total": 100} for r in (T, R)]}]}
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def steps_of(cid: str) -> list[dict]:
|
| 61 |
+
return yaml_draft(cid)["steps"]
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def first(cid: str, action: str) -> dict:
|
| 65 |
+
return next(s for s in steps_of(cid) if s["action"] == action)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
class TestCovAr(unittest.TestCase):
|
| 69 |
+
def test_each_loads_as_a_fusion_scenario_of_receivables(self):
|
| 70 |
+
lib = library()
|
| 71 |
+
for cid in NEW:
|
| 72 |
+
self.assertIn(cid, lib)
|
| 73 |
+
self.assertEqual((lib[cid]["target"], lib[cid]["module"]), ("fusion", "AR"), cid)
|
| 74 |
+
|
| 75 |
+
def test_each_uses_only_allowed_runner_actions_passes_the_step_checks_and_has_its_spec(self):
|
| 76 |
+
known = runner_actions()
|
| 77 |
+
for cid in NEW:
|
| 78 |
+
d = yaml_draft(cid)
|
| 79 |
+
acts = {s["action"] for s in d["steps"]}
|
| 80 |
+
self.assertTrue(acts <= set(sw.ALLOWED_ACTIONS) and acts <= known, (cid, acts - set(sw.ALLOWED_ACTIONS)))
|
| 81 |
+
self.assertEqual(sw.check_steps(d, AR_INV), [], cid)
|
| 82 |
+
doc = yaml.safe_load((sw.CASES_DIR / f"{cid}.yaml").read_text(encoding="utf-8"))
|
| 83 |
+
self.assertEqual(doc["runner"], "steps")
|
| 84 |
+
self.assertFalse(doc.get("canary"))
|
| 85 |
+
entry = (ROOT / "automation" / "tests" / "fusion" / "steps" / f"{cid}.spec.ts").read_text(encoding="utf-8")
|
| 86 |
+
self.assertIn(f"stepsTest('{cid}', ['@{cid}','@AR'", entry)
|
| 87 |
+
|
| 88 |
+
def test_the_scenarios_do_what_their_titles_say(self):
|
| 89 |
+
for cid, kind in (("AR-FUS-001", "Invoice"), ("AR-FUS-002", "Credit Memo"), ("AR-FUS-003", "Debit Memo"),
|
| 90 |
+
("AR-FUS-004", "Invoice"), ("AR-FUS-006", "Invoice")):
|
| 91 |
+
made = first(cid, "create_transaction")
|
| 92 |
+
self.assertEqual((made["transaction_type"], made["transaction_source"]), (kind, "Manual"), cid)
|
| 93 |
+
self.assertTrue(float(yaml_draft("AR-FUS-002")["test_values"]["amount"]) < 0) # a credit memo is entered negative
|
| 94 |
+
self.assertTrue(float(yaml_draft("AR-FUS-003")["test_values"]["amount"]) > 0)
|
| 95 |
+
for cid in ("AR-FUS-001", "AR-FUS-002", "AR-FUS-003", "AR-FUS-006"): # what each checks afterwards is what it created
|
| 96 |
+
made, expect = first(cid, "create_transaction"), first(cid, "expect_transaction")
|
| 97 |
+
self.assertEqual((expect["transaction_type"], expect["transaction_source"]),
|
| 98 |
+
(made["transaction_type"], made["transaction_source"]), cid)
|
| 99 |
+
self.assertEqual([s["action"] for s in steps_of("AR-FUS-001")][1:], ["create_transaction", "complete_transaction", "expect_transaction"])
|
| 100 |
+
self.assertEqual([s["action"] for s in steps_of("AR-FUS-004")][1:],
|
| 101 |
+
["create_transaction", "complete_transaction", "create_receipt", "find_receipt", "expect_receipt"])
|
| 102 |
+
self.assertEqual(first("AR-FUS-004", "create_receipt")["applies_to"], "transaction_number")
|
| 103 |
+
self.assertEqual(first("AR-FUS-004", "expect_receipt")["status"], "Applied")
|
| 104 |
+
# the unapplied receipt: no transaction at all, so nothing is applied to it
|
| 105 |
+
self.assertEqual([s["action"] for s in steps_of("AR-FUS-005")][1:], ["create_receipt", "find_receipt", "expect_receipt"])
|
| 106 |
+
self.assertNotIn("applies_to", first("AR-FUS-005", "create_receipt"))
|
| 107 |
+
self.assertEqual(first("AR-FUS-005", "expect_receipt")["status"], "Unapplied")
|
| 108 |
+
self.assertEqual([s["action"] for s in steps_of("AR-FUS-006")][1:], ["create_transaction", "find_transaction", "expect_transaction"])
|
| 109 |
+
self.assertEqual(first("AR-FUS-006", "expect_transaction")["status"], "Incomplete")
|
| 110 |
+
|
| 111 |
+
def test_a_document_a_person_must_undo_is_said_in_the_scenario_and_none_is_in_the_canary(self):
|
| 112 |
+
left = {"AR-FUS-001", "AR-FUS-004", "AR-FUS-005"} # a completed invoice, an applied or an unapplied receipt
|
| 113 |
+
for cid in NEW:
|
| 114 |
+
acts = {s["action"] for s in steps_of(cid)}
|
| 115 |
+
text = " ".join((sw.CASES_DIR / f"{cid}.yaml").read_text(encoding="utf-8").split("\nid:")[0].split())
|
| 116 |
+
self.assertEqual(bool(acts & {"complete_transaction", "create_receipt"}), cid in left, cid)
|
| 117 |
+
self.assertEqual("run's test data" in text, cid in left, cid)
|
| 118 |
+
self.assertEqual("deletes it while it is Incomplete" in text, cid not in left, cid)
|
| 119 |
+
canary = yaml.safe_load((sw.CASES_DIR / "CANARY-AR.yaml").read_text(encoding="utf-8"))
|
| 120 |
+
self.assertEqual({s["action"] for s in canary["steps"]} & {"complete_transaction", "create_receipt"}, set())
|
| 121 |
+
self.assertFalse({"transaction_type", "transaction_source"} & {k for s in canary["steps"] for k in s}) # canary unchanged
|
| 122 |
+
|
| 123 |
+
def test_the_intended_variants_are_covered_by_these_scenarios_and_the_rest_are_not(self):
|
| 124 |
+
lib = library()
|
| 125 |
+
cov = usage.coverage(sample_profile(), list(lib.values()))
|
| 126 |
+
by_value = {(v["dimension"], v["value"]): v for v in cov["variants"]}
|
| 127 |
+
for cid, variants in INTENDED.items():
|
| 128 |
+
text = usage._scenario_text(lib[cid])
|
| 129 |
+
for key, _resource, value in variants:
|
| 130 |
+
v = by_value[(key, value)]
|
| 131 |
+
self.assertEqual(v["status"], "covered", (cid, key, value))
|
| 132 |
+
self.assertIsNotNone(usage._match(v["phrases"], text), (cid, key, value, v["phrases"]))
|
| 133 |
+
for key, _resource, value in NOT_COVERABLE:
|
| 134 |
+
v = by_value[(key, value)]
|
| 135 |
+
self.assertNotEqual(v["status"], "covered", (key, value))
|
| 136 |
+
self.assertFalse({m["id"] for m in v["matches"]} & set(NEW), (key, value))
|
| 137 |
+
|
| 138 |
+
def test_no_scenario_claims_a_variant_it_does_not_create(self):
|
| 139 |
+
"""Each variant is matched by exactly the scenarios that create it: a credit memo is not an invoice, an unapplied
|
| 140 |
+
receipt is not an applied one."""
|
| 141 |
+
lib = library()
|
| 142 |
+
by_value = {(v["dimension"], v["value"]): v for v in usage.coverage(sample_profile(), list(lib.values()))["variants"]}
|
| 143 |
+
for variant, mine in ((("transaction_type", "Invoice"), {"AR-FUS-001", "AR-FUS-004", "AR-FUS-006"}),
|
| 144 |
+
(("transaction_type", "Credit Memo"), {"AR-FUS-002"}), (("transaction_type", "Debit Memo"), {"AR-FUS-003"}),
|
| 145 |
+
(("state", "Applied"), {"AR-FUS-004"}), (("state", "Unapplied"), {"AR-FUS-005"})):
|
| 146 |
+
matched = {m["id"] for m in by_value[variant]["matches"]} & set(NEW)
|
| 147 |
+
self.assertEqual(matched, mine, variant)
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
class TestTransactionFields(unittest.TestCase):
|
| 151 |
+
@staticmethod
|
| 152 |
+
def check(steps: list[dict], **over) -> str:
|
| 153 |
+
d = {"test_values": {"amount": "100"}, "expected_result": "Handled.", "steps": [{"action": "sign_in"}, *steps, {"action": "find_transaction"}], **over}
|
| 154 |
+
return "\n".join(sw.check_steps(d, AR_INV))
|
| 155 |
+
|
| 156 |
+
def test_the_fields_belong_to_create_and_expect_transaction_only(self):
|
| 157 |
+
self.assertIn("transaction_type belongs to create_transaction or expect_transaction, not complete_transaction",
|
| 158 |
+
self.check([{"action": "create_transaction"}, {"action": "complete_transaction", "transaction_type": "Invoice"}]))
|
| 159 |
+
self.assertIn("transaction_source belongs to", self.check([{"action": "create_transaction"},
|
| 160 |
+
{"action": "find_transaction", "transaction_source": "Manual"}]))
|
| 161 |
+
|
| 162 |
+
def test_the_sign_follows_the_type_as_fusion_enforces_it(self):
|
| 163 |
+
self.assertEqual(self.check([{"action": "create_transaction", "transaction_type": "Credit Memo", "value": "-5"}]), "")
|
| 164 |
+
self.assertIn("a credit memo is entered with a negative amount",
|
| 165 |
+
self.check([{"action": "create_transaction", "transaction_type": "Credit Memo", "value": "5"}]))
|
| 166 |
+
self.assertIn("a credit memo is entered with a negative amount",
|
| 167 |
+
self.check([{"action": "create_transaction", "transaction_type": "credit memo"}])) # the test value is positive
|
| 168 |
+
self.assertIn("has a positive amount", self.check([{"action": "create_transaction", "value": "-5"}]))
|
| 169 |
+
self.assertIn("has a positive amount", self.check([{"action": "create_transaction", "transaction_type": "Debit Memo", "value": "-5"}]))
|
| 170 |
+
self.assertEqual(self.check([{"action": "create_transaction", "transaction_type": "PA Invoice", "value": "5"}]), "") # the pod's own type
|
| 171 |
+
self.assertEqual(self.check([{"action": "create_transaction", "transaction_type": "{{tv.t}}"}], test_values={"amount": "1", "t": "X"}), "")
|
| 172 |
+
|
| 173 |
+
def test_an_import_is_refused_and_a_name_must_be_a_name(self):
|
| 174 |
+
for source in ("Receivables Import", "AutoInvoice", "Imported"):
|
| 175 |
+
self.assertIn("an import is a scheduled process", self.check([{"action": "create_transaction", "transaction_source": source}]), source)
|
| 176 |
+
self.assertEqual(self.check([{"action": "create_transaction", "transaction_source": "Manual"}]), "")
|
| 177 |
+
self.assertIn("transaction_type must be a name", self.check([{"action": "create_transaction", "transaction_type": "5; drop"}]))
|
| 178 |
+
|
| 179 |
+
def test_expect_transaction_cannot_ask_for_what_it_was_not_created_as(self):
|
| 180 |
+
made = {"action": "create_transaction", "transaction_type": "Credit Memo", "transaction_source": "Manual", "value": "-5"}
|
| 181 |
+
self.assertEqual(self.check([made, {"action": "expect_transaction", "transaction_type": "credit memo", "transaction_source": "manual"}]), "")
|
| 182 |
+
self.assertIn("was created as credit memo", self.check([made, {"action": "expect_transaction", "transaction_type": "Invoice"}]))
|
| 183 |
+
self.assertIn("was created as invoice", self.check([{"action": "create_transaction"}, {"action": "expect_transaction", "transaction_type": "Debit Memo"}]))
|
| 184 |
+
self.assertIn("was created from manual", self.check([made, {"action": "expect_transaction", "transaction_source": "Other"}]))
|
| 185 |
+
|
| 186 |
+
def test_the_fields_are_kept_in_drafts_and_placeholders_checked(self):
|
| 187 |
+
d = {"test_values": {"amount": "100"}, "expected_result": "Handled.", "steps": [
|
| 188 |
+
{"action": "sign_in"}, {"action": "create_transaction", "transaction_type": "Debit Memo", "transaction_source": "Manual"},
|
| 189 |
+
{"action": "expect_transaction", "transaction_type": "Debit Memo"}]}
|
| 190 |
+
steps = yaml.safe_load(sw.to_case_yaml({"title": "t", "type": "happy", "task": AR_INV["task"]}, copy.deepcopy(d), "AR-AI-001"))["steps"]
|
| 191 |
+
self.assertEqual((steps[1]["transaction_type"], steps[1]["transaction_source"], steps[2]["transaction_type"]),
|
| 192 |
+
("Debit Memo", "Manual", "Debit Memo"))
|
| 193 |
+
self.assertNotIn("transaction_source", steps[2])
|
| 194 |
+
self.assertIn("unknown placeholder", self.check([{"action": "create_transaction", "transaction_type": "{{nope}}"}]))
|
| 195 |
+
|
| 196 |
+
def test_the_action_descriptions_name_the_fields_and_hold_no_figure(self):
|
| 197 |
+
for a in ("create_transaction", "expect_transaction"):
|
| 198 |
+
self.assertIn("transaction_type", sw.ALLOWED_ACTIONS[a])
|
| 199 |
+
self.assertIn("transaction_source", sw.ALLOWED_ACTIONS[a])
|
| 200 |
+
self.assertFalse(re.search(r"\d", sw.ALLOWED_ACTIONS[a]), a)
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
if __name__ == "__main__":
|
| 204 |
+
unittest.main()
|
coworker/tests/test_cov_final.py
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""The last screen-testable gaps of the client's Fusion usage: payment status Negotiable, the hold "Distribution variance" as the
|
| 2 |
+
pod writes it, invoice approval Required/Initiated (initiate_approval) and the client's own organisation (procurement BU)."""
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import json
|
| 6 |
+
import unittest
|
| 7 |
+
from types import SimpleNamespace
|
| 8 |
+
|
| 9 |
+
import yaml
|
| 10 |
+
|
| 11 |
+
from ..config import ROOT
|
| 12 |
+
from ..platform import cleanup, left_on_pod
|
| 13 |
+
from ..platform import step_writer as sw
|
| 14 |
+
from ..platform import usage
|
| 15 |
+
from .test_business_actions import runner_actions, yaml_draft
|
| 16 |
+
from .test_cov_ap_pay import covered_by, profile
|
| 17 |
+
from .test_gap_scenarios import dimension_spec, library
|
| 18 |
+
from .test_po_gl_business_actions import AP_INV
|
| 19 |
+
|
| 20 |
+
PAID = ("AP-FUS-020", "AP-FUS-021", "AP-FUS-022")
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class TestNegotiable(unittest.TestCase):
|
| 24 |
+
def test_the_quick_payments_check_status_negotiable_before_any_void_and_say_so(self):
|
| 25 |
+
from .test_business_actions import yaml_draft
|
| 26 |
+
for cid in PAID:
|
| 27 |
+
d = yaml_draft(cid)
|
| 28 |
+
acts = [s["action"] for s in d["steps"]]
|
| 29 |
+
self.assertNotIn("void_payment", acts, cid)
|
| 30 |
+
checks = [s for s in d["steps"] if s["action"] == "expect_payment"]
|
| 31 |
+
self.assertEqual([s.get("status") for s in checks], ["Negotiable"], cid)
|
| 32 |
+
self.assertGreater(acts.index("expect_payment"), acts.index("create_payment"), cid)
|
| 33 |
+
doc = yaml.safe_load((sw.CASES_DIR / f"{cid}.yaml").read_text(encoding="utf-8"))
|
| 34 |
+
self.assertIn("Negotiable", doc["title"])
|
| 35 |
+
self.assertIn("negotiable", doc["tags"])
|
| 36 |
+
|
| 37 |
+
def test_negotiable_is_covered_by_them_and_a_voided_payment_does_not_claim_it(self):
|
| 38 |
+
lib = library()
|
| 39 |
+
cov = usage.coverage(profile({("payablesPayments", "status"): ["Negotiable", "Voided", "Cleared"]}), list(lib.values()))
|
| 40 |
+
status, ids = covered_by(cov, "status", "Negotiable")
|
| 41 |
+
self.assertEqual((status, ids), ("covered", set(PAID)))
|
| 42 |
+
self.assertEqual(covered_by(cov, "status", "Voided")[1], {"AP-FUS-023"})
|
| 43 |
+
self.assertNotEqual(covered_by(cov, "status", "Cleared")[0], "covered")
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
class TestDistributionVariance(unittest.TestCase):
|
| 47 |
+
def test_the_hold_is_matched_under_the_name_the_pod_writes_and_the_old_key_stays(self):
|
| 48 |
+
d = next(x for s in usage.USAGE["AP"] if s["resource"] == "invoiceHolds" for x in s["dimensions"] if x["key"] == "hold_name")
|
| 49 |
+
self.assertEqual(d["words"]["distribution variance"], ["distribution variance"])
|
| 50 |
+
self.assertEqual(d["words"]["dist variance"], ["distribution variance"])
|
| 51 |
+
self.assertIn("distribution variance", {usage.norm(s) for s in d["standard"]}) # an Oracle hold, not the client's own value
|
| 52 |
+
scenario = {"id": "X-1", "title": "Invoice whose distributions differ from its line is put on a distribution variance hold",
|
| 53 |
+
"target": "fusion", "module": "AP", "tags": []}
|
| 54 |
+
prof = profile({("invoiceHolds", "hold_name"): ["Distribution variance", "Line Variance"]})
|
| 55 |
+
cov = usage.coverage(prof, [scenario])
|
| 56 |
+
self.assertEqual(covered_by(cov, "hold_name", "Distribution variance"), ("covered", {"X-1"}))
|
| 57 |
+
self.assertEqual(next(v for v in cov["variants"] if v["value"] == "Distribution variance")["standard"], True)
|
| 58 |
+
|
| 59 |
+
def test_no_scenario_claims_it_yet_because_no_action_enters_a_distribution(self):
|
| 60 |
+
# create_invoice enters lines; their distributions are made by Fusion from the line, equal to it, so a distribution variance
|
| 61 |
+
# needs an action that changes a line's distribution amount (see the report of this change)
|
| 62 |
+
lib = library()
|
| 63 |
+
cov = usage.coverage(profile({("invoiceHolds", "hold_name"): ["Distribution variance"]}), list(lib.values()))
|
| 64 |
+
self.assertNotEqual(covered_by(cov, "hold_name", "Distribution variance")[0], "covered")
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
class TestInitiateApproval(unittest.TestCase):
|
| 68 |
+
def test_the_scenario_loads_uses_allowed_actions_passes_the_checks_and_stays_out_of_the_canary(self):
|
| 69 |
+
lib, d = library(), yaml_draft("AP-FUS-027")
|
| 70 |
+
self.assertEqual((lib["AP-FUS-027"]["target"], lib["AP-FUS-027"]["module"]), ("fusion", "AP"))
|
| 71 |
+
acts = [s["action"] for s in d["steps"]]
|
| 72 |
+
self.assertTrue(set(acts) <= set(sw.ALLOWED_ACTIONS) and set(acts) <= runner_actions())
|
| 73 |
+
self.assertEqual(sw.check_steps(d, AP_INV), [])
|
| 74 |
+
self.assertEqual(acts[-4:], ["validate_invoice", "expect_invoice", "initiate_approval", "expect_invoice"])
|
| 75 |
+
self.assertEqual([s.get("approval_status") for s in d["steps"] if s["action"] == "expect_invoice"], ["Required", "Initiated"])
|
| 76 |
+
doc = yaml.safe_load((sw.CASES_DIR / "AP-FUS-027.yaml").read_text(encoding="utf-8"))
|
| 77 |
+
self.assertEqual((doc["runner"], bool(doc.get("canary"))), ("steps", False))
|
| 78 |
+
self.assertIn("sent for approval shows approval Initiated (approval required)", doc["title"])
|
| 79 |
+
entry = (ROOT / "automation" / "tests" / "fusion" / "steps" / "AP-FUS-027.spec.ts").read_text(encoding="utf-8")
|
| 80 |
+
self.assertIn("stepsTest('AP-FUS-027', ['@AP-FUS-027','@AP','@P2'])", entry)
|
| 81 |
+
for f in sw.CASES_DIR.glob("CANARY-*.yaml"):
|
| 82 |
+
self.assertNotIn("initiate_approval", f.read_text(encoding="utf-8"), f.name)
|
| 83 |
+
|
| 84 |
+
def test_the_action_is_a_payables_scenario_only_invoice_action(self):
|
| 85 |
+
self.assertIn("initiate_approval", sw.SCENARIO_ONLY_ACTIONS)
|
| 86 |
+
self.assertIn("initiate_approval", sw.BUSINESS_AREAS["AP"]["actions"])
|
| 87 |
+
self.assertIn("Payables business action", sw.ALLOWED_ACTIONS["initiate_approval"])
|
| 88 |
+
self.assertIn("initiate_approval", sw.INVOICE_ACTIONS)
|
| 89 |
+
|
| 90 |
+
def check(self, *steps):
|
| 91 |
+
d = {"test_values": {"amount": "100"}, "expected_result": "Done.", "steps": [{"action": "sign_in"}, *steps]}
|
| 92 |
+
return sw.check_steps(d, AP_INV)
|
| 93 |
+
|
| 94 |
+
CREATE = {"action": "create_invoice", "value": "{{tv.amount}}"}
|
| 95 |
+
VALIDATE = {"action": "validate_invoice"}
|
| 96 |
+
|
| 97 |
+
def test_step_checks(self):
|
| 98 |
+
self.assertEqual(self.check(self.CREATE, self.VALIDATE, {"action": "initiate_approval"},
|
| 99 |
+
{"action": "expect_invoice", "approval_status": "Initiated"}), [])
|
| 100 |
+
self.assertTrue(any("validate_invoice" in p for p in self.check(self.CREATE, {"action": "initiate_approval"})))
|
| 101 |
+
self.assertTrue(any("needs an invoice" in p for p in self.check({"action": "initiate_approval"})))
|
| 102 |
+
self.assertTrue(any("standard invoice" in p for p in self.check(
|
| 103 |
+
{**self.CREATE, "invoice_type": "Prepayment"}, self.VALIDATE, {"action": "initiate_approval"})))
|
| 104 |
+
late = self.check(self.CREATE, self.VALIDATE, {"action": "initiate_approval"}, {"action": "cancel_invoice"})
|
| 105 |
+
self.assertTrue(any("approval is under way" in p for p in late), late)
|
| 106 |
+
|
| 107 |
+
def test_required_and_initiated_are_covered_by_it_and_not_by_approval_not_required(self):
|
| 108 |
+
cov = usage.coverage(profile({("invoices", "approval_status"): ["Required", "Initiated", "Not required"]}), list(library().values()))
|
| 109 |
+
self.assertEqual(covered_by(cov, "approval_status", "Required")[1], {"AP-FUS-027"})
|
| 110 |
+
self.assertIn("AP-FUS-027", covered_by(cov, "approval_status", "Initiated")[1])
|
| 111 |
+
self.assertNotIn("AP-FUS-024", covered_by(cov, "approval_status", "Required")[1])
|
| 112 |
+
self.assertEqual(covered_by(cov, "approval_status", "Required")[0], "covered")
|
| 113 |
+
|
| 114 |
+
def test_a_test_invoice_in_approval_is_listed_for_a_person_not_cancelled(self):
|
| 115 |
+
def svc(invoice):
|
| 116 |
+
fake = SimpleNamespace(status_code=200, json=lambda: {"items": [invoice] if invoice else []})
|
| 117 |
+
return SimpleNamespace(egress=SimpleNamespace(fusion_request=lambda *a, **k: fake))
|
| 118 |
+
run = lambda inv, fn=cleanup._clean_approval: fn(svc(inv), "https://x", ("u", "p"), {"number": "FPT-1-APR"}, "r1") # noqa: E731
|
| 119 |
+
self.assertEqual(cleanup._in_approval({"ApprovalStatus": "INITIATED"}), "initiated")
|
| 120 |
+
self.assertEqual(cleanup._in_approval({"ApprovalStatus": "Not required"}), "")
|
| 121 |
+
with self.assertRaises(RuntimeError) as why:
|
| 122 |
+
run({"InvoiceNumber": "FPT-1", "ApprovalStatus": "Initiated"})
|
| 123 |
+
self.assertIn("Approval > Withdraw", str(why.exception))
|
| 124 |
+
self.assertIn("nothing to withdraw", run({"InvoiceNumber": "FPT-1", "ApprovalStatus": "Withdrawn"}))
|
| 125 |
+
self.assertIn("no approval to withdraw", run(None))
|
| 126 |
+
# the invoice itself is not cancelled while its approval is under way: the sweep lists it for a person too
|
| 127 |
+
with self.assertRaises(RuntimeError) as why:
|
| 128 |
+
cleanup._cancel_one(svc({"InvoiceNumber": "FPT-1", "ApprovalStatus": "Initiated"}), "https://x", ("u", "p"), {"number": "FPT-1"}, "r1")
|
| 129 |
+
self.assertIn("in approval", str(why.exception))
|
| 130 |
+
self.assertIn("ap_approval", cleanup.CLEANERS)
|
| 131 |
+
self.assertIn("ap_approval", left_on_pod.KINDS)
|
| 132 |
+
self.assertIn("Approval > Withdraw", left_on_pod.TODO["ap_approval"])
|
| 133 |
+
|
| 134 |
+
def test_the_fixture_withdraws_before_it_cancels_and_leaves_what_it_cannot_withdraw_to_a_person(self):
|
| 135 |
+
fx = (ROOT / "automation" / "src" / "fusion" / "fixtures.ts").read_text(encoding="utf-8")
|
| 136 |
+
rest = (ROOT / "automation" / "src" / "fusion" / "rest.ts").read_text(encoding="utf-8")
|
| 137 |
+
self.assertIn("ui.withdrawApproval(invoice)", fx)
|
| 138 |
+
self.assertIn("throw new LeftForPerson", fx.split("async function cleanApproval")[1].split("async function cleanDoc")[0])
|
| 139 |
+
self.assertIn("invoiceInApproval(inv)", rest.split("async cancelIfPresent")[1].split("async cleanApproval")[0])
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
BU = "Acme US Procurement" # a client's own business unit: it must never be in a result's wording or reach a model
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def po_profile(*values: str) -> dict:
|
| 146 |
+
d = dimension_spec("PO", "procurement_bu", "purchaseOrders")
|
| 147 |
+
items = [{"ProcurementBU": v} for v in values for _ in range(10)]
|
| 148 |
+
dim = usage.count_dimension(d, items, "purchaseOrders")
|
| 149 |
+
return {"read_at": "2026-11-22T00:00:00Z", "days": 90, "since": "2026-08-24", "areas": [
|
| 150 |
+
{"code": "PO", "name": "Purchasing", "status": "read", "dimensions": [dim],
|
| 151 |
+
"resources": [{"resource": "purchaseOrders", "status": "read", "total": 100}]}]}
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
class TestOrganisation(unittest.TestCase):
|
| 155 |
+
"""A dimension that says where the client works (its procurement BU) is covered by the area's Fusion scenarios when the pod's own
|
| 156 |
+
test data for that organisation key is that value; the value is compared on the pod and never sent anywhere."""
|
| 157 |
+
|
| 158 |
+
def setUp(self):
|
| 159 |
+
self.lib = list(library().values())
|
| 160 |
+
self.po_fusion = sorted(c["id"] for c in self.lib if c["module"] == "PO" and c["target"] == "fusion")
|
| 161 |
+
|
| 162 |
+
def cov(self, test_data=None, scenarios=None, *values):
|
| 163 |
+
return usage.coverage(po_profile(*(values or (BU,))), self.lib if scenarios is None else scenarios, test_data=test_data)
|
| 164 |
+
|
| 165 |
+
def test_the_value_is_covered_by_the_fusion_scenarios_of_the_area_when_the_pods_test_data_is_it(self):
|
| 166 |
+
self.assertTrue(self.po_fusion)
|
| 167 |
+
status, ids = covered_by(self.cov({"PO": {"business_unit": BU}}), "procurement_bu", BU)
|
| 168 |
+
self.assertEqual(status, "covered")
|
| 169 |
+
self.assertTrue(ids and ids <= set(self.po_fusion))
|
| 170 |
+
# the spelling of case and spaces does not matter, and a list of candidates counts by its first (the one a run tries first)
|
| 171 |
+
for td in ({"PO": {"business_unit": BU.upper()}}, {"PO": {"business_unit": [f" {BU} ", "Other"]}}):
|
| 172 |
+
self.assertEqual(covered_by(self.cov(td), "procurement_bu", BU)[0], "covered", td)
|
| 173 |
+
|
| 174 |
+
def test_another_value_other_key_other_area_or_no_test_data_stays_not_covered(self):
|
| 175 |
+
for td in (None, {}, {"PO": {"business_unit": "Some Other BU"}}, {"PO": {"supplier": BU}}, {"AP": {"business_unit": BU}},
|
| 176 |
+
{"PO": {"business_unit": [("Other"), BU]}}):
|
| 177 |
+
self.assertNotEqual(covered_by(self.cov(td), "procurement_bu", BU)[0], "covered", td)
|
| 178 |
+
# one used value among several: only the one that is the pod's own
|
| 179 |
+
cov = self.cov({"PO": {"business_unit": BU}}, None, BU, "Second BU")
|
| 180 |
+
self.assertEqual(covered_by(cov, "procurement_bu", BU)[0], "covered")
|
| 181 |
+
self.assertNotEqual(covered_by(cov, "procurement_bu", "Second BU")[0], "covered")
|
| 182 |
+
|
| 183 |
+
def test_only_a_fusion_scenario_of_the_area_counts(self):
|
| 184 |
+
td = {"PO": {"business_unit": BU}}
|
| 185 |
+
mixed = [{"id": "PRAC-1", "title": "Order entry", "target": "practice", "module": "PO", "tags": []},
|
| 186 |
+
{"id": "AP-1", "title": "Invoice entry", "target": "fusion", "module": "AP", "tags": []}]
|
| 187 |
+
self.assertEqual(covered_by(self.cov(td, mixed), "procurement_bu", BU)[0], "not_covered")
|
| 188 |
+
mixed.append({"id": "PO-1", "title": "Order entry", "target": "fusion", "module": "PO", "tags": []})
|
| 189 |
+
self.assertEqual(covered_by(self.cov(td, mixed), "procurement_bu", BU), ("covered", {"PO-1"}))
|
| 190 |
+
|
| 191 |
+
def test_the_value_never_appears_in_a_matchs_words_and_never_reaches_a_model(self):
|
| 192 |
+
cov = self.cov({"PO": {"business_unit": BU.upper() + " (test data)"}}, None) # not equal: nothing of the test data is in the result
|
| 193 |
+
self.assertNotIn("(test data)", json.dumps(cov))
|
| 194 |
+
cov = self.cov({"PO": {"business_unit": BU.upper()}})
|
| 195 |
+
for m in next(v for v in cov["variants"] if v["value"] == BU)["matches"]:
|
| 196 |
+
self.assertNotIn(BU.lower(), m["why"].lower())
|
| 197 |
+
self.assertIn("business_unit", m["why"])
|
| 198 |
+
self.assertNotIn("(test data)", json.dumps(cov))
|
| 199 |
+
# a dimension with no standard values is the client's own: never in a prompt view, covered or not
|
| 200 |
+
self.assertNotIn(BU, json.dumps(usage.prompt_view(cov, "PO", "Purchasing") or {}))
|
| 201 |
+
self.assertFalse(next(v for v in cov["variants"] if v["value"] == BU)["standard"])
|
| 202 |
+
|
| 203 |
+
def test_only_the_organisation_dimensions_are_marked(self):
|
| 204 |
+
marked = {(a, s["resource"], d["key"]): d["org_key"] for a, specs in usage.USAGE.items() for s in specs
|
| 205 |
+
for d in s.get("dimensions") or [] if d.get("org_key")}
|
| 206 |
+
self.assertEqual(marked, {("PO", "purchaseOrders", "procurement_bu"): "business_unit"})
|
| 207 |
+
# (the AR receipt method has no standard values either, but it says how the client is paid, not where it works)
|
| 208 |
+
|
| 209 |
+
def test_the_pods_coverage_route_passes_the_pods_test_data_in(self):
|
| 210 |
+
import coworker.tests.fakes as F
|
| 211 |
+
app, c, svc, _fake = F.make_app()
|
| 212 |
+
h = {r: F.bearer(c, r) for r in ("viewer", "admin")}
|
| 213 |
+
pod = c.post("/api/pods", json={"name": "Client test pod", "kind": "fusion", "base_url": "https://acme-test.fa.ocs.oraclecloud.com",
|
| 214 |
+
"environment": "test"}, headers=h["admin"]).json()
|
| 215 |
+
url = f"/api/pods/{pod['id']}"
|
| 216 |
+
svc.db.update("pods", "id", pod["id"], usage=json.dumps(po_profile(BU)))
|
| 217 |
+
|
| 218 |
+
def status():
|
| 219 |
+
cov = c.get(f"{url}/coverage", headers=h["viewer"]).json()
|
| 220 |
+
return next(v for v in cov["variants"] if v["value"] == BU)["status"]
|
| 221 |
+
self.assertNotEqual(status(), "covered") # no test data of the pod says it yet
|
| 222 |
+
self.assertEqual(c.put(f"{url}/test-data", json={"overrides": {"PO": {"business_unit": BU}}}, headers=h["admin"]).status_code, 200)
|
| 223 |
+
self.assertEqual(status(), "covered")
|
| 224 |
+
c.put(f"{url}/test-data", json={"overrides": {"PO": {"business_unit": "Elsewhere BU"}}}, headers=h["admin"])
|
| 225 |
+
self.assertNotEqual(status(), "covered")
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
if __name__ == "__main__":
|
| 229 |
+
unittest.main()
|
coworker/tests/test_cov_gl.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""General Ledger scenarios written for the client's real journal usage (GL-FUS-002..005): a manual adjustment journal posted,
|
| 2 |
+
a manual accrual journal posted then reversed, a journal left unposted, a journal in the Allocation category. Each loads as a
|
| 3 |
+
Fusion scenario, uses only allowed runner actions, passes the step checks, has its spec, leaves nothing a person must undo, and
|
| 4 |
+
makes the intended journal variants covered. The subledger sources (Payables, Receivables, Projects, Payroll, Cash Management)
|
| 5 |
+
come from Create Accounting and transfers, which post real client journals: they stay NOT covered, and so does AutoCopy (the
|
| 6 |
+
Auto Copy process; no screen action of the runner makes it). No browser, no pod."""
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import unittest
|
| 10 |
+
|
| 11 |
+
import yaml
|
| 12 |
+
|
| 13 |
+
from ..adapters import cases as cases_adapter
|
| 14 |
+
from ..config import ROOT
|
| 15 |
+
from ..platform import step_writer as sw
|
| 16 |
+
from ..platform import usage
|
| 17 |
+
from .test_business_actions import runner_actions, yaml_draft
|
| 18 |
+
from .test_po_gl_business_actions import GL_INV
|
| 19 |
+
|
| 20 |
+
NEW = ("GL-FUS-002", "GL-FUS-003", "GL-FUS-004", "GL-FUS-005")
|
| 21 |
+
BATCHES, HEADERS = "journalBatches", "journalBatches/{key}/child/journalHeaders"
|
| 22 |
+
INTENDED = {
|
| 23 |
+
"GL-FUS-002": [("source", "Manual", BATCHES), ("status", "Posted", BATCHES), ("category", "Adjustment", HEADERS)],
|
| 24 |
+
"GL-FUS-003": [("status", "Posted", BATCHES), ("category", "Accrual", HEADERS)],
|
| 25 |
+
"GL-FUS-004": [("source", "Manual", BATCHES), ("status", "Unposted", BATCHES)],
|
| 26 |
+
"GL-FUS-005": [("status", "Unposted", BATCHES), ("category", "Allocation", HEADERS)],
|
| 27 |
+
}
|
| 28 |
+
# the subledger sources (Create Accounting) and what no screen action makes: reported as needing interface testing
|
| 29 |
+
SUBLEDGER = ("Payables", "Receivables", "Projects", "Payroll", "Cash Management")
|
| 30 |
+
UNCOVERED = [("source", v, BATCHES) for v in (*SUBLEDGER, "AutoCopy", "Spreadsheet", "Allocation")]
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def library() -> dict[str, dict]:
|
| 34 |
+
return {c["id"]: c for c in cases_adapter.load_cases()}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def dimension_spec(key: str, resource: str) -> dict:
|
| 38 |
+
spec = next(s for s in usage.USAGE["GL"] if s["resource"] == resource)
|
| 39 |
+
return next(d for d in spec["dimensions"] if d["key"] == key)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def profile() -> dict:
|
| 43 |
+
"""Every variant above in use (small samples of a client's records)."""
|
| 44 |
+
wanted = {(k, v, r) for xs in INTENDED.values() for k, v, r in xs} | set(UNCOVERED)
|
| 45 |
+
dims, resources = [], []
|
| 46 |
+
for resource in (BATCHES, HEADERS):
|
| 47 |
+
for key in sorted({k for k, _v, r in wanted if r == resource}):
|
| 48 |
+
d = dimension_spec(key, resource)
|
| 49 |
+
field = d["field"] if isinstance(d["field"], str) else d["field"][0]
|
| 50 |
+
items = [{field: v} for k, v, r in sorted(wanted) if (k, r) == (key, resource) for _ in range(10)]
|
| 51 |
+
dims.append(usage.count_dimension(d, items, resource))
|
| 52 |
+
resources.append({"resource": resource, "status": "read", "total": 100})
|
| 53 |
+
return {"read_at": "2026-11-22T00:00:00Z", "days": 90, "since": "2026-08-24",
|
| 54 |
+
"areas": [{"code": "GL", "name": "General Ledger", "status": "read", "dimensions": dims, "resources": resources}]}
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def checked(*steps: dict, values: dict | None = None) -> list[str]:
|
| 58 |
+
return sw.check_steps({"test_values": {"amount": "100"} if values is None else values, "expected_result": "The journal is handled.",
|
| 59 |
+
"steps": [{"action": "sign_in"}, *steps]}, GL_INV)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
class TestGlScenarios(unittest.TestCase):
|
| 63 |
+
def test_each_loads_as_a_fusion_scenario_of_the_general_ledger(self):
|
| 64 |
+
lib = library()
|
| 65 |
+
for cid in NEW:
|
| 66 |
+
self.assertIn(cid, lib)
|
| 67 |
+
self.assertEqual((lib[cid]["target"], lib[cid]["module"]), ("fusion", "GL"), cid)
|
| 68 |
+
|
| 69 |
+
def test_each_uses_only_allowed_runner_actions_passes_the_step_checks_and_has_its_spec(self):
|
| 70 |
+
known = runner_actions()
|
| 71 |
+
for cid in NEW:
|
| 72 |
+
d = yaml_draft(cid)
|
| 73 |
+
acts = {s["action"] for s in d["steps"]}
|
| 74 |
+
self.assertTrue(acts <= set(sw.ALLOWED_ACTIONS) and acts <= known, (cid, acts - set(sw.ALLOWED_ACTIONS)))
|
| 75 |
+
self.assertEqual(sw.check_steps(d, GL_INV), [], cid)
|
| 76 |
+
doc = yaml.safe_load((sw.CASES_DIR / f"{cid}.yaml").read_text(encoding="utf-8"))
|
| 77 |
+
self.assertEqual((doc["runner"], bool(doc.get("canary"))), ("steps", False))
|
| 78 |
+
entry = (ROOT / "automation" / "tests" / "fusion" / "steps" / f"{cid}.spec.ts").read_text(encoding="utf-8")
|
| 79 |
+
self.assertIn(f"stepsTest('{cid}', ['@{cid}','@GL'", entry)
|
| 80 |
+
|
| 81 |
+
def test_a_posted_journal_is_always_reversed_by_the_scenario_and_an_unposted_one_is_left_to_clean_up(self):
|
| 82 |
+
for cid in NEW:
|
| 83 |
+
acts = [s["action"] for s in yaml_draft(cid)["steps"]]
|
| 84 |
+
if "post_journal" in acts:
|
| 85 |
+
self.assertIn("reverse_journal", acts[acts.index("post_journal"):], cid)
|
| 86 |
+
else:
|
| 87 |
+
self.assertEqual(acts.count("create_journal"), 1, cid)
|
| 88 |
+
unposted = [s for s in yaml_draft("GL-FUS-004")["steps"] if s["action"] == "expect_journal"][0]
|
| 89 |
+
self.assertEqual((unposted["status"], unposted["posted"]), ("Unposted", False))
|
| 90 |
+
|
| 91 |
+
def test_only_a_manual_source_is_ever_asked_for_and_no_scenario_runs_the_subledger(self):
|
| 92 |
+
for cid in NEW:
|
| 93 |
+
for s in yaml_draft(cid)["steps"]:
|
| 94 |
+
self.assertIn(s.get("source", "Manual"), sw.JOURNAL_SOURCES, cid)
|
| 95 |
+
bad = checked({"action": "create_journal", "source": "Payables"}, {"action": "find_journal"})
|
| 96 |
+
self.assertTrue(any("subledger" in p for p in bad), bad)
|
| 97 |
+
self.assertEqual(checked({"action": "create_journal", "source": "Manual"}, {"action": "find_journal"}), [])
|
| 98 |
+
|
| 99 |
+
def test_a_journal_expected_posted_or_reversed_must_be_posted_first(self):
|
| 100 |
+
made = {"action": "create_journal"}
|
| 101 |
+
for last in ({"action": "reverse_journal"}, {"action": "expect_journal", "status": "Posted"}, {"action": "expect_journal", "posted": True}):
|
| 102 |
+
bad = checked(made, last)
|
| 103 |
+
self.assertTrue(any("post_journal" in p for p in bad), (last, bad))
|
| 104 |
+
ok = checked(made, {"action": "post_journal"}, {"action": "expect_journal", "category": "Accrual", "source": "Manual"},
|
| 105 |
+
{"action": "reverse_journal"})
|
| 106 |
+
self.assertEqual(ok, [])
|
| 107 |
+
|
| 108 |
+
def test_category_is_a_name_or_a_placeholder_and_only_on_the_journal_actions(self):
|
| 109 |
+
for cat in ("Adjustment", "{{pod.gl.category}}"):
|
| 110 |
+
self.assertEqual(checked({"action": "create_journal", "category": cat}, {"action": "find_journal"}), [], cat)
|
| 111 |
+
self.assertTrue(checked({"action": "create_journal", "category": "1; drop"}, {"action": "find_journal"}))
|
| 112 |
+
bad = checked({"action": "create_journal"}, {"action": "find_journal", "category": "Accrual"})
|
| 113 |
+
self.assertTrue(any("belongs to" in p for p in bad), bad)
|
| 114 |
+
|
| 115 |
+
def test_the_intended_variants_are_covered_by_the_new_scenarios(self):
|
| 116 |
+
lib = library()
|
| 117 |
+
cov = usage.coverage(profile(), list(lib.values()))
|
| 118 |
+
by_key = {(v["dimension"], v["value"]): v for v in cov["variants"]}
|
| 119 |
+
for cid, variants in INTENDED.items():
|
| 120 |
+
text = usage._scenario_text(lib[cid])
|
| 121 |
+
for k, v, _r in variants:
|
| 122 |
+
got = by_key[(k, v)]
|
| 123 |
+
self.assertEqual(got["status"], "covered", (k, v))
|
| 124 |
+
self.assertIsNotNone(usage._match(got["phrases"], text), (cid, k, v, got["phrases"]))
|
| 125 |
+
|
| 126 |
+
def test_subledger_sources_and_autocopy_stay_not_covered(self):
|
| 127 |
+
lib = library()
|
| 128 |
+
cov = usage.coverage(profile(), list(lib.values()))
|
| 129 |
+
by_key = {(v["dimension"], v["value"]): v for v in cov["variants"]}
|
| 130 |
+
for k, v, _r in UNCOVERED:
|
| 131 |
+
self.assertNotEqual(by_key[(k, v)]["status"], "covered", (k, v))
|
| 132 |
+
self.assertFalse({m["id"] for m in by_key[(k, v)]["matches"]} & set(NEW), (k, v))
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
if __name__ == "__main__":
|
| 136 |
+
unittest.main()
|
coworker/tests/test_nav_links.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Per-pod Fusion navigation links: a consultant pastes the address of a work area the menus do not show to the test user,
|
| 2 |
+
and runs open it directly (FPT_NAV_LINKS). Only the pod's own host is ever accepted. No browser."""
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import json
|
| 6 |
+
import unittest
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
from ..adapters import remote_runner
|
| 10 |
+
from ..platform.pods import PodRegistry
|
| 11 |
+
from .fakes import bearer, make_app
|
| 12 |
+
|
| 13 |
+
HOST = "acme-test.fa.ocs.oraclecloud.com"
|
| 14 |
+
POD = {"name": "Acme test pod", "kind": "fusion", "base_url": f"https://{HOST}", "environment": "test", "modules": ["ap"]}
|
| 15 |
+
KEY = "Procurement > Purchase Orders"
|
| 16 |
+
URL = f"https://{HOST}/fscmUI/faces/FuseOverview?fndGlobalItemNodeId=itemNode_procurement_purchase_orders"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class TestNavLinks(unittest.TestCase):
|
| 20 |
+
def setUp(self):
|
| 21 |
+
self.app, self.c, self.svc, _ = make_app()
|
| 22 |
+
self.h = {r: bearer(self.c, r) for r in ("viewer", "consultant", "admin")}
|
| 23 |
+
r = self.c.post("/api/pods", json=POD, headers=self.h["admin"])
|
| 24 |
+
self.assertEqual(r.status_code, 201, r.text)
|
| 25 |
+
self.pod = r.json()["id"]
|
| 26 |
+
self.c.post(f"/api/pods/{self.pod}/credentials", json={"module": "AP", "username": "zz.ap", "password": "pw-nav-test-1"}, headers=self.h["admin"])
|
| 27 |
+
self.url = f"/api/pods/{self.pod}/nav-links"
|
| 28 |
+
|
| 29 |
+
def put(self, links, who="admin"):
|
| 30 |
+
return self.c.put(self.url, json={"links": links}, headers=self.h[who])
|
| 31 |
+
|
| 32 |
+
def test_validation_refuses_anything_but_the_pods_own_fusion_pages(self):
|
| 33 |
+
for why, links in {
|
| 34 |
+
"another host": {KEY: "https://evil.example.com/fscmUI/faces/FuseOverview"},
|
| 35 |
+
"a look-alike host": {KEY: f"https://{HOST}.evil.example.com/fscmUI/x"},
|
| 36 |
+
"a host with the pod's name as the user": {KEY: f"https://{HOST}@evil.example.com/fscmUI/x"},
|
| 37 |
+
"another port": {KEY: f"https://{HOST}:8443/fscmUI/x"},
|
| 38 |
+
"http": {KEY: f"http://{HOST}/fscmUI/x"},
|
| 39 |
+
"credentials": {KEY: f"https://user:pw@{HOST}/fscmUI/x"},
|
| 40 |
+
"a path outside the Fusion UIs": {KEY: f"https://{HOST}/analytics/saw.dll"},
|
| 41 |
+
"a path climbing out": {KEY: f"https://{HOST}/fscmUI/../analytics/x"},
|
| 42 |
+
"a space in the address": {KEY: f"https://{HOST}/fscmUI/a b"},
|
| 43 |
+
"a key without a group": {"Purchase Orders": URL},
|
| 44 |
+
"an empty page": {"Procurement > ": URL},
|
| 45 |
+
"a scheme-less address": {KEY: f"{HOST}/fscmUI/x"},
|
| 46 |
+
"a script": {KEY: "javascript:alert(1)"},
|
| 47 |
+
"30+ entries": {f"G > P{i}": URL for i in range(31)},
|
| 48 |
+
"the same key twice": {KEY: URL, "procurement > purchase orders": URL},
|
| 49 |
+
}.items():
|
| 50 |
+
with self.subTest(why):
|
| 51 |
+
r = self.put(links)
|
| 52 |
+
self.assertEqual((r.status_code, r.json()["code"]), (422, "BAD_NAV_LINK"), r.text)
|
| 53 |
+
self.assertEqual(self.c.get(self.url, headers=self.h["viewer"]).json()["links"], {}) # nothing was saved
|
| 54 |
+
|
| 55 |
+
def test_valid_links_are_saved_with_the_pod_and_replace_the_set(self):
|
| 56 |
+
hcm = f"https://{HOST}/hcmUI/faces/FuseWelcome"
|
| 57 |
+
r = self.put({" Procurement > Purchase Orders ": URL, "Payroll > Checks": hcm, "A > B": f"https://{HOST.upper()}/crmUI/x"})
|
| 58 |
+
self.assertEqual(r.status_code, 200, r.text)
|
| 59 |
+
self.assertEqual(r.json()["links"][KEY], URL) # key tidied
|
| 60 |
+
self.assertEqual(self.c.get(self.url, headers=self.h["viewer"]).json()["links"], r.json()["links"])
|
| 61 |
+
pod = next(p for p in self.c.get("/api/pods", headers=self.h["viewer"]).json() if p["id"] == self.pod)
|
| 62 |
+
self.assertEqual(pod["nav_links"], r.json()["links"]) # on the pod row, for the page
|
| 63 |
+
self.assertEqual(self.put({KEY: URL}).json()["links"], {KEY: URL}) # a PUT replaces
|
| 64 |
+
self.assertEqual(self.put({}).json()["links"], {}) # and an empty one clears
|
| 65 |
+
self.assertEqual(self.c.get("/api/pods/9999/nav-links", headers=self.h["viewer"]).status_code, 404)
|
| 66 |
+
|
| 67 |
+
def test_30_entries_are_allowed_and_only_an_admin_edits(self):
|
| 68 |
+
self.assertEqual(self.put({f"G > P{i}": URL for i in range(30)}).status_code, 200)
|
| 69 |
+
for who in ("viewer", "consultant"):
|
| 70 |
+
self.assertEqual(self.put({KEY: URL}, who).status_code, 403, who)
|
| 71 |
+
self.assertEqual(self.c.get(self.url, headers=self.h[who]).status_code, 200, who) # reading is open to every role
|
| 72 |
+
self.assertEqual(self.c.get(self.url).status_code, 401)
|
| 73 |
+
|
| 74 |
+
def test_a_save_is_audited_without_the_addresses(self):
|
| 75 |
+
self.put({KEY: URL})
|
| 76 |
+
rows = self.c.get("/api/audit?limit=500", headers=self.h["admin"]).json()
|
| 77 |
+
rows = rows["items"] if isinstance(rows, dict) else rows
|
| 78 |
+
hit = [a for a in rows if a["kind"] == "pod.nav_links_set"]
|
| 79 |
+
self.assertEqual(len(hit), 1)
|
| 80 |
+
self.assertEqual(hit[0]["actor"], "admin")
|
| 81 |
+
self.assertIn(KEY, json.dumps(hit[0]))
|
| 82 |
+
self.assertNotIn("fndGlobalItemNodeId", json.dumps(hit[0]))
|
| 83 |
+
|
| 84 |
+
def test_links_reach_the_runs_of_that_pod_and_both_allow_lists(self):
|
| 85 |
+
reg = PodRegistry(self.svc.db, self.svc.vault, self.svc.cfg, self.svc.egress, self.svc.audit)
|
| 86 |
+
self.assertNotIn("FPT_NAV_LINKS", reg.executor_env(self.pod)) # none saved: nothing passed
|
| 87 |
+
self.put({KEY: URL})
|
| 88 |
+
env = reg.executor_env(self.pod)
|
| 89 |
+
self.assertEqual(json.loads(env["FPT_NAV_LINKS"]), {KEY: URL})
|
| 90 |
+
self.assertIn("FPT_NAV_LINKS", remote_runner.ENV_KEYS)
|
| 91 |
+
server = (Path(remote_runner.__file__).resolve().parents[2] / "automation" / "remote_runner" / "server.py").read_text(encoding="utf-8")
|
| 92 |
+
self.assertRegex(server, r'ENV_KEYS = \{[^}]*"FPT_NAV_LINKS"')
|
| 93 |
+
other = self.c.post("/api/pods", json={**POD, "name": "Other pod", "base_url": "https://other-test.fa.ocs.oraclecloud.com"},
|
| 94 |
+
headers=self.h["admin"]).json()["id"]
|
| 95 |
+
self.assertEqual(reg.nav_links(other), {}) # another pod's runs do not get it
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
if __name__ == "__main__":
|
| 99 |
+
unittest.main()
|
tests/cases/AP-FUS-020.yaml
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Oracle Fusion Payables test case written as plain steps (runner: steps): no hand-written code. Built from business
|
| 2 |
+
# actions (automation/src/fusion/steps.ts), each proven on the pod by the canary (CANARY-AP) before a run, except the payment
|
| 3 |
+
# actions: a payment is a scenario's own (it is not in the canary). The invoice is entered with payment method Electronic and paid in full by a quick payment; the clean-up
|
| 4 |
+
# voids the test payment on Manage Payments, then cancels the invoice (pass or fail). Written for a usage gap of the client's pod.
|
| 5 |
+
id: AP-FUS-020
|
| 6 |
+
title: "Quick payment by Electronic of a validated invoice is made, found on Manage Payments and Negotiable (step runner)"
|
| 7 |
+
runner: steps
|
| 8 |
+
process: Payments
|
| 9 |
+
priority: P2
|
| 10 |
+
priority_rationale: "The client pays invoices by Electronic; a quick payment made with that method must be created, found and checked in Fusion."
|
| 11 |
+
map_ids: []
|
| 12 |
+
verification: VERIFIED on a real Fusion pod when its run passes
|
| 13 |
+
approval_status: draft - pending consultant approval (architecture approval gate)
|
| 14 |
+
type: happy
|
| 15 |
+
tags:
|
| 16 |
+
- payables
|
| 17 |
+
- payments
|
| 18 |
+
- quick-payment
|
| 19 |
+
- negotiable
|
| 20 |
+
- electronic
|
| 21 |
+
- fusion
|
| 22 |
+
- step-runner
|
| 23 |
+
roles:
|
| 24 |
+
- payables_user
|
| 25 |
+
preconditions:
|
| 26 |
+
- "The test user can create, validate and pay Payables invoices in the business unit."
|
| 27 |
+
- "The pod has a bank account and payment document the test user may pay from (the pod's test data ap.bank_account and ap.payment_document, or Fusion's defaults)."
|
| 28 |
+
- "The payment method Electronic is set up on the pod."
|
| 29 |
+
data_recipes: []
|
| 30 |
+
test_values:
|
| 31 |
+
amount: "300"
|
| 32 |
+
steps:
|
| 33 |
+
- n: 1
|
| 34 |
+
action: sign_in
|
| 35 |
+
expected: "The Fusion home page opens for the test user."
|
| 36 |
+
- n: 2
|
| 37 |
+
action: create_invoice
|
| 38 |
+
value: "{{tv.amount}}"
|
| 39 |
+
payment_method: Electronic
|
| 40 |
+
expected: "An invoice of 300 with one Item line and payment method Electronic is saved without errors."
|
| 41 |
+
- n: 3
|
| 42 |
+
action: validate_invoice
|
| 43 |
+
expected: "Validated; when Fusion's tax leaves it out of balance, the amount is set to the Total first."
|
| 44 |
+
- n: 4
|
| 45 |
+
action: expect_invoice
|
| 46 |
+
status: Validated
|
| 47 |
+
payment_method: Electronic
|
| 48 |
+
amount_at_least: "{{tv.amount}}"
|
| 49 |
+
expected: "Fusion has the invoice as Validated with payment method Electronic."
|
| 50 |
+
- n: 5
|
| 51 |
+
action: create_payment
|
| 52 |
+
payment_method: Electronic
|
| 53 |
+
payment_type: Quick
|
| 54 |
+
expected: "The invoice is paid in full with a quick payment by Electronic (Invoice Actions > Pay in Full)."
|
| 55 |
+
- n: 6
|
| 56 |
+
action: find_payment
|
| 57 |
+
expected: "Manage Payments finds exactly this payment by its number."
|
| 58 |
+
- n: 7
|
| 59 |
+
action: expect_payment
|
| 60 |
+
status: Negotiable
|
| 61 |
+
payment_method: Electronic
|
| 62 |
+
payment_type: Quick
|
| 63 |
+
amount_at_least: "{{tv.amount}}"
|
| 64 |
+
expected: "Fusion has the payment as a Quick payment by Electronic, for at least 300, with status Negotiable (the status Fusion gives a payment made and not yet reconciled or voided)."
|
| 65 |
+
expected_result: "The invoice is paid by a quick payment with payment method Electronic, which is found on Manage Payments with status Negotiable; the clean-up voids the payment and cancels the test invoice afterwards."
|
tests/cases/AP-FUS-021.yaml
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Oracle Fusion Payables test case written as plain steps (runner: steps): no hand-written code. Built from business
|
| 2 |
+
# actions (automation/src/fusion/steps.ts), each proven on the pod by the canary (CANARY-AP) before a run, except the payment
|
| 3 |
+
# actions: a payment is a scenario's own (it is not in the canary). The invoice is entered with payment method Check and paid in full by a quick payment; the clean-up
|
| 4 |
+
# voids the test payment on Manage Payments, then cancels the invoice (pass or fail). Written for a usage gap of the client's pod.
|
| 5 |
+
id: AP-FUS-021
|
| 6 |
+
title: "Quick payment by Check of a validated invoice is made, found on Manage Payments and Negotiable (step runner)"
|
| 7 |
+
runner: steps
|
| 8 |
+
process: Payments
|
| 9 |
+
priority: P2
|
| 10 |
+
priority_rationale: "The client pays invoices by Check; a quick payment made with that method must be created, found and checked in Fusion."
|
| 11 |
+
map_ids: []
|
| 12 |
+
verification: VERIFIED on a real Fusion pod when its run passes
|
| 13 |
+
approval_status: draft - pending consultant approval (architecture approval gate)
|
| 14 |
+
type: happy
|
| 15 |
+
tags:
|
| 16 |
+
- payables
|
| 17 |
+
- payments
|
| 18 |
+
- quick-payment
|
| 19 |
+
- negotiable
|
| 20 |
+
- check
|
| 21 |
+
- fusion
|
| 22 |
+
- step-runner
|
| 23 |
+
roles:
|
| 24 |
+
- payables_user
|
| 25 |
+
preconditions:
|
| 26 |
+
- "The test user can create, validate and pay Payables invoices in the business unit."
|
| 27 |
+
- "The pod has a bank account and payment document the test user may pay from (the pod's test data ap.bank_account and ap.payment_document, or Fusion's defaults)."
|
| 28 |
+
- "The payment method Check is set up on the pod."
|
| 29 |
+
data_recipes: []
|
| 30 |
+
test_values:
|
| 31 |
+
amount: "300"
|
| 32 |
+
steps:
|
| 33 |
+
- n: 1
|
| 34 |
+
action: sign_in
|
| 35 |
+
expected: "The Fusion home page opens for the test user."
|
| 36 |
+
- n: 2
|
| 37 |
+
action: create_invoice
|
| 38 |
+
value: "{{tv.amount}}"
|
| 39 |
+
payment_method: Check
|
| 40 |
+
expected: "An invoice of 300 with one Item line and payment method Check is saved without errors."
|
| 41 |
+
- n: 3
|
| 42 |
+
action: validate_invoice
|
| 43 |
+
expected: "Validated; when Fusion's tax leaves it out of balance, the amount is set to the Total first."
|
| 44 |
+
- n: 4
|
| 45 |
+
action: expect_invoice
|
| 46 |
+
status: Validated
|
| 47 |
+
payment_method: Check
|
| 48 |
+
amount_at_least: "{{tv.amount}}"
|
| 49 |
+
expected: "Fusion has the invoice as Validated with payment method Check."
|
| 50 |
+
- n: 5
|
| 51 |
+
action: create_payment
|
| 52 |
+
payment_method: Check
|
| 53 |
+
payment_type: Quick
|
| 54 |
+
expected: "The invoice is paid in full with a quick payment by Check (Invoice Actions > Pay in Full)."
|
| 55 |
+
- n: 6
|
| 56 |
+
action: find_payment
|
| 57 |
+
expected: "Manage Payments finds exactly this payment by its number."
|
| 58 |
+
- n: 7
|
| 59 |
+
action: expect_payment
|
| 60 |
+
status: Negotiable
|
| 61 |
+
payment_method: Check
|
| 62 |
+
payment_type: Quick
|
| 63 |
+
amount_at_least: "{{tv.amount}}"
|
| 64 |
+
expected: "Fusion has the payment as a Quick payment by Check, for at least 300, with status Negotiable (the status Fusion gives a payment made and not yet reconciled or voided)."
|
| 65 |
+
expected_result: "The invoice is paid by a quick payment with payment method Check, which is found on Manage Payments with status Negotiable; the clean-up voids the payment and cancels the test invoice afterwards."
|
tests/cases/AP-FUS-022.yaml
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Oracle Fusion Payables test case written as plain steps (runner: steps): no hand-written code. Built from business
|
| 2 |
+
# actions (automation/src/fusion/steps.ts), each proven on the pod by the canary (CANARY-AP) before a run, except the payment
|
| 3 |
+
# actions: a payment is a scenario's own (it is not in the canary). The invoice is entered with payment method Wire and paid in full by a quick payment; the clean-up
|
| 4 |
+
# voids the test payment on Manage Payments, then cancels the invoice (pass or fail). Written for a usage gap of the client's pod.
|
| 5 |
+
id: AP-FUS-022
|
| 6 |
+
title: "Quick payment by Wire of a validated invoice is made, found on Manage Payments and Negotiable (step runner)"
|
| 7 |
+
runner: steps
|
| 8 |
+
process: Payments
|
| 9 |
+
priority: P2
|
| 10 |
+
priority_rationale: "The client pays invoices by Wire; a quick payment made with that method must be created, found and checked in Fusion."
|
| 11 |
+
map_ids: []
|
| 12 |
+
verification: VERIFIED on a real Fusion pod when its run passes
|
| 13 |
+
approval_status: draft - pending consultant approval (architecture approval gate)
|
| 14 |
+
type: happy
|
| 15 |
+
tags:
|
| 16 |
+
- payables
|
| 17 |
+
- payments
|
| 18 |
+
- quick-payment
|
| 19 |
+
- negotiable
|
| 20 |
+
- wire
|
| 21 |
+
- fusion
|
| 22 |
+
- step-runner
|
| 23 |
+
roles:
|
| 24 |
+
- payables_user
|
| 25 |
+
preconditions:
|
| 26 |
+
- "The test user can create, validate and pay Payables invoices in the business unit."
|
| 27 |
+
- "The pod has a bank account and payment document the test user may pay from (the pod's test data ap.bank_account and ap.payment_document, or Fusion's defaults)."
|
| 28 |
+
- "The payment method Wire is set up on the pod."
|
| 29 |
+
data_recipes: []
|
| 30 |
+
test_values:
|
| 31 |
+
amount: "300"
|
| 32 |
+
steps:
|
| 33 |
+
- n: 1
|
| 34 |
+
action: sign_in
|
| 35 |
+
expected: "The Fusion home page opens for the test user."
|
| 36 |
+
- n: 2
|
| 37 |
+
action: create_invoice
|
| 38 |
+
value: "{{tv.amount}}"
|
| 39 |
+
payment_method: Wire
|
| 40 |
+
expected: "An invoice of 300 with one Item line and payment method Wire is saved without errors."
|
| 41 |
+
- n: 3
|
| 42 |
+
action: validate_invoice
|
| 43 |
+
expected: "Validated; when Fusion's tax leaves it out of balance, the amount is set to the Total first."
|
| 44 |
+
- n: 4
|
| 45 |
+
action: expect_invoice
|
| 46 |
+
status: Validated
|
| 47 |
+
payment_method: Wire
|
| 48 |
+
amount_at_least: "{{tv.amount}}"
|
| 49 |
+
expected: "Fusion has the invoice as Validated with payment method Wire."
|
| 50 |
+
- n: 5
|
| 51 |
+
action: create_payment
|
| 52 |
+
payment_method: Wire
|
| 53 |
+
payment_type: Quick
|
| 54 |
+
expected: "The invoice is paid in full with a quick payment by Wire (Invoice Actions > Pay in Full)."
|
| 55 |
+
- n: 6
|
| 56 |
+
action: find_payment
|
| 57 |
+
expected: "Manage Payments finds exactly this payment by its number."
|
| 58 |
+
- n: 7
|
| 59 |
+
action: expect_payment
|
| 60 |
+
status: Negotiable
|
| 61 |
+
payment_method: Wire
|
| 62 |
+
payment_type: Quick
|
| 63 |
+
amount_at_least: "{{tv.amount}}"
|
| 64 |
+
expected: "Fusion has the payment as a Quick payment by Wire, for at least 300, with status Negotiable (the status Fusion gives a payment made and not yet reconciled or voided)."
|
| 65 |
+
expected_result: "The invoice is paid by a quick payment with payment method Wire, which is found on Manage Payments with status Negotiable; the clean-up voids the payment and cancels the test invoice afterwards."
|
tests/cases/AP-FUS-023.yaml
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Oracle Fusion Payables test case written as plain steps (runner: steps): no hand-written code. Built from business
|
| 2 |
+
# actions (automation/src/fusion/steps.ts), each proven on the pod by the canary (CANARY-AP) before a run, except the payment
|
| 3 |
+
# actions: a payment is a scenario's own (it is not in the canary). A validated invoice is paid by a quick payment, which the scenario then voids
|
| 4 |
+
# (Manage Payments > Actions > Void Payment). The clean-up cancels the test invoice, pass or fail. Written for a usage gap of the
|
| 5 |
+
# client's pod.
|
| 6 |
+
id: AP-FUS-023
|
| 7 |
+
title: "Quick payment of a validated invoice is voided and Fusion shows the payment Voided (step runner)"
|
| 8 |
+
runner: steps
|
| 9 |
+
process: Payments
|
| 10 |
+
priority: P2
|
| 11 |
+
priority_rationale: "The client voids payments; the Void action must leave the payment with status Voided."
|
| 12 |
+
map_ids: []
|
| 13 |
+
verification: VERIFIED on a real Fusion pod when its run passes
|
| 14 |
+
approval_status: draft - pending consultant approval (architecture approval gate)
|
| 15 |
+
type: happy
|
| 16 |
+
tags:
|
| 17 |
+
- payables
|
| 18 |
+
- payments
|
| 19 |
+
- quick-payment
|
| 20 |
+
- void-payment
|
| 21 |
+
- fusion
|
| 22 |
+
- step-runner
|
| 23 |
+
roles:
|
| 24 |
+
- payables_user
|
| 25 |
+
preconditions:
|
| 26 |
+
- "The test user can create, validate and pay Payables invoices in the business unit."
|
| 27 |
+
- "The pod has a bank account and payment document the test user may pay from (the pod's test data ap.bank_account and ap.payment_document, or Fusion's defaults)."
|
| 28 |
+
data_recipes: []
|
| 29 |
+
test_values:
|
| 30 |
+
amount: "300"
|
| 31 |
+
steps:
|
| 32 |
+
- n: 1
|
| 33 |
+
action: sign_in
|
| 34 |
+
expected: "The Fusion home page opens for the test user."
|
| 35 |
+
- n: 2
|
| 36 |
+
action: create_invoice
|
| 37 |
+
value: "{{tv.amount}}"
|
| 38 |
+
expected: "An invoice of 300 with one Item line is saved without errors."
|
| 39 |
+
- n: 3
|
| 40 |
+
action: validate_invoice
|
| 41 |
+
expected: "Validated; when Fusion's tax leaves it out of balance, the amount is set to the Total first."
|
| 42 |
+
- n: 4
|
| 43 |
+
action: create_payment
|
| 44 |
+
payment_type: Quick
|
| 45 |
+
expected: "The invoice is paid in full with a quick payment."
|
| 46 |
+
- n: 5
|
| 47 |
+
action: expect_payment
|
| 48 |
+
payment_type: Quick
|
| 49 |
+
amount_at_least: "{{tv.amount}}"
|
| 50 |
+
expected: "Fusion has the payment as a Quick payment for at least 300."
|
| 51 |
+
- n: 6
|
| 52 |
+
action: void_payment
|
| 53 |
+
expected: "Manage Payments: Actions > Void Payment on this payment."
|
| 54 |
+
- n: 7
|
| 55 |
+
action: expect_payment
|
| 56 |
+
status: Voided
|
| 57 |
+
expected: "Fusion shows the payment as Voided."
|
| 58 |
+
expected_result: "The quick payment is made and then voided; Fusion shows it Voided; the clean-up cancels the test invoice afterwards."
|
tests/cases/AP-FUS-024.yaml
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Oracle Fusion Payables test case written as plain steps (runner: steps): no hand-written code. Built from business
|
| 2 |
+
# actions (automation/src/fusion/steps.ts), each proven on the pod by the canary (CANARY-AP) before a run, except the payment
|
| 3 |
+
# actions: a payment is a scenario's own (it is not in the canary). A standard invoice is validated and its approval status is checked through Fusion REST (ApprovalStatus). The step
|
| 4 |
+
# runner cancels the test invoice afterwards, pass or fail. Written for a usage gap of the client's pod.
|
| 5 |
+
id: AP-FUS-024
|
| 6 |
+
title: "Standard invoice validated with approval not required shows approval status Not required (step runner)"
|
| 7 |
+
runner: steps
|
| 8 |
+
process: Invoice approval
|
| 9 |
+
priority: P2
|
| 10 |
+
priority_rationale: "Most of the client's invoices need no approval; the approval status Not required must show on such an invoice."
|
| 11 |
+
map_ids: []
|
| 12 |
+
verification: VERIFIED on a real Fusion pod when its run passes
|
| 13 |
+
approval_status: draft - pending consultant approval (architecture approval gate)
|
| 14 |
+
type: happy
|
| 15 |
+
tags:
|
| 16 |
+
- payables
|
| 17 |
+
- invoice-approval
|
| 18 |
+
- approval-status
|
| 19 |
+
- not-required
|
| 20 |
+
- fusion
|
| 21 |
+
- step-runner
|
| 22 |
+
roles:
|
| 23 |
+
- payables_user
|
| 24 |
+
preconditions:
|
| 25 |
+
- "The test user can create and validate Payables invoices in the business unit."
|
| 26 |
+
- "Invoice approval is not required for the business unit's standard invoices (the pod's approval rules): on a pod that approves every invoice this scenario fails, which is its point."
|
| 27 |
+
data_recipes: []
|
| 28 |
+
test_values:
|
| 29 |
+
amount: "100"
|
| 30 |
+
steps:
|
| 31 |
+
- n: 1
|
| 32 |
+
action: sign_in
|
| 33 |
+
expected: "The Fusion home page opens for the test user."
|
| 34 |
+
- n: 2
|
| 35 |
+
action: create_invoice
|
| 36 |
+
value: "{{tv.amount}}"
|
| 37 |
+
expected: "A standard invoice of 100 with one Item line is saved without errors."
|
| 38 |
+
- n: 3
|
| 39 |
+
action: validate_invoice
|
| 40 |
+
expected: "Validated; when Fusion's tax leaves it out of balance, the amount is set to the Total first."
|
| 41 |
+
- n: 4
|
| 42 |
+
action: expect_invoice
|
| 43 |
+
status: Validated
|
| 44 |
+
approval_status: Not required
|
| 45 |
+
amount_at_least: "{{tv.amount}}"
|
| 46 |
+
expected: "Fusion has the invoice as Validated with approval status Not required."
|
| 47 |
+
expected_result: "The validated invoice shows approval status Not required in Fusion; the test invoice is cancelled afterwards."
|
tests/cases/AP-FUS-025.yaml
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Oracle Fusion Payables test case written as plain steps (runner: steps): no hand-written code. Built from business
|
| 2 |
+
# actions (automation/src/fusion/steps.ts), each proven on the pod by the canary (CANARY-AP) before a run, except the payment
|
| 3 |
+
# actions: a payment is a scenario's own (it is not in the canary). A standard invoice is saved and left alone; its validation status is checked through Fusion REST (ValidationStatus;
|
| 4 |
+
# AP-FUS-013 checks the same on the page). The step runner cancels the test invoice afterwards, pass or fail. Written for a
|
| 5 |
+
# usage gap of the client's pod.
|
| 6 |
+
id: AP-FUS-025
|
| 7 |
+
title: "Saved invoice never validated shows validation status Not validated in Fusion (step runner)"
|
| 8 |
+
runner: steps
|
| 9 |
+
process: Invoice validation
|
| 10 |
+
priority: P2
|
| 11 |
+
priority_rationale: "About four in ten of the client's invoices stay not validated; the status must be Not validated in Fusion itself, not only on the page."
|
| 12 |
+
map_ids: []
|
| 13 |
+
verification: VERIFIED on a real Fusion pod when its run passes
|
| 14 |
+
approval_status: draft - pending consultant approval (architecture approval gate)
|
| 15 |
+
type: happy
|
| 16 |
+
tags:
|
| 17 |
+
- payables
|
| 18 |
+
- invoice-validation
|
| 19 |
+
- validation-status
|
| 20 |
+
- not-validated
|
| 21 |
+
- fusion
|
| 22 |
+
- step-runner
|
| 23 |
+
roles:
|
| 24 |
+
- payables_user
|
| 25 |
+
preconditions:
|
| 26 |
+
- "The test user can create Payables invoices in the business unit."
|
| 27 |
+
data_recipes: []
|
| 28 |
+
test_values:
|
| 29 |
+
amount: "100"
|
| 30 |
+
steps:
|
| 31 |
+
- n: 1
|
| 32 |
+
action: sign_in
|
| 33 |
+
expected: "The Fusion home page opens for the test user."
|
| 34 |
+
- n: 2
|
| 35 |
+
action: create_invoice
|
| 36 |
+
value: "{{tv.amount}}"
|
| 37 |
+
expected: "A standard invoice of 100 with one Item line is saved without errors; nothing validates it."
|
| 38 |
+
- n: 3
|
| 39 |
+
action: expect_invoice
|
| 40 |
+
validation_status: Not validated
|
| 41 |
+
canceled: false
|
| 42 |
+
amount_at_least: "{{tv.amount}}"
|
| 43 |
+
expected: "Fusion has the invoice with validation status Not validated (Never validated counts), not cancelled."
|
| 44 |
+
- n: 4
|
| 45 |
+
action: expect_no_holds
|
| 46 |
+
expected: "A saved invoice that was never validated carries no holds."
|
| 47 |
+
expected_result: "The saved invoice stays Not validated in Fusion, with no holds; the test invoice is cancelled afterwards."
|
tests/cases/AP-FUS-026.yaml
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Oracle Fusion Payables test case written as plain steps (runner: steps): no hand-written code. Built from business
|
| 2 |
+
# actions (automation/src/fusion/steps.ts), each proven on the pod by the canary (CANARY-AP) before a run, except the payment
|
| 3 |
+
# actions: a payment is a scenario's own (it is not in the canary). A validated invoice is edited (its amount changed on the open invoice) and saved, which Fusion answers with
|
| 4 |
+
# Needs revalidation (checked through REST). The step runner cancels the test invoice afterwards, pass or fail. Written for a usage
|
| 5 |
+
# gap of the client's pod.
|
| 6 |
+
id: AP-FUS-026
|
| 7 |
+
title: "Validated invoice edited again needs revalidation (step runner)"
|
| 8 |
+
runner: steps
|
| 9 |
+
process: Invoice validation
|
| 10 |
+
priority: P2
|
| 11 |
+
priority_rationale: "A validated invoice that is changed must fall back to Needs revalidation; the client has such invoices."
|
| 12 |
+
map_ids: []
|
| 13 |
+
verification: VERIFIED on a real Fusion pod when its run passes
|
| 14 |
+
approval_status: draft - pending consultant approval (architecture approval gate)
|
| 15 |
+
type: happy
|
| 16 |
+
tags:
|
| 17 |
+
- payables
|
| 18 |
+
- invoice-validation
|
| 19 |
+
- validation-status
|
| 20 |
+
- needs-revalidation
|
| 21 |
+
- fusion
|
| 22 |
+
- step-runner
|
| 23 |
+
roles:
|
| 24 |
+
- payables_user
|
| 25 |
+
preconditions:
|
| 26 |
+
- "The test user can create, validate and edit Payables invoices in the business unit."
|
| 27 |
+
- "The invoice stays open on Create Invoice after Validate and its Amount may still be changed (not proven on every pod: verify the first run)."
|
| 28 |
+
data_recipes: []
|
| 29 |
+
test_values:
|
| 30 |
+
amount: "100"
|
| 31 |
+
new_amount: "150"
|
| 32 |
+
steps:
|
| 33 |
+
- n: 1
|
| 34 |
+
action: sign_in
|
| 35 |
+
expected: "The Fusion home page opens for the test user."
|
| 36 |
+
- n: 2
|
| 37 |
+
action: create_invoice
|
| 38 |
+
value: "{{tv.amount}}"
|
| 39 |
+
expected: "A standard invoice of 100 with one Item line is saved without errors."
|
| 40 |
+
- n: 3
|
| 41 |
+
action: validate_invoice
|
| 42 |
+
expected: "Validated; when Fusion's tax leaves it out of balance, the amount is set to the Total first."
|
| 43 |
+
- n: 4
|
| 44 |
+
action: expect_invoice
|
| 45 |
+
validation_status: Validated
|
| 46 |
+
amount_at_least: "{{tv.amount}}"
|
| 47 |
+
expected: "Fusion has the invoice as Validated."
|
| 48 |
+
- n: 5
|
| 49 |
+
action: enter
|
| 50 |
+
field: Amount
|
| 51 |
+
value: "{{tv.new_amount}}"
|
| 52 |
+
expected: "The invoice's amount is changed to 150 on the open invoice."
|
| 53 |
+
- n: 6
|
| 54 |
+
action: save
|
| 55 |
+
expected: "The change is saved; Fusion no longer treats the invoice as validated."
|
| 56 |
+
- n: 7
|
| 57 |
+
action: expect_invoice
|
| 58 |
+
validation_status: Needs revalidation
|
| 59 |
+
expected: "Fusion has the invoice with validation status Needs revalidation."
|
| 60 |
+
expected_result: "The validated invoice, edited and saved, shows Needs revalidation in Fusion; the test invoice is cancelled afterwards."
|
tests/cases/AP-FUS-027.yaml
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Oracle Fusion Payables test case written as plain steps (runner: steps): no hand-written code. Built from business
|
| 2 |
+
# actions (automation/src/fusion/steps.ts), each proven on the pod by the canary (CANARY-AP) before a run, except initiate_approval:
|
| 3 |
+
# sending an invoice for approval is a scenario's own (it is not in the canary: a pod's approval rules are its own). A standard invoice is
|
| 4 |
+
# validated, its approval status is checked (Required), it is sent for approval (Invoice Actions > Approval > Initiate) and its approval
|
| 5 |
+
# status is checked again (Initiated), through Fusion REST. The clean-up withdraws the approval and cancels the test invoice (pass or fail);
|
| 6 |
+
# an approval Fusion does not let it withdraw is listed in the run's test data. Written for a usage gap of the client's pod.
|
| 7 |
+
id: AP-FUS-027
|
| 8 |
+
title: "Invoice sent for approval shows approval Initiated (approval required) (step runner)"
|
| 9 |
+
runner: steps
|
| 10 |
+
process: Invoice approval
|
| 11 |
+
priority: P2
|
| 12 |
+
priority_rationale: "The client's invoices needing approval are sent for approval by a person; an invoice with approval Required must show approval Initiated once sent."
|
| 13 |
+
map_ids: []
|
| 14 |
+
verification: VERIFIED on a real Fusion pod when its run passes
|
| 15 |
+
approval_status: draft - pending consultant approval (architecture approval gate)
|
| 16 |
+
type: happy
|
| 17 |
+
tags:
|
| 18 |
+
- payables
|
| 19 |
+
- invoice-approval
|
| 20 |
+
- approval-required
|
| 21 |
+
- approval-initiated
|
| 22 |
+
- sent-for-approval
|
| 23 |
+
- fusion
|
| 24 |
+
- step-runner
|
| 25 |
+
roles:
|
| 26 |
+
- payables_user
|
| 27 |
+
preconditions:
|
| 28 |
+
- "The test user can create, validate and send for approval Payables invoices in the business unit."
|
| 29 |
+
- "Invoice approval is set up for the business unit and requires approval of a standard invoice of this amount (the pod's approval rules): on a pod without it this scenario fails saying so, which is its point; it never passes by pretending."
|
| 30 |
+
data_recipes: []
|
| 31 |
+
test_values:
|
| 32 |
+
amount: "100"
|
| 33 |
+
steps:
|
| 34 |
+
- n: 1
|
| 35 |
+
action: sign_in
|
| 36 |
+
expected: "The Fusion home page opens for the test user."
|
| 37 |
+
- n: 2
|
| 38 |
+
action: create_invoice
|
| 39 |
+
value: "{{tv.amount}}"
|
| 40 |
+
expected: "A standard invoice of 100 with one Item line is saved without errors."
|
| 41 |
+
- n: 3
|
| 42 |
+
action: validate_invoice
|
| 43 |
+
expected: "Validated; when Fusion's tax leaves it out of balance, the amount is set to the Total first."
|
| 44 |
+
- n: 4
|
| 45 |
+
action: expect_invoice
|
| 46 |
+
status: Validated
|
| 47 |
+
approval_status: Required
|
| 48 |
+
amount_at_least: "{{tv.amount}}"
|
| 49 |
+
expected: "Fusion has the invoice as Validated with approval status Required."
|
| 50 |
+
- n: 5
|
| 51 |
+
action: initiate_approval
|
| 52 |
+
expected: "The invoice is sent for approval (Invoice Actions > Approval > Initiate); a pod without invoice approval set up fails here saying so."
|
| 53 |
+
- n: 6
|
| 54 |
+
action: expect_invoice
|
| 55 |
+
approval_status: Initiated
|
| 56 |
+
expected: "Fusion has the invoice's approval status as Initiated."
|
| 57 |
+
expected_result: "The validated invoice shows approval Required, is sent for approval and then shows approval Initiated in Fusion; the clean-up withdraws the approval and cancels the test invoice afterwards."
|
tests/cases/AR-FUS-001.yaml
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Oracle Fusion Receivables test case written as plain steps (runner: steps): no hand-written code. Built from business
|
| 2 |
+
# actions (automation/src/fusion/steps.ts), each proven on the pod by the canary (CANARY-AR) before a run.
|
| 3 |
+
# A manual invoice (source Manual, type Invoice) is completed; a completed invoice can only be undone by a person (a
|
| 4 |
+
# credit memo), so the run's clean-up lists it in the run's test data and never deletes it.
|
| 5 |
+
# Written for a usage gap of the client's pod.
|
| 6 |
+
id: AR-FUS-001
|
| 7 |
+
title: "Manual invoice is created and completed and Fusion takes it out of Incomplete (step runner)"
|
| 8 |
+
runner: steps
|
| 9 |
+
process: Transaction entry
|
| 10 |
+
priority: P1
|
| 11 |
+
priority_rationale: "Invoices keyed in by hand are the transactions a receivables clerk completes every day."
|
| 12 |
+
map_ids: []
|
| 13 |
+
verification: VERIFIED on a real Fusion pod when its run passes
|
| 14 |
+
approval_status: draft - pending consultant approval (architecture approval gate)
|
| 15 |
+
type: happy
|
| 16 |
+
tags:
|
| 17 |
+
- receivables
|
| 18 |
+
- transaction-entry
|
| 19 |
+
- invoice
|
| 20 |
+
- manual
|
| 21 |
+
- complete
|
| 22 |
+
- fusion
|
| 23 |
+
- step-runner
|
| 24 |
+
roles:
|
| 25 |
+
- accounts_receivable_specialist
|
| 26 |
+
preconditions:
|
| 27 |
+
- The test user can create transactions in the business unit.
|
| 28 |
+
- The transaction source Manual and the transaction type Invoice are set up on the pod.
|
| 29 |
+
- The test user may complete transactions.
|
| 30 |
+
data_recipes: []
|
| 31 |
+
test_values:
|
| 32 |
+
amount: "100"
|
| 33 |
+
steps:
|
| 34 |
+
- n: 1
|
| 35 |
+
action: sign_in
|
| 36 |
+
expected: The Fusion home page opens for the test user.
|
| 37 |
+
- n: 2
|
| 38 |
+
action: create_transaction
|
| 39 |
+
value: "{{tv.amount}}"
|
| 40 |
+
transaction_type: "Invoice"
|
| 41 |
+
transaction_source: "Manual"
|
| 42 |
+
expected: An invoice of one line, source Manual, is entered on Create Transaction and saved without errors.
|
| 43 |
+
- n: 3
|
| 44 |
+
action: complete_transaction
|
| 45 |
+
expected: Fusion completes the invoice and it is no longer Incomplete.
|
| 46 |
+
- n: 4
|
| 47 |
+
action: expect_transaction
|
| 48 |
+
transaction_type: "Invoice"
|
| 49 |
+
transaction_source: "Manual"
|
| 50 |
+
amount_at_least: "{{tv.amount}}"
|
| 51 |
+
expected: Fusion has the transaction as an Invoice from source Manual, for the line amount plus any tax.
|
| 52 |
+
expected_result: A manual invoice is created and completed; Fusion has it as type Invoice from source Manual. The completed invoice is left for a person to credit and is listed in the run's test data.
|