> ## Documentation Index
> Fetch the complete documentation index at: https://docs.humaniq.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Financial Recipes

> Approval workflows for financial operations

<Note>
  These recipes provide ready-to-use approval workflows for financial operations, designed with compliance and security in mind.
</Note>

<Tabs>
  <Tab title="Refund Processing">
    ### Refund Processing

    Enable safe refund processing with automatic approvals for small amounts and required oversight for larger refunds.

    <CodeGroup>
      ```typescript Basic theme={null}
      const processRefund = needsHumanApproval({
        type: 'sync',
        title: 'Refund Request',
        ask: (args) => `Approve refund of $${args.amount} for order ${args.orderId}?`,
        autoApprove: async (args) => args.amount < 100
      })

      // Usage
      await processRefund({
        orderId: '1234',
        amount: 150,
        reason: 'Defective product'
      })
      ```

      ```typescript Advanced theme={null}
      const processRefund = needsHumanApproval({
        type: 'sync',
        title: 'Refund Request',
        ask: (args) => {
          const urgent = args.customerTier === 'VIP' ? '🔔 URGENT: ' : '';
          return `${urgent}Approve refund of $${args.amount} for order ${args.orderId}?`;
        },
        // Auto-approve based on multiple conditions
        autoApprove: async (args) => {
          return args.amount < 100 || 
                 args.customerTier === 'VIP' ||
                 args.reason === 'Damaged in shipping';
        },
        approvalArguments: {
          amount: {
            type: 'number',
            value: args.amount,
            label: 'Refund Amount',
            editable: true
          },
          reason: {
            type: 'string',
            value: args.reason,
            label: 'Refund Reason',
            editable: true
          },
          customerTier: {
            type: 'string',
            value: args.customerTier,
            label: 'Customer Tier',
            editable: false
          },
          notes: {
            type: 'longString',
            value: '',
            label: 'Approval Notes',
            editable: true
          }
        }
      })
      ```
    </CodeGroup>

    <AccordionGroup>
      <Accordion title="When to use this" icon="lightbulb">
        * Customer refund requests
        * Order cancellations
        * Service credits
        * Complaint resolutions
      </Accordion>

      <Accordion title="Best practices" icon="check">
        * Set appropriate auto-approval thresholds
        * Include order context
        * Maintain audit trail
        * Consider customer history
      </Accordion>
    </AccordionGroup>
  </Tab>

  <Tab title="Wire Transfers">
    ### Wire Transfers

    Secure wire transfer processing with multi-approver requirements and business hour restrictions.

    <CodeGroup>
      ```typescript Basic theme={null}
      const processWireTransfer = needsHumanApproval({
        type: 'sync',
        title: 'Wire Transfer',
        ask: (args) => `Approve wire transfer of $${args.amount} to ${args.recipient}?`,
        // Require approval outside business hours
        shouldSeekApprovals: async (args) => {
          const hour = new Date().getHours();
          return hour < 9 || hour > 17;
        }
      })
      ```

      ```typescript Advanced theme={null}
      const processWireTransfer = needsHumanApproval({
        type: 'sync',
        title: 'Wire Transfer',
        ask: (args) => `Approve wire transfer of $${args.amount} to ${args.recipient}?`,
        // Multiple approvers for large amounts
        approvers: (args) => {
          if (args.amount > 50000) {
            return [
              { name: 'Financial Controller', email: 'controller@company.com' },
              { name: 'Treasury Manager', email: 'treasury@company.com' }
            ];
          }
          return [{ name: 'Finance Manager', email: 'finance@company.com' }];
        },
        approvalArguments: {
          amount: {
            type: 'number',
            value: args.amount,
            label: 'Transfer Amount',
            editable: true
          },
          recipient: {
            type: 'string',
            value: args.recipient,
            label: 'Recipient',
            editable: true
          },
          recipientBank: {
            type: 'string',
            value: args.bankDetails,
            label: 'Bank Details',
            editable: false
          },
          purpose: {
            type: 'string',
            value: args.purpose,
            label: 'Transfer Purpose',
            editable: true
          }
        }
      })
      ```
    </CodeGroup>

    <Note>
      For wire transfers over \$50,000, approvals from both Financial Controller and Treasury Manager are required.
    </Note>
  </Tab>

  <Tab title="Payment Processing">
    ### Payment Processing

    Handle high-value payment approvals with fraud detection integration.

    ```typescript theme={null}
    const processPayment = needsHumanApproval({
      type: 'sync',
      title: 'Payment Processing',
      ask: (args) => {
        const fraudAlert = args.fraudScore > 70 ? '⚠️ HIGH RISK: ' : '';
        return `${fraudAlert}Approve payment of $${args.amount} for transaction ${args.transactionId}`;
      },
      approvalArguments: {
        amount: {
          type: 'number',
          value: args.amount,
          label: 'Payment Amount',
          editable: false
        },
        fraudScore: {
          type: 'number',
          value: args.fraudScore,
          label: 'Fraud Risk Score',
          editable: false
        },
        paymentMethod: {
          type: 'string',
          value: args.paymentMethod,
          label: 'Payment Method',
          editable: false
        },
        customerHistory: {
          type: 'longString',
          value: args.transactionHistory,
          label: 'Customer Transaction History',
          editable: false
        }
      },
      // Require approval for high-risk transactions
      shouldSeekApprovals: async (args) => {
        return args.fraudScore > 50 || args.amount > 10000;
      }
    })
    ```

    <AccordionGroup>
      <Accordion title="Risk Factors" icon="shield-halved">
        * Fraud score above threshold
        * Unusual transaction amount
        * New payment method
        * Geographic location
      </Accordion>
    </AccordionGroup>
  </Tab>

  <Tab title="Credit Limit Changes">
    ### Credit Limit Changes

    Manage credit limit modifications with risk assessment.

    ```typescript theme={null}
    const modifyCreditLimit = needsHumanApproval({
      type: 'async',
      title: 'Credit Limit Modification',
      ask: (args) => `Review credit limit change for account ${args.accountId}`,
      approvalArguments: {
        currentLimit: {
          type: 'number',
          value: args.currentLimit,
          label: 'Current Limit',
          editable: false
        },
        proposedLimit: {
          type: 'number',
          value: args.proposedLimit,
          label: 'Proposed Limit',
          editable: true
        },
        creditScore: {
          type: 'number',
          value: args.creditScore,
          label: 'Credit Score',
          editable: false
        },
        paymentHistory: {
          type: 'longString',
          value: args.paymentHistory,
          label: 'Payment History',
          editable: false
        }
      },
      // Auto-approve small increases for good customers
      autoApprove: async (args) => {
        const increasePercent = (args.proposedLimit - args.currentLimit) / args.currentLimit * 100;
        return increasePercent <= 10 && args.creditScore > 700;
      }
    })
    ```
  </Tab>
</Tabs>

## Next Steps

<CardGroup cols={2}>
  <Card title="Legal Recipes" icon="scale-balanced" href="/recipes/legal">
    Explore approval workflows for legal operations
  </Card>
</CardGroup>
