(ns auto-ap.views.pages.invoices.common)

(defn does-amount-exceed-outstanding? [amount outstanding-balance ]
  (let [amount (js/parseFloat amount)
        outstanding-balance (js/parseFloat outstanding-balance)] 
    (or (and (> outstanding-balance 0)
             (> amount outstanding-balance))
        (and (> outstanding-balance 0)
             (<= amount 0))
        (and (< outstanding-balance 0)
             (< amount outstanding-balance))
        (and (< outstanding-balance 0)
             (>= amount 0)))))

(def invoice-read [:id :total :outstanding-balance :date :due :invoice-number :status
                   :scheduled-payment
                   [:client [:id :name :locations]]
                   [:payments [:amount [:payment [:id :amount :s3_url :check_number ]]]]
                   [:vendor [:id :name]]
                   [:expense_accounts [:amount :id 
                                       :location
                                       [:account [:id :numeric-code :name :location]]]]])
