File imports.yaml

inputs:
  - match: "import-data/mercury/*.csv"
    config:
      extractor: mercury
      default_file: "books/{{ date.year }}.bean"
      prepend_postings:
        - account: Assets:Bank:US:Mercury:Checking
          amount:
            number: "{{ amount }}"
            currency: "{{ currency | default('USD', true) }}"
  - match: "import-data/connect/American Express/Plaid Credit Card/*.csv"
    config:
      default_file: "books/{{ date.year }}.bean"
      prepend_postings:
        - account: Liabilities:CreditCard:US:AmericanExpress:PlaidCreditCard
          amount:
            number: "{{ -amount }}"
            currency: "{{ currency | default('USD', true) }}"
  - match: "import-data/connect/Chase/Plaid Checking/*.csv"
    config:
      default_file: "books/{{ date.year }}.bean"
      prepend_postings:
        - account: Assets:Bank:US:Chase:Checking
          amount:
            number: "{{ -amount }}"
            currency: "{{ currency | default('USD', true) }}"
  - match: "import-data/connect/Chase/Plaid Saving/*.csv"
    config:
      default_file: "books/{{ date.year }}.bean"
      prepend_postings:
        - account: Assets:Bank:US:Chase:Saving
          amount:
            number: "{{ -amount }}"
            currency: "{{ currency | default('USD', true) }}"
  - match: "import-data/connect/Wells Fargo/Plaid Checking/*.csv"
    config:
      default_file: "books/{{ date.year }}.bean"
      prepend_postings:
        - account: Assets:Bank:US:WellsFargo:Checking
          amount:
            number: "{{ -amount }}"
            currency: "{{ currency | default('USD', true) }}"
  - match: "import-data/connect/Wells Fargo/Plaid Saving/*.csv"
    config:
      default_file: "books/{{ date.year }}.bean"
      prepend_postings:
        - account: Assets:Bank:US:WellsFargo:Checking
          amount:
            number: "{{ -amount }}"
            currency: "{{ currency | default('USD', true) }}"

imports:
  - name: Mercury Routine expenses
    common_cond:
      extractor:
        equals: "mercury"
    match:
      - cond:
          desc: Amazon Web Services
        vars:
          account: Expenses:Engineering:Servers:AWS
      - cond:
          desc: Circleci|Digital Ocean|Netlify
        vars:
          account: Expenses:Engineering:ServiceSubscription
      - cond:
          desc: Microsoft
        vars:
          account: Expenses:Office:Supplies:SoftwareAsService
          narration: "Microsoft 365 Apps for Business Subscription"
      - cond:
          desc: OpenPhone
        vars:
          account: Expenses:Office:Supplies:SoftwareAsService
      - cond:
          desc: Mailchimp
        vars:
          account: Expenses:Marketing:ServiceSubscription
      - cond:
          desc: Adobe
        vars:
          account: Expenses:Design:ServiceSubscription
      - cond:
          desc: AMEX EPAYMENT
        vars:
          account: Liabilities:CreditCard:US:AmericanExpress:AmazonPrime 
          narration: "American Express Amazon Prime credit card payment"
    actions:
      - txn:
          flag: "{{ '!' if pending else '*' }}"
          narration: "{{ narration | default(desc, true) | default(bank_desc, true) }}"
          postings:
            - account: "{{ account }}"
              amount:
                number: "{{ -amount }}"
                currency: "{{ currency | default('USD', true) }}"

  - name: Routine expenses
    common_cond:
      extractor:
        equals: "plaid"
    match:
      - cond:
          payee: KFC|McDonald's|Starbucks
        vars:
          account: Expenses:Food
      - cond:
          payee: United Airlines|Uber
        vars:
          account: Expenses:Travel
      - cond:
          desc: Touchstone Climbing|Madison Bicycle Shop
        vars:
          account: Expenses:Fitness
      - cond:
          desc: AUTOMATIC PAYMENT - THANK
        vars:
          account: Assets:Bank:US:Chase:Checking
          narration: "Paid credit card"
      - cond:
          desc: Tectra Inc|SparkFun
        vars:
          account: Expenses:Engineering:Equipments
          narration: "Purchase scientific equipments for my startup"
      - cond:
          desc: INTRST PYMNT
        vars:
          account: Income:BankInterest
    actions:
      - txn:
          flag: "{{ '!' if pending else '*' }}"
          narration: "{{ narration | default(desc, true) | default(bank_desc, true) }}"
          postings:
            - account: "{{ account }}"
              amount:
                number: "{{ amount }}"
                currency: "{{ currency | default('USD', true) }}"

  - name: Gusto fees
    match:
      extractor:
        equals: "mercury"
      desc: GUSTO
      bank_desc:
        prefix: "GUSTO; FEE "
    actions:
      - txn:
          narration: "Gusto subscription fee"
          postings:
            - account: Expenses:Office:Supplies:SoftwareAsService
              amount:
                number: "{{ -amount }}"
                currency: "{{ currency | default('USD', true) }}"

  - name: Receive payments from contracting client XYZ
    match:
      extractor:
        equals: "mercury"
      desc:
        equals: XYZ
    actions:
      - txn:
          narration: "Receive payment from XYZ"
          postings:
            - account: "Assets:AccountsReceivable:Contracting:XYZ"
              amount:
                number: "{{ -amount / 300 }}"
                currency: "XYZ.HOUR"
              price:
                number: "300.0"
                currency: "USD"

  - name: Ignore unused entries
    match:
      desc:
        one_of:
        - Mercury Credit
        - Mercury Checking xx1234
        - CREDIT CARD 3333 PAYMENT *//
    actions:
      - type: ignore