ynab-amazon-helper/types.ts
2025-11-04 12:27:02 -05:00

55 lines
1.2 KiB
TypeScript

// Amazon Order Types
export interface AmazonOrder {
orderId: string;
orderDate: Date;
total: number;
items: AmazonOrderItem[];
orderUrl: string;
}
export interface AmazonOrderItem {
title: string;
price: number;
quantity: number;
}
// YNAB Transaction Types
export interface YNABTransaction {
id: string;
date: string; // YYYY-MM-DD format
amount: number; // in milliunits (e.g., -12340 = -$12.34)
payee_name: string | null;
memo: string | null;
category_id: string | null;
category_name: string | null;
account_id: string;
account_name: string;
}
export interface YNABCategory {
id: string;
name: string;
category_group_id: string;
category_group_name: string;
}
// Matching Types
export interface TransactionMatch {
ynabTransaction: YNABTransaction;
amazonOrder: AmazonOrder | null;
matchConfidence: number; // 0-1 score
suggestedCategory: YNABCategory | null;
status: 'pending' | 'approved' | 'rejected';
}
export interface MatchingOptions {
dateToleranceDays: number; // How many days before/after to consider a match
amountToleranceDollars: number; // How much variance in amount to allow
}
// API Response Types
export interface APIResponse<T> {
success: boolean;
data?: T;
error?: string;
}