Class: Merge::Accounting::GeneralLedgerTransaction
- Inherits:
-
Object
- Object
- Merge::Accounting::GeneralLedgerTransaction
- Defined in:
- lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb
Overview
# The GeneralLedgerTransaction Object
### Description
A General Ledger Entry is a record of a financial transaction that is posted to
the general ledger, the central repository of a company’s financial data.
The `GeneralLedgerTransaction` object is a singular endpoint to pull all
transactions posted to a company’s general ledger. The transaction that
generated the `GeneralLedgerTransaction` can be found by referencing the
`underlying_transaction_type` and `underlying_transaction_remote_id` fields.
The lines of a `GeneralLedgerTransaction` object will always have equal amounts
of debits and credits.
### Usage Example
Fetch from the `GET GeneralLedgerTransaction` endpoint and view a general ledger
transaction.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#accounting_period ⇒ Merge::Accounting::GeneralLedgerTransactionAccountingPeriod
readonly
The accounting period that the GeneralLedgerTransaction was generated in.
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#company ⇒ Merge::Accounting::GeneralLedgerTransactionCompany
readonly
The company the GeneralLedgerTransaction belongs to.
-
#created_at ⇒ DateTime
readonly
The datetime that this object was created by Merge.
- #field_mappings ⇒ Hash{String => Object} readonly
-
#general_ledger_transaction_lines ⇒ Array<Merge::Accounting::GeneralLedgerTransactionGeneralLedgerTransactionLinesItem>
readonly
A list of “General Ledger Transaction Applied to Lines” objects.
- #id ⇒ String readonly
-
#modified_at ⇒ DateTime
readonly
The datetime that this object was modified by Merge.
-
#posting_date ⇒ DateTime
readonly
The date that the transaction was posted to the general ledger.
-
#remote_created_at ⇒ DateTime
readonly
When the third party’s GeneralLedgerTransaction entry was created.
- #remote_data ⇒ Array<Merge::Accounting::RemoteData> readonly
-
#remote_id ⇒ String
readonly
The third-party API ID of the matching object.
-
#remote_updated_at ⇒ DateTime
readonly
When the third party’s GeneralLedgerTransaction entry was updated.
-
#remote_was_deleted ⇒ Boolean
readonly
Indicates whether or not this object has been deleted in the third party platform.
- #tracking_categories ⇒ Array<Merge::Accounting::GeneralLedgerTransactionTrackingCategoriesItem> readonly
-
#underlying_transaction_remote_id ⇒ String
readonly
The third party remote ID of the underlying transaction.
-
#underlying_transaction_type ⇒ Merge::Accounting::UnderlyingTransactionTypeEnum
readonly
The type of the underlying transaction.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Merge::Accounting::GeneralLedgerTransaction
Deserialize a JSON object to an instance of GeneralLedgerTransaction.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, underlying_transaction_remote_id: OMIT, underlying_transaction_type: OMIT, accounting_period: OMIT, company: OMIT, remote_updated_at: OMIT, remote_created_at: OMIT, tracking_categories: OMIT, posting_date: OMIT, general_ledger_transaction_lines: OMIT, remote_was_deleted: OMIT, field_mappings: OMIT, remote_data: OMIT, additional_properties: nil) ⇒ Merge::Accounting::GeneralLedgerTransaction constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of GeneralLedgerTransaction to a JSON object.
Constructor Details
#initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, underlying_transaction_remote_id: OMIT, underlying_transaction_type: OMIT, accounting_period: OMIT, company: OMIT, remote_updated_at: OMIT, remote_created_at: OMIT, tracking_categories: OMIT, posting_date: OMIT, general_ledger_transaction_lines: OMIT, remote_was_deleted: OMIT, field_mappings: OMIT, remote_data: OMIT, additional_properties: nil) ⇒ Merge::Accounting::GeneralLedgerTransaction
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 107 def initialize(id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, underlying_transaction_remote_id: OMIT, underlying_transaction_type: OMIT, accounting_period: OMIT, company: OMIT, remote_updated_at: OMIT, remote_created_at: OMIT, tracking_categories: OMIT, posting_date: OMIT, general_ledger_transaction_lines: OMIT, remote_was_deleted: OMIT, field_mappings: OMIT, remote_data: OMIT, additional_properties: nil) @id = id if id != OMIT @remote_id = remote_id if remote_id != OMIT @created_at = created_at if created_at != OMIT @modified_at = modified_at if modified_at != OMIT @underlying_transaction_remote_id = if != OMIT @underlying_transaction_type = if != OMIT @accounting_period = accounting_period if accounting_period != OMIT @company = company if company != OMIT @remote_updated_at = remote_updated_at if remote_updated_at != OMIT @remote_created_at = remote_created_at if remote_created_at != OMIT @tracking_categories = tracking_categories if tracking_categories != OMIT @posting_date = posting_date if posting_date != OMIT @general_ledger_transaction_lines = general_ledger_transaction_lines if general_ledger_transaction_lines != OMIT @remote_was_deleted = remote_was_deleted if remote_was_deleted != OMIT @field_mappings = field_mappings if field_mappings != OMIT @remote_data = remote_data if remote_data != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "remote_id": remote_id, "created_at": created_at, "modified_at": modified_at, "underlying_transaction_remote_id": , "underlying_transaction_type": , "accounting_period": accounting_period, "company": company, "remote_updated_at": remote_updated_at, "remote_created_at": remote_created_at, "tracking_categories": tracking_categories, "posting_date": posting_date, "general_ledger_transaction_lines": general_ledger_transaction_lines, "remote_was_deleted": remote_was_deleted, "field_mappings": field_mappings, "remote_data": remote_data }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#accounting_period ⇒ Merge::Accounting::GeneralLedgerTransactionAccountingPeriod (readonly)
Returns The accounting period that the GeneralLedgerTransaction was generated in.
49 50 51 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 49 def accounting_period @accounting_period end |
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
72 73 74 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 72 def additional_properties @additional_properties end |
#company ⇒ Merge::Accounting::GeneralLedgerTransactionCompany (readonly)
Returns The company the GeneralLedgerTransaction belongs to.
51 52 53 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 51 def company @company end |
#created_at ⇒ DateTime (readonly)
Returns The datetime that this object was created by Merge.
34 35 36 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 34 def created_at @created_at end |
#field_mappings ⇒ Hash{String => Object} (readonly)
68 69 70 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 68 def field_mappings @field_mappings end |
#general_ledger_transaction_lines ⇒ Array<Merge::Accounting::GeneralLedgerTransactionGeneralLedgerTransactionLinesItem> (readonly)
Returns A list of “General Ledger Transaction Applied to Lines” objects.
61 62 63 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 61 def general_ledger_transaction_lines @general_ledger_transaction_lines end |
#id ⇒ String (readonly)
30 31 32 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 30 def id @id end |
#modified_at ⇒ DateTime (readonly)
Returns The datetime that this object was modified by Merge.
36 37 38 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 36 def modified_at @modified_at end |
#posting_date ⇒ DateTime (readonly)
Returns The date that the transaction was posted to the general ledger.
59 60 61 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 59 def posting_date @posting_date end |
#remote_created_at ⇒ DateTime (readonly)
Returns When the third party’s GeneralLedgerTransaction entry was created.
55 56 57 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 55 def remote_created_at @remote_created_at end |
#remote_data ⇒ Array<Merge::Accounting::RemoteData> (readonly)
70 71 72 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 70 def remote_data @remote_data end |
#remote_id ⇒ String (readonly)
Returns The third-party API ID of the matching object.
32 33 34 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 32 def remote_id @remote_id end |
#remote_updated_at ⇒ DateTime (readonly)
Returns When the third party’s GeneralLedgerTransaction entry was updated.
53 54 55 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 53 def remote_updated_at @remote_updated_at end |
#remote_was_deleted ⇒ Boolean (readonly)
Returns Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. [Learn more](docs.merge.dev/integrations/hris/supported-features/).
66 67 68 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 66 def remote_was_deleted @remote_was_deleted end |
#tracking_categories ⇒ Array<Merge::Accounting::GeneralLedgerTransactionTrackingCategoriesItem> (readonly)
57 58 59 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 57 def tracking_categories @tracking_categories end |
#underlying_transaction_remote_id ⇒ String (readonly)
Returns The third party remote ID of the underlying transaction.
38 39 40 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 38 def @underlying_transaction_remote_id end |
#underlying_transaction_type ⇒ Merge::Accounting::UnderlyingTransactionTypeEnum (readonly)
Returns The type of the underlying transaction.
-
‘INVOICE` - INVOICE
-
‘EXPENSE` - EXPENSE
-
‘TRANSACTION` - TRANSACTION
-
‘JOURNAL_ENTRY` - JOURNAL_ENTRY
-
‘PAYMENT` - PAYMENT
-
‘VENDOR_CREDIT` - VENDOR_CREDIT
-
‘CREDIT_NOTE` - CREDIT_NOTE.
47 48 49 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 47 def @underlying_transaction_type end |
Class Method Details
.from_json(json_object:) ⇒ Merge::Accounting::GeneralLedgerTransaction
Deserialize a JSON object to an instance of GeneralLedgerTransaction
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 152 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] remote_id = parsed_json["remote_id"] created_at = (DateTime.parse(parsed_json["created_at"]) unless parsed_json["created_at"].nil?) modified_at = (DateTime.parse(parsed_json["modified_at"]) unless parsed_json["modified_at"].nil?) = parsed_json["underlying_transaction_remote_id"] = parsed_json["underlying_transaction_type"] if parsed_json["accounting_period"].nil? accounting_period = nil else accounting_period = parsed_json["accounting_period"].to_json accounting_period = Merge::Accounting::GeneralLedgerTransactionAccountingPeriod.from_json(json_object: accounting_period) end if parsed_json["company"].nil? company = nil else company = parsed_json["company"].to_json company = Merge::Accounting::GeneralLedgerTransactionCompany.from_json(json_object: company) end remote_updated_at = unless parsed_json["remote_updated_at"].nil? DateTime.parse(parsed_json["remote_updated_at"]) end remote_created_at = unless parsed_json["remote_created_at"].nil? DateTime.parse(parsed_json["remote_created_at"]) end tracking_categories = parsed_json["tracking_categories"]&.map do |item| item = item.to_json Merge::Accounting::GeneralLedgerTransactionTrackingCategoriesItem.from_json(json_object: item) end posting_date = (DateTime.parse(parsed_json["posting_date"]) unless parsed_json["posting_date"].nil?) general_ledger_transaction_lines = parsed_json["general_ledger_transaction_lines"]&.map do |item| item = item.to_json Merge::Accounting::GeneralLedgerTransactionGeneralLedgerTransactionLinesItem.from_json(json_object: item) end remote_was_deleted = parsed_json["remote_was_deleted"] field_mappings = parsed_json["field_mappings"] remote_data = parsed_json["remote_data"]&.map do |item| item = item.to_json Merge::Accounting::RemoteData.from_json(json_object: item) end new( id: id, remote_id: remote_id, created_at: created_at, modified_at: modified_at, underlying_transaction_remote_id: , underlying_transaction_type: , accounting_period: accounting_period, company: company, remote_updated_at: remote_updated_at, remote_created_at: remote_created_at, tracking_categories: tracking_categories, posting_date: posting_date, general_ledger_transaction_lines: general_ledger_transaction_lines, remote_was_deleted: remote_was_deleted, field_mappings: field_mappings, remote_data: remote_data, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 228 def self.validate_raw(obj:) obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.remote_id&.is_a?(String) != false || raise("Passed value for field obj.remote_id is not the expected type, validation failed.") obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") obj.modified_at&.is_a?(DateTime) != false || raise("Passed value for field obj.modified_at is not the expected type, validation failed.") obj.&.is_a?(String) != false || raise("Passed value for field obj.underlying_transaction_remote_id is not the expected type, validation failed.") obj.&.is_a?(Merge::Accounting::UnderlyingTransactionTypeEnum) != false || raise("Passed value for field obj.underlying_transaction_type is not the expected type, validation failed.") obj.accounting_period.nil? || Merge::Accounting::GeneralLedgerTransactionAccountingPeriod.validate_raw(obj: obj.accounting_period) obj.company.nil? || Merge::Accounting::GeneralLedgerTransactionCompany.validate_raw(obj: obj.company) obj.remote_updated_at&.is_a?(DateTime) != false || raise("Passed value for field obj.remote_updated_at is not the expected type, validation failed.") obj.remote_created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.remote_created_at is not the expected type, validation failed.") obj.tracking_categories&.is_a?(Array) != false || raise("Passed value for field obj.tracking_categories is not the expected type, validation failed.") obj.posting_date&.is_a?(DateTime) != false || raise("Passed value for field obj.posting_date is not the expected type, validation failed.") obj.general_ledger_transaction_lines&.is_a?(Array) != false || raise("Passed value for field obj.general_ledger_transaction_lines is not the expected type, validation failed.") obj.remote_was_deleted&.is_a?(Boolean) != false || raise("Passed value for field obj.remote_was_deleted is not the expected type, validation failed.") obj.field_mappings&.is_a?(Hash) != false || raise("Passed value for field obj.field_mappings is not the expected type, validation failed.") obj.remote_data&.is_a?(Array) != false || raise("Passed value for field obj.remote_data is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of GeneralLedgerTransaction to a JSON object
218 219 220 |
# File 'lib/merge_ruby_client/accounting/types/general_ledger_transaction.rb', line 218 def to_json(*_args) @_field_set&.to_json end |