Class: QBFC::Transaction
- Defined in:
- lib/qbfc/transaction.rb
Constant Summary collapse
- ID_NAME =
"TxnID"
Class Method Summary collapse
- .base_class_find(sess, what, q, options) ⇒ Object
-
.find_by_id(sess, id, options = {}) ⇒ Object
Find by TxnID of List record.
-
.find_by_ref(sess, ref, options = {}) ⇒ Object
Find by Reference Number of the Transaction record.
-
.find_by_ref_or_id(*args) ⇒ Object
(also: find_by_unique_id)
Find by either ref or id.
Instance Method Summary collapse
-
#cleared_status=(status) ⇒ Object
Change cleared status of transaction status can be one of: - QBFC::CsCleared (or true) - QBFC::CsNotCleared (or false) - QBFC::CsPending.
-
#delete ⇒ Object
Delete this Transaction.
-
#display ⇒ Object
Display the Transaction add (for new records) or edit dialog box.
-
#id ⇒ Object
Alias of TxnID for this record.
Methods inherited from Element
#custom, find, #initialize, is_base_class, is_base_class?, #new_record?, #save
Methods inherited from Base
create_query, #initialize, is_base_class?, #method_missing, #ole_methods, parse_find_args, qb_name, #qb_name, #respond_to_ole?
Constructor Details
This class inherits a constructor from QBFC::Element
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class QBFC::Base
Class Method Details
.base_class_find(sess, what, q, options) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/qbfc/transaction.rb', line 33 def base_class_find(sess, what, q, ) q.IncludeRetElementList.Add(self::ID_NAME) q.IncludeRetElementList.Add('TxnType') list = q.response if list.nil? (what == :all) ? [] : nil else ary = (0..(list.Count - 1)).collect { |i| element = list.GetAt(i) ret_class_name = element.TxnType.GetAsString if QBFC::const_defined?(ret_class_name) ret_class = QBFC::const_get(ret_class_name) ret_class.find(sess, element.send(ret_class::ID_NAME).GetValue, .dup) else find(sess, element.send(Transaction::ID_NAME).GetValue, .dup.merge(:ignore_base_class => true)) end } if what == :all ary else ary[0] end end end |
.find_by_id(sess, id, options = {}) ⇒ Object
Find by TxnID of List record. options
are the same as those for in find
.
20 21 22 23 24 |
# File 'lib/qbfc/transaction.rb', line 20 def find_by_id(sess, id, = {}) q = create_query(sess) q.query.TxnIDList.Add(id) find(sess, :first, q, ) end |
.find_by_ref(sess, ref, options = {}) ⇒ Object
Find by Reference Number of the Transaction record. options
are the same as those for in find
.
12 13 14 15 16 |
# File 'lib/qbfc/transaction.rb', line 12 def find_by_ref(sess, ref, = {}) q = create_query(sess) q.query.RefNumberList.Add(ref) find(sess, :first, q, ) end |
.find_by_ref_or_id(*args) ⇒ Object Also known as: find_by_unique_id
Find by either ref or id. Tries id first, then ref.
27 28 29 |
# File 'lib/qbfc/transaction.rb', line 27 def find_by_ref_or_id(*args) find_by_id(*args) || find_by_ref(*args) end |
Instance Method Details
#cleared_status=(status) ⇒ Object
Change cleared status of transaction status can be one of:
-
QBFC::CsCleared (or true)
-
QBFC::CsNotCleared (or false)
-
QBFC::CsPending
81 82 83 84 85 86 87 88 89 |
# File 'lib/qbfc/transaction.rb', line 81 def cleared_status=(status) req = QBFC::Request.new(@sess, "ClearedStatusMod") req.txn_id = id status = QBFC_CONST::CsCleared if status === true status = QBFC_CONST::CsNotCleared if status === false req.cleared_status = status req.submit return status end |
#delete ⇒ Object
Delete this Transaction
68 69 70 71 72 73 74 |
# File 'lib/qbfc/transaction.rb', line 68 def delete req = QBFC::Request.new(@sess, "TxnDel") req.txn_del_type = QBFC_CONST::const_get("Tdt#{qb_name}") req.txn_id = id req.submit return true end |
#display ⇒ Object
Display the Transaction add (for new records) or edit dialog box
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/qbfc/transaction.rb', line 92 def display if new_record? req = QBFC::Request.new(@sess, "TxnDisplayAdd") req.txn_display_add_type = QBFC_CONST::const_get("Tdat#{qb_name}") else req = QBFC::Request.new(@sess, "TxnDisplayMod") req.txn_display_mod_type = QBFC_CONST::const_get("Tdmt#{qb_name}") req.txn_id = id end req.submit return true end |
#id ⇒ Object
Alias of TxnID for this record.
63 64 65 |
# File 'lib/qbfc/transaction.rb', line 63 def id @ole.txn_id end |