feat(transactions): port manual bank-transaction import to SSR #8

Closed
notid wants to merge 133 commits from integreat-add-transaction-manual into master
3 changed files with 86 additions and 2 deletions
Showing only changes of commit 3715910029 - Show all commits

View File

@@ -281,3 +281,53 @@ test.describe('Transaction Edit Validation', () => {
expect(parseFloat(value)).toBeCloseTo(50.0, 1);
});
});
async function openEditModalForTransaction(page: any, description: string) {
// Navigate to transactions page
await page.goto('/transaction2');
// Wait for the table to load
await page.waitForSelector('table tbody tr');
// Find the row with the specific description and click its edit button
const row = page.locator('table tbody tr', { hasText: description }).first();
const editButton = row.locator('button[hx-get*="/transaction2/"][hx-get*="/edit"]').first();
await editButton.click();
// Wait for the modal to open
await page.waitForSelector('#modal-holder[x-show="open"]', { state: 'visible' });
await page.waitForSelector('#wizardmodal');
// Click Next to go to the links step (button says "Transaction Actions")
await page.click('button:has-text("Transaction Actions")');
// Wait for the links step to load
await page.waitForSelector('text=Transaction Actions', { state: 'visible' });
}
test.describe('Transaction Link Date Display', () => {
test('should show payment date when linking to payment', async ({ page }) => {
await openEditModalForTransaction(page, 'Transaction for payment link');
// Click on "Link to payment" tab
await page.click('button:has-text("Link to payment")');
await page.waitForTimeout(500);
// Verify the payment option shows the date
await expect(page.locator('#payment-matches')).toContainText('Available Payments');
await expect(page.locator('#payment-matches')).toContainText('06/14/2023');
});
test('should show invoice date when linking to unpaid invoice', async ({ page }) => {
await openEditModalForTransaction(page, 'Transaction for unpaid invoice link');
// Click on "Link to unpaid invoices" tab
await page.click('button:has-text("Link to unpaid invoices")');
await page.waitForTimeout(500);
// Verify the invoice option shows the date
await expect(page.locator('text=Available Unpaid Invoices')).toBeVisible();
await expect(page.locator('text=UNPAID-001')).toBeVisible();
await expect(page.locator('text=07/19/2023')).toBeVisible();
});
});

View File

@@ -653,6 +653,7 @@
[:div.ml-3
[:span.block.text-sm.font-medium (:invoice/invoice-number invoice)]
[:span.block.text-sm.text-gray-500 (-> invoice :invoice/vendor :vendor/name)]
[:span.block.text-sm.text-gray-500 (some-> invoice :invoice/date coerce/to-date-time (atime/unparse-local atime/normal-date))]
[:span.block.text-sm.font-medium (format "$%.2f" (:invoice/outstanding-balance invoice))]]))})
:name (fc/with-field :autopay-invoice-ids (fc/field-name))
:width "w-full"})]]
@@ -699,6 +700,7 @@
[:div.ml-3
[:span.block.text-sm.font-medium (:invoice/invoice-number invoice)]
[:span.block.text-sm.text-gray-500 (-> invoice :invoice/vendor :vendor/name)]
[:span.block.text-sm.text-gray-500 (some-> invoice :invoice/date coerce/to-date-time (atime/unparse-local atime/normal-date))]
[:span.block.text-sm.font-medium (format "$%.2f" (:invoice/outstanding-balance invoice))]]))})
:name (fc/with-field :unpaid-invoice-ids (fc/field-name))
:width "w-full"})]

View File

@@ -3,7 +3,7 @@
(:require
[auto-ap.datomic :refer [conn transact-schema install-functions]]
[auto-ap.handler :as handler]
[auto-ap.integration.util :refer [setup-test-data test-client test-bank-account test-transaction]]
[auto-ap.integration.util :refer [setup-test-data test-client test-bank-account test-transaction test-payment test-invoice]]
[auto-ap.routes.transactions :as route]
[auto-ap.ssr.transaction.edit :as edit]
[auto-ap.ssr.components.multi-modal :as mm]
@@ -117,7 +117,39 @@
:transaction/bank-account "bank-account-id"
:transaction/amount 300.0
:transaction/description-original "Third transaction"
:transaction/approval-status :transaction-approval-status/unapproved)])
:transaction/approval-status :transaction-approval-status/unapproved)
;; Transaction and payment for link testing
(test-transaction :db/id "transaction-id-payment"
:transaction/client "client-id"
:transaction/bank-account "bank-account-id"
:transaction/amount -100.0
:transaction/description-original "Transaction for payment link"
:transaction/approval-status :transaction-approval-status/unapproved)
(test-payment :db/id "payment-id"
:payment/client "client-id"
:payment/vendor "vendor-id"
:payment/bank-account "bank-account-id"
:payment/amount 100.0
:payment/status :payment-status/pending
:payment/date #inst "2023-06-15")
;; Transaction and unpaid invoice for link testing
(test-transaction :db/id "transaction-id-unpaid"
:transaction/client "client-id"
:transaction/bank-account "bank-account-id"
:transaction/amount -150.0
:transaction/description-original "Transaction for unpaid invoice link"
:transaction/approval-status :transaction-approval-status/unapproved)
(test-invoice :db/id "invoice-unpaid-id"
:invoice/client "client-id"
:invoice/vendor "vendor-id"
:invoice/total 150.0
:invoice/outstanding-balance 150.0
:invoice/status :invoice-status/unpaid
:invoice/date #inst "2023-07-20"
:invoice/invoice-number "UNPAID-001"
:invoice/expense-accounts [{:invoice-expense-account/account "account-id"
:invoice-expense-account/amount 150.0
:invoice-expense-account/location "DT"}])])
tempids (:tempids tx-result)
tx-entity-id (get tempids "transaction-id")]
(println "Test transaction entity ID:" tx-entity-id)