@zeniai/client-epic-state 5.2.84 → 5.2.85-beta1KB

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  2. package/lib/entity/snackbar/snackbarTypes.js +1 -0
  3. package/lib/entity/transaction/stateTypes/paymentType.d.ts +2 -2
  4. package/lib/entity/transaction/stateTypes/paymentType.js +9 -1
  5. package/lib/entity/transaction/stateTypes/printStatus.d.ts +4 -0
  6. package/lib/entity/transaction/stateTypes/printStatus.js +11 -0
  7. package/lib/epic.d.ts +5 -1
  8. package/lib/epic.js +8 -0
  9. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
  10. package/lib/esm/entity/transaction/stateTypes/paymentType.js +9 -1
  11. package/lib/esm/entity/transaction/stateTypes/printStatus.js +7 -0
  12. package/lib/esm/epic.js +8 -0
  13. package/lib/esm/index.js +5 -2
  14. package/lib/esm/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.js +157 -0
  15. package/lib/esm/view/transactionDetail/createTransaction/createTransactionPayload.js +162 -0
  16. package/lib/esm/view/transactionDetail/createTransaction/createTransactionSelector.js +47 -0
  17. package/lib/esm/view/transactionDetail/createTransaction/createTransactionState.js +11 -0
  18. package/lib/esm/view/transactionDetail/createTransaction/epics/createTransactionAttachmentUploadFailureEpic.js +19 -0
  19. package/lib/esm/view/transactionDetail/createTransaction/epics/createTransactionEpic.js +81 -0
  20. package/lib/esm/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.js +53 -0
  21. package/lib/esm/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.js +14 -0
  22. package/lib/esm/view/transactionDetail/transactionDetailReducer.js +196 -1
  23. package/lib/index.d.ts +6 -2
  24. package/lib/index.js +58 -37
  25. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  26. package/lib/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.d.ts +56 -0
  27. package/lib/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.js +172 -0
  28. package/lib/view/transactionDetail/createTransaction/createTransactionPayload.d.ts +95 -0
  29. package/lib/view/transactionDetail/createTransaction/createTransactionPayload.js +167 -0
  30. package/lib/view/transactionDetail/createTransaction/createTransactionSelector.d.ts +44 -0
  31. package/lib/view/transactionDetail/createTransaction/createTransactionSelector.js +53 -0
  32. package/lib/view/transactionDetail/createTransaction/createTransactionState.d.ts +82 -0
  33. package/lib/view/transactionDetail/createTransaction/createTransactionState.js +14 -0
  34. package/lib/view/transactionDetail/createTransaction/epics/createTransactionAttachmentUploadFailureEpic.d.ts +10 -0
  35. package/lib/view/transactionDetail/createTransaction/epics/createTransactionAttachmentUploadFailureEpic.js +23 -0
  36. package/lib/view/transactionDetail/createTransaction/epics/createTransactionEpic.d.ts +9 -0
  37. package/lib/view/transactionDetail/createTransaction/epics/createTransactionEpic.js +85 -0
  38. package/lib/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.d.ts +20 -0
  39. package/lib/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.js +57 -0
  40. package/lib/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.d.ts +12 -0
  41. package/lib/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.js +18 -0
  42. package/lib/view/transactionDetail/transactionDetailReducer.d.ts +39 -1
  43. package/lib/view/transactionDetail/transactionDetailReducer.js +198 -2
  44. package/lib/view/transactionDetail/transactionDetailState.d.ts +12 -0
  45. package/package.json +1 -1
@@ -39,7 +39,7 @@ export declare const getLineItemsByTransactionsIdsFromResponse: (transactions: S
39
39
  export declare const getLineItemsByTransactionIdsFromLocalData: (transactionLocalData: TransactionReviewLocalDataSelectorView[], selectedTab: TransactionsTab) => Record<ID, string[]>;
40
40
  export declare const mergeTabSpecificLineItems: (currentTabSpecificLineItems: TabSpecificLineItems, selectedTab: TransactionsTab, newLineItems: TabSpecificLineItems) => TabSpecificLineItems;
41
41
  export declare const getSnackbarMessageForTransactionReview: (updatedCount: number, failedCount: number, categorizedCount: number) => {
42
- messageSection: "common" | "recommendation_feedback" | "transactionDetails_updatingPastTransactions" | "transactionDetails_transactionUpdated" | "cockpit_month_end_email_sent" | "cockpit_month_end_email_save" | "cockpit_month_end_email_attachment_upload" | "je_bill_link" | "je_posted" | "actual_matching_match_and_reverse" | "actual_matching_undo_reversal" | "actual_matching_ignore_suggestion" | "audit_score_updated" | "people_invite_people" | "people_invite_multiple_people" | "people_delete_person" | "people_update_person" | "reimbursement_updated" | "reimbursement_deleted" | "reimbursement_cancelled_deleted" | "reimbursement_cancelled" | "reimbursement_approved" | "reimbursement_rejected" | "reimbursement_sent_for_approval" | "account_added" | "business_verification_save" | "business_verification_submit" | "business_verification_from_bills_submit" | "plaid_connection" | "unlink_deposit_account" | "reimbursement_setup" | "reimbursement_approval_create" | "reimbursement_duplicate_approval_create" | "reimbursement_approval_update" | "reimbursement_duplicate_approval_update" | "reimbursement_approval_delete" | "reimbursement_approval_reorder" | "reimbursement_create_mileage" | "reimbursement_update_mileage" | "reimbursement_accept_term" | "reimbursement_accept_employee_term" | "reimbursement_bulk_submit" | "reimbursement_bulk_processed" | "bill_pay_setup" | "zeni_accounts_setup" | "bill_pay_approval_create" | "bill_pay_duplicate_approval_create" | "bill_pay_approval_update" | "bill_pay_duplicate_approval_update" | "bill_pay_approval_delete" | "bill_pay_approval_reorder" | "bill_pay_updated" | "bill_pay_deleted" | "bill_pay_cancelled_deleted" | "bill_pay_cancelled" | "bill_pay_approved" | "real_time_approver_added" | "bill_pay_rejected" | "bill_pay_sent_for_approval" | "bill_pay_accept_term" | "bill_pay_bulk_submit" | "bill_pay_bulk_processed" | "bill_pay_refund" | "bill_pay_retry" | "bill_pay_marked_as_paid" | "zeni_account_accept_term" | "update_vendor" | "data_refresh_update" | "delete_bank_account" | "create_bank_account" | "create_bank_account_ach" | "create_bank_account_wire" | "create_bank_account_international" | "transfer_money" | "update_zeni_account_nickname" | "create_checking_account" | "deposit_check" | "create_vendor" | "onboarding_customer_view" | "onboarding_customer_view_complete" | "onboarding_customer_identity_verification_save" | "onboarding_customer_identity_verification_submit" | "onboarding_customer_business_verification_save" | "onboarding_customer_business_verification_submit" | "retry_bank_account_connection" | "dashboard_invite_sent" | "onboarding_info_saved" | "approve_original_merchant" | "approve_global_merchant" | "reject_global_merchant" | "create_global_merchant" | "fetch_global_merchant_no_recommendation" | "save_vendor_renamed" | "save_vendor_sent_for_review" | "save_vendor_marked_as_employee" | "save_vendor_marked_as_local_contractor" | "charge_card_setup" | "charge_card_accept_term" | "charge_card_receipt_upload" | "charge_card_resend_invite" | "charge_card_revoke_invite" | "card_policy_created" | "card_policy_updated" | "card_policy_deleted" | "charge_card_update_limit" | "charge_cards_update_limit" | "close_charge_card" | "lock_charge_card" | "lock_charge_card_card_user" | "lock_charge_cards" | "unlock_charge_card" | "unlock_charge_card_card_user" | "unlock_charge_cards" | "close_charge_cards" | "revoke_invite_charge_cards" | "charge_card_express_interest" | "create_schedule" | "save_schedule" | "delete_schedule" | "ignore_schedule" | "revert_schedule" | "ignore_accrual" | "revert_accrual" | "save_task_detail" | "fetch_task_detail" | "delete_task" | "archive_task" | "snooze_task" | "unsnooze_task" | "create_tag" | "delete_tag" | "update_charge_card" | "update_charge_card_name" | "update_charge_card_name_card_user" | "issue_charge_card" | "issue_charge_cards" | "notification_settings_saved" | "referral_invite_sent" | "notification_mark_as_read" | "mark_as_complete_schedule" | "cancel_journal_entry" | "settings_accounting_accounts_updated" | "create_card_setup" | "confirm_card_setup" | "add_card_payment_source" | "fetch_payment_sources" | "task_assigned_toast_notification" | "task_due_tomorrow_toast_notification" | "task_deleted_toast_notification" | "task_archived_toast_notification" | "task_overdue_toast_notification" | "task_overdue_toast_notification_creator" | "task_notification_count" | "task_activities_toast_notification" | "task_created_toast_notification" | "task_group_creation_success" | "task_group_deletion_success" | "task_group_update_success" | "primary_funding_account_updated" | "task_time_spent_validation" | "missing_receipts_attachment" | "flux_analysis_unreviewed" | "flux_analysis_reviewed" | "receipt_match" | "receipts_upload" | "receipts_bulk_match" | "billing_address_view" | "express_pay_submit" | "exclude_transaction" | "reconcile" | "save_reconcile_for_later" | "recon_transaction_categorize" | "recon_transaction_match" | "update_debit_card_pin_attempt" | "set_debit_card_pin" | "ai_cfo_create_session_and_submit" | "ai_cfo_chat_session_deleted" | "charge_card_auto_pay_enable" | "charge_card_auto_pay_disable" | "treasury_setup" | "treasury_accept_term" | "treasury_transfer_money" | "treasury_transfer_money_failed" | "auto_transfer_rule_create" | "auto_transfer_rule_update" | "auto_transfer_rule_delete" | "auto_transfer_rule_pause" | "auto_transfer_rule_resume" | "treasury_update_portfolio_allocation" | "send_email_magic_link_to_user" | "complete_profile_done" | "create_transfer_entry" | "reports_resync" | "invalid_phone_number" | "transactions_categorized_updated_failed" | "transaction_categorized_updated_failed" | "transactionsCategorized_transactionsUpdated" | "transactionsCategorized_transactionUpdated" | "transactionCategorized_transactionsUpdated" | "transactionCategorized_transactionUpdated" | "transactionsCategorized_transactionsFailed" | "transactionsCategorized_transactionFailed" | "transactionCategorized_transactionsFailed" | "transactionCategorized_transactionFailed" | "transactionsUpdated_transactionsFailed" | "transactionsUpdated_transactionFailed" | "transactionUpdated_transactionsFailed" | "transactionUpdated_transactionFailed" | "transactionsCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionsUpdated_transactionFailed" | "transactionsCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionUpdated_transactionFailed" | "transactionCategorized_transactionsUpdated_transactionFailed" | "transactionCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionUpdated_transactionFailed" | "accounting_classes_enabled_update" | "accounting_projects_enabled_update" | "accounting_projects_qbo_not_enabled" | "capitalization_threshold_update" | "account_excluded_from_reconciliation" | "account_included_in_reconciliation" | "confirm_statement_mapping" | "statement_parsing_in_progress" | "statement_parsing_complete" | "ai_accountant_trigger_job" | "oauth_consent_approve" | "oauth_consent_invalid_request" | "credit_agent_update_profile" | "credit_agent_save_macro" | "credit_agent_schedule_cron" | "create_sub_task" | "qbo_connection_already_linked" | "qbo_connection_failed" | "accounting_projects_qbo_reconnect_failed" | "product_services_update" | "qbo_realm_id_update" | "kyc_kyb_reset" | "invoicing_dunning_case_resolved" | "invoicing_dunning_retry" | "invoicing_dunning_cancel" | "invoicing_dunning_settings_save" | "invoicing_qbo_backfill" | "invoicing_qbo_sync_health_retry" | "invoicing_qbo_settings_save" | "invoicing_branding_save" | "invoicing_discount_archive" | "invoicing_discount_unarchive" | "invoicing_discount_delete" | "invoicing_invoice_reminder_sent" | "invoicing_invoice_regenerated" | "invoicing_invoice_voided" | "invoicing_catalog_item_saved" | "invoicing_customer_saved" | "invoicing_subscription_saved" | "invoicing_coupon_saved" | "invoicing_invoice_saved" | "invoicing_credit_note_saved" | "invoicing_payment_recorded" | "invoicing_subscription_activated" | "invoicing_subscription_cancellation_removed" | "invoicing_subscription_cancelled" | "invoicing_subscription_non_renewing" | "invoicing_subscription_paused" | "invoicing_subscription_reactivated" | "invoicing_subscription_resumed" | "invoicing_subscription_term_end_changed" | "invoicing_data_import_download";
42
+ messageSection: "common" | "recommendation_feedback" | "transactionDetails_updatingPastTransactions" | "transactionDetails_transactionUpdated" | "cockpit_month_end_email_sent" | "cockpit_month_end_email_save" | "cockpit_month_end_email_attachment_upload" | "je_bill_link" | "je_posted" | "actual_matching_match_and_reverse" | "actual_matching_undo_reversal" | "actual_matching_ignore_suggestion" | "audit_score_updated" | "people_invite_people" | "people_invite_multiple_people" | "people_delete_person" | "people_update_person" | "reimbursement_updated" | "reimbursement_deleted" | "reimbursement_cancelled_deleted" | "reimbursement_cancelled" | "reimbursement_approved" | "reimbursement_rejected" | "reimbursement_sent_for_approval" | "account_added" | "business_verification_save" | "business_verification_submit" | "business_verification_from_bills_submit" | "plaid_connection" | "unlink_deposit_account" | "reimbursement_setup" | "reimbursement_approval_create" | "reimbursement_duplicate_approval_create" | "reimbursement_approval_update" | "reimbursement_duplicate_approval_update" | "reimbursement_approval_delete" | "reimbursement_approval_reorder" | "reimbursement_create_mileage" | "reimbursement_update_mileage" | "reimbursement_accept_term" | "reimbursement_accept_employee_term" | "reimbursement_bulk_submit" | "reimbursement_bulk_processed" | "bill_pay_setup" | "zeni_accounts_setup" | "bill_pay_approval_create" | "bill_pay_duplicate_approval_create" | "bill_pay_approval_update" | "bill_pay_duplicate_approval_update" | "bill_pay_approval_delete" | "bill_pay_approval_reorder" | "bill_pay_updated" | "bill_pay_deleted" | "bill_pay_cancelled_deleted" | "bill_pay_cancelled" | "bill_pay_approved" | "real_time_approver_added" | "bill_pay_rejected" | "bill_pay_sent_for_approval" | "bill_pay_accept_term" | "bill_pay_bulk_submit" | "bill_pay_bulk_processed" | "bill_pay_refund" | "bill_pay_retry" | "bill_pay_marked_as_paid" | "zeni_account_accept_term" | "update_vendor" | "data_refresh_update" | "delete_bank_account" | "create_bank_account" | "create_bank_account_ach" | "create_bank_account_wire" | "create_bank_account_international" | "transfer_money" | "update_zeni_account_nickname" | "create_checking_account" | "deposit_check" | "create_vendor" | "onboarding_customer_view" | "onboarding_customer_view_complete" | "onboarding_customer_identity_verification_save" | "onboarding_customer_identity_verification_submit" | "onboarding_customer_business_verification_save" | "onboarding_customer_business_verification_submit" | "retry_bank_account_connection" | "dashboard_invite_sent" | "onboarding_info_saved" | "approve_original_merchant" | "approve_global_merchant" | "reject_global_merchant" | "create_global_merchant" | "fetch_global_merchant_no_recommendation" | "save_vendor_renamed" | "save_vendor_sent_for_review" | "save_vendor_marked_as_employee" | "save_vendor_marked_as_local_contractor" | "charge_card_setup" | "charge_card_accept_term" | "charge_card_receipt_upload" | "charge_card_resend_invite" | "charge_card_revoke_invite" | "card_policy_created" | "card_policy_updated" | "card_policy_deleted" | "charge_card_update_limit" | "charge_cards_update_limit" | "close_charge_card" | "lock_charge_card" | "lock_charge_card_card_user" | "lock_charge_cards" | "unlock_charge_card" | "unlock_charge_card_card_user" | "unlock_charge_cards" | "close_charge_cards" | "revoke_invite_charge_cards" | "charge_card_express_interest" | "create_schedule" | "save_schedule" | "delete_schedule" | "ignore_schedule" | "revert_schedule" | "ignore_accrual" | "revert_accrual" | "save_task_detail" | "fetch_task_detail" | "delete_task" | "archive_task" | "snooze_task" | "unsnooze_task" | "create_tag" | "delete_tag" | "update_charge_card" | "update_charge_card_name" | "update_charge_card_name_card_user" | "issue_charge_card" | "issue_charge_cards" | "notification_settings_saved" | "referral_invite_sent" | "notification_mark_as_read" | "mark_as_complete_schedule" | "cancel_journal_entry" | "settings_accounting_accounts_updated" | "create_card_setup" | "confirm_card_setup" | "add_card_payment_source" | "fetch_payment_sources" | "task_assigned_toast_notification" | "task_due_tomorrow_toast_notification" | "task_deleted_toast_notification" | "task_archived_toast_notification" | "task_overdue_toast_notification" | "task_overdue_toast_notification_creator" | "task_notification_count" | "task_activities_toast_notification" | "task_created_toast_notification" | "task_group_creation_success" | "task_group_deletion_success" | "task_group_update_success" | "primary_funding_account_updated" | "task_time_spent_validation" | "missing_receipts_attachment" | "flux_analysis_unreviewed" | "flux_analysis_reviewed" | "receipt_match" | "receipts_upload" | "receipts_bulk_match" | "billing_address_view" | "express_pay_submit" | "exclude_transaction" | "reconcile" | "save_reconcile_for_later" | "recon_transaction_categorize" | "recon_transaction_match" | "update_debit_card_pin_attempt" | "set_debit_card_pin" | "ai_cfo_create_session_and_submit" | "ai_cfo_chat_session_deleted" | "charge_card_auto_pay_enable" | "charge_card_auto_pay_disable" | "treasury_setup" | "treasury_accept_term" | "treasury_transfer_money" | "treasury_transfer_money_failed" | "auto_transfer_rule_create" | "auto_transfer_rule_update" | "auto_transfer_rule_delete" | "auto_transfer_rule_pause" | "auto_transfer_rule_resume" | "treasury_update_portfolio_allocation" | "send_email_magic_link_to_user" | "complete_profile_done" | "create_transfer_entry" | "create_transaction" | "reports_resync" | "invalid_phone_number" | "transactions_categorized_updated_failed" | "transaction_categorized_updated_failed" | "transactionsCategorized_transactionsUpdated" | "transactionsCategorized_transactionUpdated" | "transactionCategorized_transactionsUpdated" | "transactionCategorized_transactionUpdated" | "transactionsCategorized_transactionsFailed" | "transactionsCategorized_transactionFailed" | "transactionCategorized_transactionsFailed" | "transactionCategorized_transactionFailed" | "transactionsUpdated_transactionsFailed" | "transactionsUpdated_transactionFailed" | "transactionUpdated_transactionsFailed" | "transactionUpdated_transactionFailed" | "transactionsCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionsUpdated_transactionFailed" | "transactionsCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionUpdated_transactionFailed" | "transactionCategorized_transactionsUpdated_transactionFailed" | "transactionCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionUpdated_transactionFailed" | "accounting_classes_enabled_update" | "accounting_projects_enabled_update" | "accounting_projects_qbo_not_enabled" | "capitalization_threshold_update" | "account_excluded_from_reconciliation" | "account_included_in_reconciliation" | "confirm_statement_mapping" | "statement_parsing_in_progress" | "statement_parsing_complete" | "ai_accountant_trigger_job" | "oauth_consent_approve" | "oauth_consent_invalid_request" | "credit_agent_update_profile" | "credit_agent_save_macro" | "credit_agent_schedule_cron" | "create_sub_task" | "qbo_connection_already_linked" | "qbo_connection_failed" | "accounting_projects_qbo_reconnect_failed" | "product_services_update" | "qbo_realm_id_update" | "kyc_kyb_reset" | "invoicing_dunning_case_resolved" | "invoicing_dunning_retry" | "invoicing_dunning_cancel" | "invoicing_dunning_settings_save" | "invoicing_qbo_backfill" | "invoicing_qbo_sync_health_retry" | "invoicing_qbo_settings_save" | "invoicing_branding_save" | "invoicing_discount_archive" | "invoicing_discount_unarchive" | "invoicing_discount_delete" | "invoicing_invoice_reminder_sent" | "invoicing_invoice_regenerated" | "invoicing_invoice_voided" | "invoicing_catalog_item_saved" | "invoicing_customer_saved" | "invoicing_subscription_saved" | "invoicing_coupon_saved" | "invoicing_invoice_saved" | "invoicing_credit_note_saved" | "invoicing_payment_recorded" | "invoicing_subscription_activated" | "invoicing_subscription_cancellation_removed" | "invoicing_subscription_cancelled" | "invoicing_subscription_non_renewing" | "invoicing_subscription_paused" | "invoicing_subscription_reactivated" | "invoicing_subscription_resumed" | "invoicing_subscription_term_end_changed" | "invoicing_data_import_download";
43
43
  messageText: "notification" | "failed" | "success";
44
44
  type: "error" | "success" | "info";
45
45
  variables: {
@@ -0,0 +1,56 @@
1
+ import { Recommendation, RecommendationWithCOT } from '../../../commonStateTypes/recommendationBase';
2
+ import { TransactionCategory } from '../../../entity/transaction/stateTypes/transactionType';
3
+ import { CreatableTransactionType, CreateTransactionLineLocalData, CreateTransactionLocalData, CreateTransactionLocalDataByType } from './createTransactionState';
4
+ export declare const nextCreateTransactionLineId: () => string;
5
+ /** Test-only: makes line ids predictable from the start of each case. */
6
+ export declare const resetCreateTransactionLineIdCounter: () => void;
7
+ export declare const createEmptyCreateTransactionLine: (postingType?: TransactionCategory) => CreateTransactionLineLocalData;
8
+ /**
9
+ * The lines a freshly-opened form starts with. A journal entry is invalid with fewer than one
10
+ * debit and one credit, so it opens with both rather than making the user add the second row.
11
+ * Transfer has no lines at all.
12
+ */
13
+ export declare const getDefaultCreateTransactionLines: (transactionType: CreatableTransactionType) => CreateTransactionLineLocalData[];
14
+ /**
15
+ * A blank working copy for one type. Note this does NOT seed the date -- the reducer's initial
16
+ * state has to stay a pure constant so `clearAll` restores something stable. The date is seeded
17
+ * by initializeCreateTransactionLocalDataEpic, which runs when the form opens.
18
+ */
19
+ export declare const getEmptyCreateTransactionLocalData: (transactionType: CreatableTransactionType) => CreateTransactionLocalData;
20
+ export declare const getInitialCreateTransactionLocalDataByType: () => CreateTransactionLocalDataByType;
21
+ /**
22
+ * What the form opens with: a blank copy plus today's date, the default line set, and the
23
+ * payment_type the backend insists on for the type.
24
+ */
25
+ export declare const getSeededCreateTransactionLocalData: (transactionType: CreatableTransactionType) => CreateTransactionLocalData;
26
+ /**
27
+ * Merges a partial edit into the working copy. Lines are replaced wholesale when present --
28
+ * a partial line array would silently truncate the form.
29
+ */
30
+ export declare const mergeCreateTransactionLocalData: (current: CreateTransactionLocalData, update: Partial<CreateTransactionLocalData>) => CreateTransactionLocalData;
31
+ /**
32
+ * A user edit to a prefilled account or class makes it theirs, so its flag is dropped and a
33
+ * later vendor switch no longer clears it.
34
+ */
35
+ export declare const updateCreateTransactionLine: (lines: CreateTransactionLineLocalData[], lineId: string, update: Partial<CreateTransactionLineLocalData>) => CreateTransactionLineLocalData[];
36
+ /**
37
+ * Recommendation -> RecommendationWithCOT. Chain-of-thought and recommendation feedback both
38
+ * need an existing transaction, so cot/reasoning are empty here by design; the dropdown only
39
+ * needs the entities to build its "Recommended" group.
40
+ */
41
+ export declare const toRecommendationsWithCOT: (recommendations: Recommendation[]) => RecommendationWithCOT[];
42
+ /**
43
+ * Applies a vendor's recommendations to one line: always refreshes the dropdown's "Recommended"
44
+ * group, but only prefills account/class when the field is still empty. Callers switching
45
+ * vendors clear the previous prefill first, so "empty" includes what the last vendor filled. Anything the user
46
+ * picked wins -- this follows the transaction-categorization helper, which prefills, rather
47
+ * than the detail-page helper, which only suggests.
48
+ */
49
+ export declare const applyRecommendationsToCreateTransactionLine: (line: CreateTransactionLineLocalData, recommendations: Recommendation[], isAccountingClassesEnabled: boolean) => CreateTransactionLineLocalData;
50
+ /**
51
+ * Undoes a prefill when the vendor is cleared. Only the fields the prefill wrote are removed --
52
+ * the per-field flags are what make the user's own choices distinguishable from ours, which is
53
+ * why they are not a single line-level boolean: a hand-picked account alongside a prefilled
54
+ * class is an ordinary state, and clearing must not take the account with it.
55
+ */
56
+ export declare const clearRecommendationsFromCreateTransactionLine: (line: CreateTransactionLineLocalData) => CreateTransactionLineLocalData;
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clearRecommendationsFromCreateTransactionLine = exports.applyRecommendationsToCreateTransactionLine = exports.toRecommendationsWithCOT = exports.updateCreateTransactionLine = exports.mergeCreateTransactionLocalData = exports.getSeededCreateTransactionLocalData = exports.getInitialCreateTransactionLocalDataByType = exports.getEmptyCreateTransactionLocalData = exports.getDefaultCreateTransactionLines = exports.createEmptyCreateTransactionLine = exports.resetCreateTransactionLineIdCounter = exports.nextCreateTransactionLineId = void 0;
4
+ const zeniDayJS_1 = require("../../../zeniDayJS");
5
+ const createTransactionState_1 = require("./createTransactionState");
6
+ /**
7
+ * Monotonic counter for line row keys. These never leave the client -- the payload builder
8
+ * drops them -- so a counter is enough, and it keeps reducer tests deterministic in a way
9
+ * randomUUID would not.
10
+ */
11
+ let lineIdCounter = 0;
12
+ const nextCreateTransactionLineId = () => `create-transaction-line-${lineIdCounter++}`;
13
+ exports.nextCreateTransactionLineId = nextCreateTransactionLineId;
14
+ /** Test-only: makes line ids predictable from the start of each case. */
15
+ const resetCreateTransactionLineIdCounter = () => {
16
+ lineIdCounter = 0;
17
+ };
18
+ exports.resetCreateTransactionLineIdCounter = resetCreateTransactionLineIdCounter;
19
+ const createEmptyCreateTransactionLine = (postingType) => ({
20
+ id: (0, exports.nextCreateTransactionLineId)(),
21
+ postingType,
22
+ });
23
+ exports.createEmptyCreateTransactionLine = createEmptyCreateTransactionLine;
24
+ /**
25
+ * The lines a freshly-opened form starts with. A journal entry is invalid with fewer than one
26
+ * debit and one credit, so it opens with both rather than making the user add the second row.
27
+ * Transfer has no lines at all.
28
+ */
29
+ const getDefaultCreateTransactionLines = (transactionType) => {
30
+ if (transactionType === 'transfer') {
31
+ return [];
32
+ }
33
+ if (transactionType === 'journal_entry') {
34
+ return [
35
+ (0, exports.createEmptyCreateTransactionLine)('debit'),
36
+ (0, exports.createEmptyCreateTransactionLine)('credit'),
37
+ ];
38
+ }
39
+ return [(0, exports.createEmptyCreateTransactionLine)()];
40
+ };
41
+ exports.getDefaultCreateTransactionLines = getDefaultCreateTransactionLines;
42
+ /**
43
+ * A blank working copy for one type. Note this does NOT seed the date -- the reducer's initial
44
+ * state has to stay a pure constant so `clearAll` restores something stable. The date is seeded
45
+ * by initializeCreateTransactionLocalDataEpic, which runs when the form opens.
46
+ */
47
+ const getEmptyCreateTransactionLocalData = (transactionType) => ({
48
+ lines: [],
49
+ transactionType,
50
+ });
51
+ exports.getEmptyCreateTransactionLocalData = getEmptyCreateTransactionLocalData;
52
+ const getInitialCreateTransactionLocalDataByType = () => createTransactionState_1.ALL_CREATABLE_TRANSACTION_TYPES.reduce((acc, transactionType) => {
53
+ acc[transactionType] =
54
+ (0, exports.getEmptyCreateTransactionLocalData)(transactionType);
55
+ return acc;
56
+ }, {});
57
+ exports.getInitialCreateTransactionLocalDataByType = getInitialCreateTransactionLocalDataByType;
58
+ /**
59
+ * The payment_type the backend insists on for some types: a check needs `check`, and a
60
+ * credit_card_credit (sent as expense + is_credit) needs a card type -- qbo_purchase.py raises
61
+ * without them.
62
+ */
63
+ const SEEDED_PAYMENT_TYPE = {
64
+ check: 'check',
65
+ credit_card_credit: 'credit_card',
66
+ };
67
+ /**
68
+ * What the form opens with: a blank copy plus today's date, the default line set, and the
69
+ * payment_type the backend insists on for the type.
70
+ */
71
+ const getSeededCreateTransactionLocalData = (transactionType) => ({
72
+ ...(0, exports.getEmptyCreateTransactionLocalData)(transactionType),
73
+ lines: (0, exports.getDefaultCreateTransactionLines)(transactionType),
74
+ paymentType: SEEDED_PAYMENT_TYPE[transactionType],
75
+ transactionDate: (0, zeniDayJS_1.dateNow)(),
76
+ });
77
+ exports.getSeededCreateTransactionLocalData = getSeededCreateTransactionLocalData;
78
+ /**
79
+ * Merges a partial edit into the working copy. Lines are replaced wholesale when present --
80
+ * a partial line array would silently truncate the form.
81
+ */
82
+ const mergeCreateTransactionLocalData = (current, update) => ({
83
+ ...current,
84
+ ...update,
85
+ lines: update.lines ?? current.lines,
86
+ // The type is keyed by the slice, never edited through a merge.
87
+ transactionType: current.transactionType,
88
+ });
89
+ exports.mergeCreateTransactionLocalData = mergeCreateTransactionLocalData;
90
+ /**
91
+ * A user edit to a prefilled account or class makes it theirs, so its flag is dropped and a
92
+ * later vendor switch no longer clears it.
93
+ */
94
+ const updateCreateTransactionLine = (lines, lineId, update) => lines.map((line) => line.id === lineId
95
+ ? {
96
+ ...line,
97
+ ...update,
98
+ id: line.id,
99
+ isAccountPreFilled: 'accountQboId' in update ? undefined : line.isAccountPreFilled,
100
+ isClassPreFilled: 'classId' in update ? undefined : line.isClassPreFilled,
101
+ }
102
+ : line);
103
+ exports.updateCreateTransactionLine = updateCreateTransactionLine;
104
+ /**
105
+ * Recommendation -> RecommendationWithCOT. Chain-of-thought and recommendation feedback both
106
+ * need an existing transaction, so cot/reasoning are empty here by design; the dropdown only
107
+ * needs the entities to build its "Recommended" group.
108
+ */
109
+ const toRecommendationsWithCOT = (recommendations) => recommendations.map((recommendation) => ({
110
+ account: recommendation.account != null
111
+ ? { ...recommendation.account, cot: [], reasoning: '' }
112
+ : undefined,
113
+ class: recommendation.class != null
114
+ ? { ...recommendation.class, cot: [], reasoning: '' }
115
+ : undefined,
116
+ vendor: recommendation.vendor != null
117
+ ? { ...recommendation.vendor, cot: [], reasoning: '' }
118
+ : undefined,
119
+ }));
120
+ exports.toRecommendationsWithCOT = toRecommendationsWithCOT;
121
+ /**
122
+ * Applies a vendor's recommendations to one line: always refreshes the dropdown's "Recommended"
123
+ * group, but only prefills account/class when the field is still empty. Callers switching
124
+ * vendors clear the previous prefill first, so "empty" includes what the last vendor filled. Anything the user
125
+ * picked wins -- this follows the transaction-categorization helper, which prefills, rather
126
+ * than the detail-page helper, which only suggests.
127
+ */
128
+ const applyRecommendationsToCreateTransactionLine = (line, recommendations, isAccountingClassesEnabled) => {
129
+ const top = recommendations[0];
130
+ const updated = {
131
+ ...line,
132
+ recommendationsWithCOT: (0, exports.toRecommendationsWithCOT)(recommendations),
133
+ };
134
+ if (line.accountQboId == null && top?.account?.qboId != null) {
135
+ updated.accountQboId = top.account.qboId;
136
+ updated.accountName = top.account.accountName;
137
+ updated.isAccountPreFilled = true;
138
+ }
139
+ if (isAccountingClassesEnabled &&
140
+ line.classId == null &&
141
+ top?.class?.classId != null) {
142
+ updated.classId = top.class.classId;
143
+ updated.className = top.class.className;
144
+ updated.isClassPreFilled = true;
145
+ }
146
+ return updated;
147
+ };
148
+ exports.applyRecommendationsToCreateTransactionLine = applyRecommendationsToCreateTransactionLine;
149
+ /**
150
+ * Undoes a prefill when the vendor is cleared. Only the fields the prefill wrote are removed --
151
+ * the per-field flags are what make the user's own choices distinguishable from ours, which is
152
+ * why they are not a single line-level boolean: a hand-picked account alongside a prefilled
153
+ * class is an ordinary state, and clearing must not take the account with it.
154
+ */
155
+ const clearRecommendationsFromCreateTransactionLine = (line) => {
156
+ const cleared = {
157
+ ...line,
158
+ recommendationsWithCOT: undefined,
159
+ };
160
+ if (line.isAccountPreFilled === true) {
161
+ cleared.accountQboId = undefined;
162
+ cleared.accountName = undefined;
163
+ cleared.isAccountPreFilled = undefined;
164
+ }
165
+ if (line.isClassPreFilled === true) {
166
+ cleared.classId = undefined;
167
+ cleared.className = undefined;
168
+ cleared.isClassPreFilled = undefined;
169
+ }
170
+ return cleared;
171
+ };
172
+ exports.clearRecommendationsFromCreateTransactionLine = clearRecommendationsFromCreateTransactionLine;
@@ -0,0 +1,95 @@
1
+ import { ID } from '../../../commonStateTypes/common';
2
+ import { ProjectBasePayload } from '../../../entity/project/projectPayload';
3
+ import { TransactionPayload } from '../../../entity/transaction/payloadTypes/transactionPayload';
4
+ import { ZeniAPIResponse } from '../../../responsePayload';
5
+ import { RootState } from '../../../rootStateTypes';
6
+ import { CreateTransactionLocalData } from './createTransactionState';
7
+ /**
8
+ * Wire types for POST /1.0/transactions/manage.
9
+ *
10
+ * Two things here are easy to get wrong and are deliberately explicit:
11
+ *
12
+ * 1. `line_detail_type` is snake_case. The PascalCase strings in the backend are Python
13
+ * constant NAMES; ZENI_LINE_DETAIL_TYPE_TO_QBO_LINE_DETAIL_TYPE_MAP converts them for the
14
+ * body the backend sends on to QuickBooks, never for ours.
15
+ * 2. The reference number uses two different keys depending on the QBO entity. check and
16
+ * expense are Purchases and take `document_number`; everything else takes `document_id`.
17
+ */
18
+ export interface CreateTransactionAccountPayload {
19
+ qbo_id: ID;
20
+ account_name?: string;
21
+ }
22
+ export interface CreateTransactionLineDetailPayload {
23
+ account?: CreateTransactionAccountPayload;
24
+ class?: Record<string, never> | {
25
+ qbo_id: ID;
26
+ };
27
+ /**
28
+ * journal_entry only, and it MUST sit inside line_detail. The write validator's docstring
29
+ * warns that a misplaced posting_type is silently dropped and then rejected by QBO.
30
+ */
31
+ posting_type?: 'credit' | 'debit';
32
+ /** Same shape the transaction update sends on a vendor line. */
33
+ project?: ProjectBasePayload;
34
+ vendor?: {
35
+ qbo_id: ID;
36
+ };
37
+ }
38
+ export interface CreateTransactionLinePayload {
39
+ amount: number;
40
+ line_detail: CreateTransactionLineDetailPayload;
41
+ line_detail_type: 'account_based_expense_line_detail' | 'item_based_expense_line_detail' | 'journal_entry_line_detail';
42
+ line_description?: string;
43
+ }
44
+ export interface CreateTransactionRemitToAddressPayload {
45
+ city?: string;
46
+ country?: string;
47
+ line1?: string;
48
+ postal_code?: string;
49
+ state?: string;
50
+ }
51
+ export interface CreateTransactionRequest extends Record<string, unknown> {
52
+ transaction_date: string;
53
+ transaction_type: string;
54
+ /** journal_entry reference number. */
55
+ document_id?: string;
56
+ /** check / credit_card_credit reference number (QBO Purchase). */
57
+ document_number?: string;
58
+ from_account_id?: ID;
59
+ /** credit_card_credit is modelled as a Purchase with Credit: true. */
60
+ is_credit?: boolean;
61
+ lines?: CreateTransactionLinePayload[];
62
+ payment_type?: string;
63
+ print_status?: string;
64
+ qbo_account_id?: ID;
65
+ remit_to_address?: CreateTransactionRemitToAddressPayload;
66
+ to_account_id?: ID;
67
+ total_amount?: number;
68
+ transaction_memo?: string;
69
+ vendor_id?: ID;
70
+ }
71
+ /**
72
+ * The create endpoint writes to QBO and returns the created entity; Zeni's own mirror is
73
+ * populated by the delta sync that runs afterwards, so this response is the only view of the
74
+ * new transaction the client gets immediately.
75
+ */
76
+ export interface CreateTransactionPayload {
77
+ transactions: TransactionPayload[];
78
+ }
79
+ export type CreateTransactionResponse = ZeniAPIResponse<CreateTransactionPayload>;
80
+ /**
81
+ * Thrown when a picked id has no QBO id to send. Sending the Zeni id instead would reach QBO as
82
+ * an unknown reference and come back as an opaque error, so the create is stopped here and the
83
+ * epic shows this message instead.
84
+ */
85
+ export declare class UnresolvedCreateTransactionIdError extends Error {
86
+ }
87
+ /**
88
+ * Builds the request body for one transaction type. One branch per type rather than a shared
89
+ * body with optional keys, because the types genuinely diverge -- transfer carries no lines at
90
+ * all, and journal_entry carries no header account.
91
+ *
92
+ * Throws UnresolvedCreateTransactionIdError when a picked vendor, class or transfer account has
93
+ * no QBO id.
94
+ */
95
+ export declare const prepareCreateTransactionPayload: (state: RootState, localData: CreateTransactionLocalData) => CreateTransactionRequest;
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareCreateTransactionPayload = exports.UnresolvedCreateTransactionIdError = void 0;
4
+ const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
5
+ const accountSelector_1 = require("../../../entity/account/accountSelector");
6
+ const classSelector_1 = require("../../../entity/class/classSelector");
7
+ const projectPayload_1 = require("../../../entity/project/projectPayload");
8
+ const projectSelector_1 = require("../../../entity/project/projectSelector");
9
+ const vendorSelector_1 = require("../../../entity/vendor/vendorSelector");
10
+ const toRemitToAddressPayload = (address) => {
11
+ if (address == null) {
12
+ return undefined;
13
+ }
14
+ return {
15
+ line1: address.line1,
16
+ city: address.city,
17
+ state: address.state,
18
+ postal_code: address.postalCode,
19
+ country: address.country,
20
+ };
21
+ };
22
+ const toLinePayload = (state, line, transactionType) => {
23
+ const lineDetail = {};
24
+ if (line.accountQboId != null) {
25
+ lineDetail.account = {
26
+ qbo_id: line.accountQboId,
27
+ account_name: line.accountName,
28
+ };
29
+ }
30
+ // An empty object is what the confirmed payloads send when no class is chosen; sending the
31
+ // key with a qbo_id only once one is picked.
32
+ const classQboId = toQboClassId(state, line.classId);
33
+ lineDetail.class = classQboId != null ? { qbo_id: classQboId } : {};
34
+ if (line.projectId != null) {
35
+ lineDetail.project = (0, projectPayload_1.toProjectBasePayload)((0, projectSelector_1.getProjectById)(state.projectState, line.projectId) ?? {
36
+ projectId: line.projectId,
37
+ projectName: '',
38
+ });
39
+ }
40
+ if (transactionType === 'journal_entry') {
41
+ lineDetail.posting_type = line.postingType;
42
+ if (line.vendorQboId != null) {
43
+ lineDetail.vendor = { qbo_id: line.vendorQboId };
44
+ }
45
+ }
46
+ return {
47
+ // The backend rejects a bool here, so this is always coerced to a number.
48
+ amount: line.amount?.amount ?? 0,
49
+ line_description: line.lineDescription,
50
+ line_detail_type: transactionType === 'journal_entry'
51
+ ? 'journal_entry_line_detail'
52
+ : 'account_based_expense_line_detail',
53
+ line_detail: lineDetail,
54
+ };
55
+ };
56
+ /**
57
+ * Thrown when a picked id has no QBO id to send. Sending the Zeni id instead would reach QBO as
58
+ * an unknown reference and come back as an opaque error, so the create is stopped here and the
59
+ * epic shows this message instead.
60
+ */
61
+ class UnresolvedCreateTransactionIdError extends Error {
62
+ }
63
+ exports.UnresolvedCreateTransactionIdError = UnresolvedCreateTransactionIdError;
64
+ /**
65
+ * Resolves a transfer account (the Zeni account id from the transfer pools) to its QBO id. The
66
+ * header and line account dropdowns already hold the QBO id, so they are sent as-is.
67
+ */
68
+ const toQboTransferAccountId = (state, accountId) => {
69
+ if (accountId == null) {
70
+ return undefined;
71
+ }
72
+ const qboId = (0, accountSelector_1.getAccountBaseForTransferAccounts)(state.accountState, accountId)?.qboId;
73
+ if (qboId == null || qboId === '') {
74
+ throw new UnresolvedCreateTransactionIdError('The selected transfer account could not be found in QuickBooks.');
75
+ }
76
+ return qboId;
77
+ };
78
+ /** Resolves a Zeni class id (`class_<uuid>`) to the QBO id `line_detail.class.qbo_id` expects. */
79
+ const toQboClassId = (state, classId) => {
80
+ if (classId == null) {
81
+ return undefined;
82
+ }
83
+ const qboId = (0, classSelector_1.getClassById)(state.classState, {
84
+ classId,
85
+ reportId: 'class_list',
86
+ })?.qboId;
87
+ if (qboId == null || qboId === '') {
88
+ throw new UnresolvedCreateTransactionIdError('The selected class could not be found in QuickBooks.');
89
+ }
90
+ return qboId;
91
+ };
92
+ /**
93
+ * Resolves a Zeni vendor id to its QBO id -- `vendor_id` on the wire is a QBO id. A vendor not
94
+ * yet synced to QBO carries `qboId === name`, which QBO would reject, so it is refused here.
95
+ */
96
+ const toQboVendorId = (state, vendorId) => {
97
+ if (vendorId == null) {
98
+ return undefined;
99
+ }
100
+ const vendor = (0, vendorSelector_1.getVendorByVendorId)(state.vendorState, vendorId);
101
+ if (vendor == null || vendor.qboId === '' || vendor.qboId === vendor.name) {
102
+ throw new UnresolvedCreateTransactionIdError('The selected vendor is not synced to QuickBooks yet.');
103
+ }
104
+ return vendor.qboId;
105
+ };
106
+ /**
107
+ * Builds the request body for one transaction type. One branch per type rather than a shared
108
+ * body with optional keys, because the types genuinely diverge -- transfer carries no lines at
109
+ * all, and journal_entry carries no header account.
110
+ *
111
+ * Throws UnresolvedCreateTransactionIdError when a picked vendor, class or transfer account has
112
+ * no QBO id.
113
+ */
114
+ const prepareCreateTransactionPayload = (state, localData) => {
115
+ const { transactionType } = localData;
116
+ const base = {
117
+ transaction_type: transactionType,
118
+ transaction_date: localData.transactionDate?.format(timePeriod_1.DEFAULT_DATE_FORMAT) ?? '',
119
+ transaction_memo: localData.transactionMemo,
120
+ };
121
+ if (transactionType === 'transfer') {
122
+ return {
123
+ ...base,
124
+ from_account_id: toQboTransferAccountId(state, localData.fromAccountId),
125
+ to_account_id: toQboTransferAccountId(state, localData.toAccountId),
126
+ total_amount: localData.totalAmount?.amount ?? 0,
127
+ };
128
+ }
129
+ const lines = localData.lines.map((line) => toLinePayload(state, line, transactionType));
130
+ if (transactionType === 'journal_entry') {
131
+ return {
132
+ ...base,
133
+ document_id: localData.documentId,
134
+ lines,
135
+ };
136
+ }
137
+ const purchaseBase = {
138
+ ...base,
139
+ payment_type: localData.paymentType,
140
+ qbo_account_id: localData.qboAccountId,
141
+ vendor_id: toQboVendorId(state, localData.vendorId),
142
+ lines,
143
+ };
144
+ if (transactionType === 'check') {
145
+ return {
146
+ ...purchaseBase,
147
+ document_number: localData.documentNumber,
148
+ print_status: localData.printStatus,
149
+ remit_to_address: toRemitToAddressPayload(localData.remitToAddress),
150
+ };
151
+ }
152
+ if (transactionType === 'credit_card_credit') {
153
+ // credit_card_credit is not in the backend's SUPPORTED_TRANSACTION_WRITE_TYPES. QBO models
154
+ // it as a Purchase with Credit: true and qbo_purchase.py already honours is_credit for
155
+ // card payment types, so this sends `expense` + is_credit rather than a type the validator
156
+ // rejects outright. Confirm with backend before enabling the menu item. The seed sets
157
+ // payment_type to credit_card, since qbo_purchase.py raises on is_credit without a card type.
158
+ return {
159
+ ...purchaseBase,
160
+ transaction_type: 'expense',
161
+ is_credit: true,
162
+ document_number: localData.documentNumber,
163
+ };
164
+ }
165
+ return purchaseBase;
166
+ };
167
+ exports.prepareCreateTransactionPayload = prepareCreateTransactionPayload;
@@ -0,0 +1,44 @@
1
+ import { NestedAccountHierarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
2
+ import { NestedClassHierarchyForReport } from '../../../commonStateTypes/classesView/nestedClassID';
3
+ import { FetchState, FetchStateAndError } from '../../../commonStateTypes/common';
4
+ import { Recommendation } from '../../../commonStateTypes/recommendationBase';
5
+ import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
6
+ import { AccountBase } from '../../../entity/account/accountState';
7
+ import { TransactionID } from '../../../entity/transaction/stateTypes/transactionID';
8
+ import { Vendor } from '../../../entity/vendor/vendorState';
9
+ import { RootState } from '../../../rootStateTypes';
10
+ import { CreatableTransactionType, CreateTransactionLocalData } from './createTransactionState';
11
+ export interface CreateTransactionView extends SelectorView {
12
+ /**
13
+ * COA and class trees for the header account and the line dropdowns. The hierarchies rather
14
+ * than flat lists, because the create page builds its grouped "Recommended" / "All" options
15
+ * with the same helpers the detail page uses.
16
+ */
17
+ accountListNestedAccountHierarchy: NestedAccountHierarchyForReport[];
18
+ classListNestedAccountHierarchy: NestedClassHierarchyForReport[];
19
+ createStatus: FetchStateAndError;
20
+ localData: CreateTransactionLocalData;
21
+ transactionType: CreatableTransactionType;
22
+ /** Populated for transfer only; the COA would offer ineligible accounts. */
23
+ transferAccountsList: AccountBase[];
24
+ vendorList: Vendor[];
25
+ createdTransactionId?: TransactionID;
26
+ }
27
+ export declare const getCreateTransactionLocalData: (state: RootState, transactionType: CreatableTransactionType) => CreateTransactionLocalData;
28
+ export declare const getCreateTransactionStatus: (state: RootState) => FetchStateAndError;
29
+ /**
30
+ * The vendor recommendations backing the category/class dropdowns on the create page.
31
+ *
32
+ * No new state field is needed for this: getRecommendationsForEntity already returns
33
+ * fetchState alongside recommendations, so composing it here is enough for the page to show a
34
+ * line skeleton and hold Save while a fetch is in flight.
35
+ */
36
+ export declare const getCreateTransactionVendorRecommendations: (state: RootState, vendorQboId?: string) => {
37
+ fetchState: FetchState;
38
+ recommendations?: Recommendation[];
39
+ };
40
+ /**
41
+ * Memoized: app-ui reads this straight from useSelector, and the vendor list and hierarchies are
42
+ * rebuilt on every call, so an unmemoized version re-renders the page on every store action.
43
+ */
44
+ export declare const getCreateTransactionView: (state: RootState, transactionType: CreatableTransactionType) => CreateTransactionView;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCreateTransactionView = exports.getCreateTransactionVendorRecommendations = exports.getCreateTransactionStatus = exports.getCreateTransactionLocalData = void 0;
4
+ const toolkit_1 = require("@reduxjs/toolkit");
5
+ const accountListSelector_1 = require("../../accountList/accountListSelector");
6
+ const classListSelector_1 = require("../../classList/classListSelector");
7
+ const createTransferEntrySelector_1 = require("../../createTransferEntry/createTransferEntrySelector");
8
+ const recommendationSelector_1 = require("../../recommendation/recommendationSelector");
9
+ const getCreateTransactionLocalData = (state, transactionType) => state.transactionDetailState.createTransactionsState.newTransactionState[transactionType];
10
+ exports.getCreateTransactionLocalData = getCreateTransactionLocalData;
11
+ const getCreateTransactionStatus = (state) => state.transactionDetailState.createTransactionsState.createStatus;
12
+ exports.getCreateTransactionStatus = getCreateTransactionStatus;
13
+ /**
14
+ * The vendor recommendations backing the category/class dropdowns on the create page.
15
+ *
16
+ * No new state field is needed for this: getRecommendationsForEntity already returns
17
+ * fetchState alongside recommendations, so composing it here is enough for the page to show a
18
+ * line skeleton and hold Save while a fetch is in flight.
19
+ */
20
+ const getCreateTransactionVendorRecommendations = (state, vendorQboId) => {
21
+ if (vendorQboId == null || vendorQboId === '') {
22
+ return { fetchState: 'Not-Started' };
23
+ }
24
+ const view = (0, recommendationSelector_1.getRecommendationsForEntity)(state, vendorQboId, 'vendor');
25
+ return {
26
+ fetchState: view.fetchState,
27
+ recommendations: view.recommendations,
28
+ };
29
+ };
30
+ exports.getCreateTransactionVendorRecommendations = getCreateTransactionVendorRecommendations;
31
+ /**
32
+ * Memoized: app-ui reads this straight from useSelector, and the vendor list and hierarchies are
33
+ * rebuilt on every call, so an unmemoized version re-renders the page on every store action.
34
+ */
35
+ exports.getCreateTransactionView = (0, toolkit_1.createSelector)([
36
+ (state) => state.transactionDetailState.createTransactionsState,
37
+ (state) => state.vendorState.vendorByID,
38
+ (state) => state.accountListState,
39
+ (state) => state.classListState,
40
+ (state) => (0, createTransferEntrySelector_1.getResolvedTransferAccounts)(state).transferAccountsList,
41
+ (_state, transactionType) => transactionType,
42
+ ], (createTransactionsState, vendorByID, accountListState, classListState, transferAccountsList, transactionType) => ({
43
+ transactionType,
44
+ localData: createTransactionsState.newTransactionState[transactionType],
45
+ createStatus: createTransactionsState.createStatus,
46
+ createdTransactionId: createTransactionsState.createdTransactionId,
47
+ vendorList: Object.values(vendorByID),
48
+ accountListNestedAccountHierarchy: (0, accountListSelector_1.getNestedAccountListHierarchy)(accountListState, 'accountList'),
49
+ classListNestedAccountHierarchy: (0, classListSelector_1.getNestedClassListHierarchy)(classListState),
50
+ transferAccountsList: transactionType === 'transfer' ? transferAccountsList : [],
51
+ fetchState: createTransactionsState.createStatus.fetchState,
52
+ error: createTransactionsState.createStatus.error,
53
+ }));