[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 18be9ad 04/21: Add ebdb-field-bank-account class
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 18be9ad 04/21: Add ebdb-field-bank-account class |
Date: |
Sun, 17 Sep 2017 15:32:45 -0400 (EDT) |
branch: externals/ebdb
commit 18be9ad1520cf8c04c232af0da4db259b7e77732
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Add ebdb-field-bank-account class
* ebdb.el (ebdb-field-bank-account): New class holding bank account
information.
(ebdb-read, ebdb-string): Basic methods, no ebdb-parse.
* ebdb-com.el (ebdb-fmt-field): Special output for this class.
---
ebdb-com.el | 7 ++++
ebdb.el | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 111 insertions(+)
diff --git a/ebdb-com.el b/ebdb-com.el
index 2fe1b22..2f495b0 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -458,6 +458,13 @@ property is the field instance itself."
(propertize "HIDDEN" 'face 'ebdb-field-hidden))
(cl-defmethod ebdb-fmt-field ((_fmt ebdb-formatter-ebdb)
+ (field ebdb-field-bank-account)
+ _style
+ (_record ebdb-record))
+ (with-slots (bank-name account-name) field
+ (format "%s: %s" bank-name account-name)))
+
+(cl-defmethod ebdb-fmt-field ((_fmt ebdb-formatter-ebdb)
(field ebdb-field-mail)
_style
(_record ebdb-record))
diff --git a/ebdb.el b/ebdb.el
index 1f84f40..fc9081f 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -2185,6 +2185,110 @@ See `ebdb-url-valid-schemes' for a list of acceptable
schemes."
(cl-defmethod ebdb-string ((field ebdb-field-gender))
(symbol-name (slot-value field 'gender)))
+;;; Bank account field
+
+(defclass ebdb-field-bank-account (ebdb-field-user)
+ ((bank-name
+ :initarg :bank-name
+ :type string
+ :custom string
+ :documentation "Bank name")
+ (bank-address
+ :initarg :bank-address
+ :type (or ebdb-field-address null)
+ :initform nil
+ :custom ebdb-field-address
+ :documentation "Bank address")
+ (routing-aba
+ :initarg :routing-aba
+ :type (or string null)
+ :initform nil
+ :custom string
+ :documentation "Routing number or ABA")
+ (swift-bic
+ :initarg :swift-bic
+ :type (or string null)
+ :initform nil
+ :custom string
+ :documentation "SWIFT or BIC code, for international transfers")
+ (account-name
+ :initarg :account-name
+ :type string
+ :custom string
+ :documentation "Name of account")
+ (account-numbers
+ :initarg :account-numbers
+ :type list
+ :custom (repeat (cons (string :tag "Account label")
+ (string :tag "Account number")))
+ :documentation "A list of account labels and numbers/IBANs")
+ (notes
+ :initarg :notes
+ :type (or ebdb-field-notes null)
+ :custom ebdb-field-notes
+ :initform nil
+ :documentation "Additional notes"))
+ :human-readable "bank account"
+ :documentation "A field holding information for a bank account.")
+
+(cl-defmethod ebdb-read ((class (subclass ebdb-field-bank-account))
+ &optional slots obj)
+ (let ((bank-name (or (plist-get slots :bank-name)
+ (ebdb-read-string "Bank name: "
+ (when obj (slot-value obj
'bank-name)))))
+ (bank-address (or (plist-get slots :bank-address)
+ (ebdb-with-exit
+ (ebdb-read 'ebdb-field-address '(:object-name
"office")
+ (when obj (slot-value obj
'bank-address))))))
+ (routing-aba (or (plist-get slots :routing-aba)
+ (ebdb-with-exit
+ (ebdb-read-string "Routing or ABA number: "
+ (when obj (slot-value obj
'routing-aba))))))
+ (swift-bic (or (plist-get slots :swift-bic)
+ (ebdb-with-exit
+ (ebdb-read-string "SWIFT or BIC code: "
+ (when obj (slot-value obj
'swift-bic))))))
+ (account-name (or (plist-get slots :account-name)
+ (ebdb-read-string "Account name: "
+ (when obj (slot-value obj
'account-name)))))
+ (account-numbers
+ (or (plist-get slots :account-numbers)
+ (ebdb-loop-with-exit
+ (cons (ebdb-read-string "Account label (eg. \"checking\"): ")
+ (ebdb-read-string "Account number/IBAN: ")))))
+ (notes (or (plist-get slots :notes)
+ (ebdb-with-exit
+ (ebdb-read 'ebdb-field-notes nil
+ (when obj (slot-value obj 'notes)))))))
+ (cl-call-next-method
+ class
+ `(:bank-name ,bank-name
+ :bank-address ,bank-address
+ :routing-aba ,routing-aba
+ :swift-bic ,swift-bic
+ :account-name ,account-name
+ :account-numbers ,account-numbers
+ :notes ,notes)
+ obj)))
+
+(cl-defmethod ebdb-string ((acct ebdb-field-bank-account))
+ (with-slots (bank-name bank-address routing-aba swift-bic
+ account-name account-numbers notes)
+ acct
+ (concat bank-name "\n\n"
+ (ebdb-string bank-address) "\n"
+ (when routing-aba
+ (format "Routing/ABA: %s\n" routing-aba))
+ (when swift-bic
+ (format "SWIFT/BIC: %s\n" swift-bic))
+ "\n" account-name "\n"
+ (mapconcat
+ (lambda (a)
+ (format "%s: %s" (car a) (cdr a)))
+ account-numbers "\n")
+ (when notes
+ (format "\n%s\n" notes)))))
+
;; Tags field.
;; This field class holds a list of tags that apply to the record.
- [elpa] externals/ebdb updated (cec392d -> c298037), Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb 6b605a9 06/21: Hash records against their tag field tags, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb 4206ccd 02/21: Don't unilaterally add to kill-emacs-hook, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb 3311fc7 10/21: Add a dir file for the Info manual, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb 62fcfcf 15/21: Add ebdb-save to write-contents-functions in EBDB buffers, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb a22c983 16/21: Try different faces in EBDB buffers, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb 13f680a 13/21: Part two of threaded version of ebdb-initialize, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb 3a918eb 09/21: Provide better instructions for BBDB migration, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb cbb4cc1 20/21: More complete error handling for field insertion, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb c298037 21/21: Bump version for 0.3.2, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb 18be9ad 04/21: Add ebdb-field-bank-account class,
Eric Abrahamsen <=
- [elpa] externals/ebdb dc5d03e 01/21: Change behavior of ebdb-fmt-compose-field, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb 9c0947c 05/21: Comment out some custom definitions for address field, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb 4a332dc 03/21: Add defgeneric for ebdb-read, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb 767a9fa 07/21: Allow two kinds of searches on tags, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb 8fc7b6d 08/21: Allow "fast lookups", Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb e3229ad 11/21: Give some indication that the migration process is ongoing, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb efd9e15 12/21: Provide an alternate threaded version of ebdb-initialize, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb 2fa4379 14/21: New option ebdb-try-speedups, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb 09a04b2 19/21: Fix up ebdb-string method for bank accounts, Eric Abrahamsen, 2017/09/17
- [elpa] externals/ebdb 2b52686 18/21: Check type spec of slots that may or may not accept an object, Eric Abrahamsen, 2017/09/17