>
> I'm trying to wrap my mind around the different parts of beancount in 
> order to automate the import of my Amazon purchases. Using their Chase card 
> allows me to have a mapping from a credit card transaction to Amazon order 
> id. From Amazon, I can download a csv file with all items with their order 
> ids.
>

Here is a slightly different approach that has dependably worked for me for 
years to import Amazon purchases, and addresses all the issues you brought 
up (of matching during import):

*Solution*
1. Credit card transactions are booked to a Zero sum account. Smart 
importer does this automatically:
2022-09-02 * "AMZN Mktp US*1FASU238B"
  Liabilities:Credit-Cards:MyCard  -18.92 USD
  Assets:Zero-Sum-Accounts:Amazon-Purchases

2. Amazon purchases are booked from the Zero sum account to the expense 
account. smart_importer will book repeating transactions correctly. Others 
need to be booked manually:
2022-09-03 * "Cool Stealth Canoe, Black"
  card: "Gift Certificate/Card and Visa - 1234"
  Assets:Zero-Sum-Accounts:Amazon-Purchases  -18.92 USD
  Expenses:Outdoor-Activities:Equipment

3. In most cases, the transactions in the Zero sum account will sum to 
zero, and you are all done! Optionally, if you use the zero sum plugin 
<https://github.com/redstreet/beancount_reds_plugins/blob/main/beancount_reds_plugins/zerosum/README.md>,
  
it will match transactions above in memory, that can help in case you have 
unmatched, left over transactions.

*Pros and Cons*

   - With this approach, there is no dependency on the credit card used to 
   include metadata that maps to the Amazon order id. I could even pay with an 
   Amazon gift card (even partially), and everything works out of the box.
   - The approach decouples the payment with the classification of 
   transactions. This way, you are not forced to import and classify purchases 
   each time you download your credit card transactions (which is fully 
   automated for me, and takes like 5 seconds, which means I tend to do it 
   frequently). Your pending amazon purchase details are neatly booked into 
   the Assets account as a negative balance, and thus also reflect your state 
   correctly.
   - Of course, the decoupling means you can't see the expense account on 
   the payment transaction directly. I find that this doesn't matter to me at 
   all. If you find that it does (I'd be curious as to why), it's pretty 
   simple to solve by adding a trivial beancount-link feature to the zerosum 
   plugin to link the two transactions. Fava will then display a link.


*Implementation*
I use Beancount's built in csv importer, which suffices, along with 
smart_importer, both seen in the config below:

CONFIG = [
    # GDPR Download
    # limitations: doesn't include coupons and discounts
    apply_hooks(csv.Importer({Col.DATE: 'Order Date',
                  Col.NARRATION1: 'Product Name',
                  Col.AMOUNT: 'Total Owed',
                  Col.LAST4: 'Payment Instrument Type',
                  },
                  'Assets:Zero-Sum-Accounts:Amazon-Purchases',
                  'USD',

                  ("Website", "Order ID", "Order Date", "Purchase Order 
Number", "Currency", "Unit Price",  "Unit Price Tax",
                   "Shipping Charge", "Total Discounts", "Total Owed", 
"Shipment Item Subtotal", "Shipment Item Subtotal Tax",
                   "ASIN", "Product Condition", "Quantity", "Payment 
Instrument Type", "Order Status", "Shipment Status",
                   "Ship Date", "Shipping Option", "Shipping Address", 
"Billing Address", "Carrier Name & Tracking Number",
                   "Product Name", "Gift Message", "Gift Sender Name", 
"Gift Recipient Contact Details"),

                  encoding='utf-8-sig',
                  institution='Amazon',
                  invert_sign=True),
       [PredictPostings()]),
]

Amazon used to provide a "Category" column (eg: Kitchen, Sporting, etc.) 
that worked together with smart_importer to book almost any, never-seen 
transaction correctly. They don't any more.

*Extensions*
I screenscrape (copy-paste) my Amazon gift card transactions from the 
webpage as a tab-separated file, and import this as a payment method. At 
the end of this, I have a gift card balance that usually agrees with what 
my Amazon account shows. I'll share this importer later.

All the above takes perhaps 3-4 minutes + the time taken to book the 
purchases. I personally do it only once in several months.

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beancount+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/7d1a9ea3-2907-4ffe-9100-254414ff5315n%40googlegroups.com.

Reply via email to