@zeniai/client-epic-state 5.2.91 → 5.2.93-betaNB1
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.
- package/lib/entity/reconciliationReport/reconciliationReportState.d.ts +3 -2
- package/lib/entity/reconciliationReport/reconciliationReportState.js +4 -1
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +1 -0
- package/lib/entity/transaction/stateTypes/paymentType.d.ts +2 -2
- package/lib/entity/transaction/stateTypes/paymentType.js +9 -1
- package/lib/entity/transaction/stateTypes/printStatus.d.ts +4 -0
- package/lib/entity/transaction/stateTypes/printStatus.js +11 -0
- package/lib/epic.d.ts +5 -1
- package/lib/epic.js +8 -0
- package/lib/esm/entity/reconciliationReport/reconciliationReportState.js +4 -1
- package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
- package/lib/esm/entity/transaction/stateTypes/paymentType.js +9 -1
- package/lib/esm/entity/transaction/stateTypes/printStatus.js +7 -0
- package/lib/esm/epic.js +8 -0
- package/lib/esm/index.js +4 -2
- package/lib/esm/view/invoicing/invoicingOverview/invoicingOverviewPayload.js +3 -0
- package/lib/esm/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.js +157 -0
- package/lib/esm/view/transactionDetail/createTransaction/createTransactionPayload.js +164 -0
- package/lib/esm/view/transactionDetail/createTransaction/createTransactionSelector.js +47 -0
- package/lib/esm/view/transactionDetail/createTransaction/createTransactionState.js +11 -0
- package/lib/esm/view/transactionDetail/createTransaction/epics/createTransactionAttachmentUploadFailureEpic.js +19 -0
- package/lib/esm/view/transactionDetail/createTransaction/epics/createTransactionEpic.js +81 -0
- package/lib/esm/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.js +53 -0
- package/lib/esm/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.js +10 -0
- package/lib/esm/view/transactionDetail/transactionDetailReducer.js +196 -1
- package/lib/index.d.ts +6 -2
- package/lib/index.js +56 -37
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/invoicing/invoicingOverview/invoicingOverviewPayload.d.ts +7 -0
- package/lib/view/invoicing/invoicingOverview/invoicingOverviewPayload.js +3 -0
- package/lib/view/invoicing/invoicingOverview/invoicingOverviewState.d.ts +4 -0
- package/lib/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.d.ts +56 -0
- package/lib/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.js +172 -0
- package/lib/view/transactionDetail/createTransaction/createTransactionPayload.d.ts +95 -0
- package/lib/view/transactionDetail/createTransaction/createTransactionPayload.js +169 -0
- package/lib/view/transactionDetail/createTransaction/createTransactionSelector.d.ts +44 -0
- package/lib/view/transactionDetail/createTransaction/createTransactionSelector.js +53 -0
- package/lib/view/transactionDetail/createTransaction/createTransactionState.d.ts +82 -0
- package/lib/view/transactionDetail/createTransaction/createTransactionState.js +14 -0
- package/lib/view/transactionDetail/createTransaction/epics/createTransactionAttachmentUploadFailureEpic.d.ts +10 -0
- package/lib/view/transactionDetail/createTransaction/epics/createTransactionAttachmentUploadFailureEpic.js +23 -0
- package/lib/view/transactionDetail/createTransaction/epics/createTransactionEpic.d.ts +9 -0
- package/lib/view/transactionDetail/createTransaction/epics/createTransactionEpic.js +85 -0
- package/lib/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.d.ts +20 -0
- package/lib/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.js +57 -0
- package/lib/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.d.ts +12 -0
- package/lib/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.js +14 -0
- package/lib/view/transactionDetail/transactionDetailReducer.d.ts +39 -1
- package/lib/view/transactionDetail/transactionDetailReducer.js +198 -2
- package/lib/view/transactionDetail/transactionDetailState.d.ts +12 -0
- package/package.json +1 -1
package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts
CHANGED
|
@@ -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: {
|
|
@@ -18,6 +18,7 @@ export interface InvoicingMRRDataPointPayload {
|
|
|
18
18
|
month: string;
|
|
19
19
|
mrr: number;
|
|
20
20
|
churned?: number;
|
|
21
|
+
contraction?: number;
|
|
21
22
|
expansion?: number;
|
|
22
23
|
month_num?: number;
|
|
23
24
|
net?: number;
|
|
@@ -46,6 +47,11 @@ export interface InvoicingDashboardSummaryPayload {
|
|
|
46
47
|
resumed: number;
|
|
47
48
|
total_active: number;
|
|
48
49
|
total_active_value: number;
|
|
50
|
+
/**
|
|
51
|
+
* Churned opening-cohort customers ÷ customers at month start, as a 0-100
|
|
52
|
+
* percent. Customer-scoped, unlike the subscription-scoped KPI churn rate.
|
|
53
|
+
*/
|
|
54
|
+
customer_churn_rate?: number | null;
|
|
49
55
|
};
|
|
50
56
|
failed_payments: {
|
|
51
57
|
amount: number;
|
|
@@ -60,6 +66,7 @@ export interface InvoicingDashboardSummaryPayload {
|
|
|
60
66
|
};
|
|
61
67
|
mrr_movement: {
|
|
62
68
|
churned: number;
|
|
69
|
+
contraction: number;
|
|
63
70
|
expansions: number;
|
|
64
71
|
net_change: number;
|
|
65
72
|
new_subscriptions: number;
|
|
@@ -23,6 +23,7 @@ const mapInvoicingMRRDataPointPayloadToState = (payload) => ({
|
|
|
23
23
|
month: payload.month,
|
|
24
24
|
mrr: (0, amount_1.toAmount)(payload.mrr, 'USD', '$'),
|
|
25
25
|
churned: payload.churned,
|
|
26
|
+
contraction: payload.contraction,
|
|
26
27
|
expansion: payload.expansion,
|
|
27
28
|
monthNum: payload.month_num,
|
|
28
29
|
net: payload.net,
|
|
@@ -49,6 +50,7 @@ exports.mapInvoicingPlanRevenuePointPayloadToState = mapInvoicingPlanRevenuePoin
|
|
|
49
50
|
const mapInvoicingDashboardSummaryPayloadToState = (payload) => ({
|
|
50
51
|
customerMovement: {
|
|
51
52
|
churned: payload.customer_movement.churned,
|
|
53
|
+
customerChurnRate: payload.customer_movement.customer_churn_rate ?? undefined,
|
|
52
54
|
netChange: payload.customer_movement.net_change,
|
|
53
55
|
new: payload.customer_movement.new,
|
|
54
56
|
paused: payload.customer_movement.paused,
|
|
@@ -70,6 +72,7 @@ const mapInvoicingDashboardSummaryPayloadToState = (payload) => ({
|
|
|
70
72
|
},
|
|
71
73
|
mrrMovement: {
|
|
72
74
|
churned: payload.mrr_movement.churned,
|
|
75
|
+
contraction: payload.mrr_movement.contraction,
|
|
73
76
|
expansions: payload.mrr_movement.expansions,
|
|
74
77
|
netChange: payload.mrr_movement.net_change,
|
|
75
78
|
newSubscriptions: payload.mrr_movement.new_subscriptions,
|
|
@@ -22,6 +22,7 @@ export interface InvoicingMRRDataPoint {
|
|
|
22
22
|
month: string;
|
|
23
23
|
mrr: Amount;
|
|
24
24
|
churned?: number;
|
|
25
|
+
contraction?: number;
|
|
25
26
|
expansion?: number;
|
|
26
27
|
monthNum?: number;
|
|
27
28
|
net?: number;
|
|
@@ -50,6 +51,8 @@ export interface InvoicingDashboardSummary {
|
|
|
50
51
|
resumed: number;
|
|
51
52
|
totalActive: number;
|
|
52
53
|
totalActiveValue: Amount;
|
|
54
|
+
/** 0-100 percent; absent from a backend that predates it. */
|
|
55
|
+
customerChurnRate?: number;
|
|
53
56
|
};
|
|
54
57
|
failedPayments: {
|
|
55
58
|
amount: Amount;
|
|
@@ -64,6 +67,7 @@ export interface InvoicingDashboardSummary {
|
|
|
64
67
|
};
|
|
65
68
|
mrrMovement: {
|
|
66
69
|
churned: number;
|
|
70
|
+
contraction: number;
|
|
67
71
|
expansions: number;
|
|
68
72
|
netChange: number;
|
|
69
73
|
newSubscriptions: number;
|
|
@@ -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 (header or journal entry line),
|
|
93
|
+
* class or transfer account has no QBO id.
|
|
94
|
+
*/
|
|
95
|
+
export declare const prepareCreateTransactionPayload: (state: RootState, localData: CreateTransactionLocalData) => CreateTransactionRequest;
|
|
@@ -0,0 +1,169 @@
|
|
|
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
|
+
const vendorQboId = toQboLineVendorId(state, line.vendorQboId);
|
|
43
|
+
if (vendorQboId != null) {
|
|
44
|
+
lineDetail.vendor = { qbo_id: vendorQboId };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
// The backend rejects a bool here, so this is always coerced to a number.
|
|
49
|
+
amount: line.amount?.amount ?? 0,
|
|
50
|
+
line_description: line.lineDescription,
|
|
51
|
+
line_detail_type: transactionType === 'journal_entry'
|
|
52
|
+
? 'journal_entry_line_detail'
|
|
53
|
+
: 'account_based_expense_line_detail',
|
|
54
|
+
line_detail: lineDetail,
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Thrown when a picked id has no QBO id to send. Sending the Zeni id instead would reach QBO as
|
|
59
|
+
* an unknown reference and come back as an opaque error, so the create is stopped here and the
|
|
60
|
+
* epic shows this message instead.
|
|
61
|
+
*/
|
|
62
|
+
class UnresolvedCreateTransactionIdError extends Error {
|
|
63
|
+
}
|
|
64
|
+
exports.UnresolvedCreateTransactionIdError = UnresolvedCreateTransactionIdError;
|
|
65
|
+
/**
|
|
66
|
+
* Resolves a transfer account (the Zeni account id from the transfer pools) to its QBO id. The
|
|
67
|
+
* header and line account dropdowns already hold the QBO id, so they are sent as-is.
|
|
68
|
+
*/
|
|
69
|
+
const toQboTransferAccountId = (state, accountId) => {
|
|
70
|
+
if (accountId == null) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
const qboId = (0, accountSelector_1.getAccountBaseForTransferAccounts)(state.accountState, accountId)?.qboId;
|
|
74
|
+
if (qboId == null || qboId === '') {
|
|
75
|
+
throw new UnresolvedCreateTransactionIdError('The selected transfer account could not be found in QuickBooks.');
|
|
76
|
+
}
|
|
77
|
+
return qboId;
|
|
78
|
+
};
|
|
79
|
+
/** Resolves a Zeni class id (`class_<uuid>`) to the QBO id `line_detail.class.qbo_id` expects. */
|
|
80
|
+
const toQboClassId = (state, classId) => {
|
|
81
|
+
if (classId == null) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
const qboId = (0, classSelector_1.getClassById)(state.classState, {
|
|
85
|
+
classId,
|
|
86
|
+
reportId: 'class_list',
|
|
87
|
+
})?.qboId;
|
|
88
|
+
if (qboId == null || qboId === '') {
|
|
89
|
+
throw new UnresolvedCreateTransactionIdError('The selected class could not be found in QuickBooks.');
|
|
90
|
+
}
|
|
91
|
+
return qboId;
|
|
92
|
+
};
|
|
93
|
+
/** A vendor not yet synced to QBO carries `qboId === name`, which QBO would reject. */
|
|
94
|
+
const toSyncedVendorQboId = (vendor) => {
|
|
95
|
+
if (vendor == null || vendor.qboId === '' || vendor.qboId === vendor.name) {
|
|
96
|
+
throw new UnresolvedCreateTransactionIdError('The selected vendor is not synced to QuickBooks yet.');
|
|
97
|
+
}
|
|
98
|
+
return vendor.qboId;
|
|
99
|
+
};
|
|
100
|
+
/** Resolves a Zeni vendor id to its QBO id -- `vendor_id` on the wire is a QBO id. */
|
|
101
|
+
const toQboVendorId = (state, vendorId) => vendorId == null
|
|
102
|
+
? undefined
|
|
103
|
+
: toSyncedVendorQboId((0, vendorSelector_1.getVendorByVendorId)(state.vendorState, vendorId));
|
|
104
|
+
/** A journal entry line holds the QBO id already, so it is only checked against the store. */
|
|
105
|
+
const toQboLineVendorId = (state, vendorQboId) => vendorQboId == null
|
|
106
|
+
? undefined
|
|
107
|
+
: toSyncedVendorQboId((0, vendorSelector_1.getVendorByQboId)(state.vendorState, vendorQboId));
|
|
108
|
+
/**
|
|
109
|
+
* Builds the request body for one transaction type. One branch per type rather than a shared
|
|
110
|
+
* body with optional keys, because the types genuinely diverge -- transfer carries no lines at
|
|
111
|
+
* all, and journal_entry carries no header account.
|
|
112
|
+
*
|
|
113
|
+
* Throws UnresolvedCreateTransactionIdError when a picked vendor (header or journal entry line),
|
|
114
|
+
* class or transfer account has no QBO id.
|
|
115
|
+
*/
|
|
116
|
+
const prepareCreateTransactionPayload = (state, localData) => {
|
|
117
|
+
const { transactionType } = localData;
|
|
118
|
+
const base = {
|
|
119
|
+
transaction_type: transactionType,
|
|
120
|
+
transaction_date: localData.transactionDate?.format(timePeriod_1.DEFAULT_DATE_FORMAT) ?? '',
|
|
121
|
+
transaction_memo: localData.transactionMemo,
|
|
122
|
+
};
|
|
123
|
+
if (transactionType === 'transfer') {
|
|
124
|
+
return {
|
|
125
|
+
...base,
|
|
126
|
+
from_account_id: toQboTransferAccountId(state, localData.fromAccountId),
|
|
127
|
+
to_account_id: toQboTransferAccountId(state, localData.toAccountId),
|
|
128
|
+
total_amount: localData.totalAmount?.amount ?? 0,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const lines = localData.lines.map((line) => toLinePayload(state, line, transactionType));
|
|
132
|
+
if (transactionType === 'journal_entry') {
|
|
133
|
+
return {
|
|
134
|
+
...base,
|
|
135
|
+
document_id: localData.documentId,
|
|
136
|
+
lines,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
const purchaseBase = {
|
|
140
|
+
...base,
|
|
141
|
+
payment_type: localData.paymentType,
|
|
142
|
+
qbo_account_id: localData.qboAccountId,
|
|
143
|
+
vendor_id: toQboVendorId(state, localData.vendorId),
|
|
144
|
+
lines,
|
|
145
|
+
};
|
|
146
|
+
if (transactionType === 'check') {
|
|
147
|
+
return {
|
|
148
|
+
...purchaseBase,
|
|
149
|
+
document_number: localData.documentNumber,
|
|
150
|
+
print_status: localData.printStatus,
|
|
151
|
+
remit_to_address: toRemitToAddressPayload(localData.remitToAddress),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
if (transactionType === 'credit_card_credit') {
|
|
155
|
+
// credit_card_credit is not in the backend's SUPPORTED_TRANSACTION_WRITE_TYPES. QBO models
|
|
156
|
+
// it as a Purchase with Credit: true and qbo_purchase.py already honours is_credit for
|
|
157
|
+
// card payment types, so this sends `expense` + is_credit rather than a type the validator
|
|
158
|
+
// rejects outright. Confirm with backend before enabling the menu item. The seed sets
|
|
159
|
+
// payment_type to credit_card, since qbo_purchase.py raises on is_credit without a card type.
|
|
160
|
+
return {
|
|
161
|
+
...purchaseBase,
|
|
162
|
+
transaction_type: 'expense',
|
|
163
|
+
is_credit: true,
|
|
164
|
+
document_number: localData.documentNumber,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return purchaseBase;
|
|
168
|
+
};
|
|
169
|
+
exports.prepareCreateTransactionPayload = prepareCreateTransactionPayload;
|