Class: StarkInfra::CreditNotePreview
- Inherits:
-
StarkCore::Utils::SubResource
- Object
- StarkCore::Utils::SubResource
- StarkInfra::CreditNotePreview
- Defined in:
- lib/credit_preview/credit_note_preview.rb
Overview
# CreditNotePreview object
A CreditNotePreview is used to preview a CCB contract between the borrower and lender with a specific table type.
When you initialize a CreditPreview, the entity will not be automatically created in the Stark Infra API. The ‘create’ function sends the objects to the Stark Infra API and returns the list of created objects.
## Parameters (required):
-
type [string]: table type that defines the amortization system. Options: ‘sac’, ‘price’, ‘american’, ‘bullet’, ‘custom’
-
nominal_amount [integer]: amount in cents transferred to the credit receiver, before deductions. ex: 11234 (= R$ 112.34)
-
scheduled [DateTime, Date or string]: date of transfer execution. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
-
tax_id [string]: credit receiver’s tax ID (CPF or CNPJ). ex: ‘20.018.183/0001-80’
## Parameters (conditionally required):
-
invoices [list of CreditNote::Invoice objects]: list of CreditNote.Invoice objects to be created and sent to the credit receiver.
-
nominal_interest [float]: yearly nominal interest rate of the credit note, in percentage. ex: 12.5
-
initial_due [DateTime, Date or string]: date of the first invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0), Date.new(2020, 3, 10) or ‘2020-03-10’
-
count [integer]: quantity of invoices for payment. ex: 12
-
initial_amount [integer]: value of the first invoice in cents. ex: 1234 (= R$12.34)
-
interval [string]: interval between invoices. ex: ‘year’, ‘month’
## Parameters (optional):
-
rebate_amount [integer, default nil]: credit analysis fee deducted from lent amount. ex: 11234 (= R$ 112.34)
## Attributes (return-only):
-
amount [integer]: credit note value in cents. ex: 1234 (= R$ 12.34)
-
interest [float]: yearly effective interest rate of the credit note, in percentage. ex: 12.5
-
tax_amount [integer]: tax amount included in the credit note. ex: 100
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#initial_amount ⇒ Object
readonly
Returns the value of attribute initial_amount.
-
#initial_due ⇒ Object
readonly
Returns the value of attribute initial_due.
-
#interest ⇒ Object
readonly
Returns the value of attribute interest.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#invoices ⇒ Object
readonly
Returns the value of attribute invoices.
-
#nominal_amount ⇒ Object
readonly
Returns the value of attribute nominal_amount.
-
#nominal_interest ⇒ Object
readonly
Returns the value of attribute nominal_interest.
-
#rebate_amount ⇒ Object
readonly
Returns the value of attribute rebate_amount.
-
#scheduled ⇒ Object
readonly
Returns the value of attribute scheduled.
-
#tax_amount ⇒ Object
readonly
Returns the value of attribute tax_amount.
-
#tax_id ⇒ Object
readonly
Returns the value of attribute tax_id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type:, nominal_amount:, scheduled:, tax_id:, invoices: nil, nominal_interest: nil, initial_due: nil, count: nil, initial_amount: nil, interval: nil, rebate_amount: nil, amount: nil, interest: nil, tax_amount: nil) ⇒ CreditNotePreview
constructor
A new instance of CreditNotePreview.
Constructor Details
#initialize(type:, nominal_amount:, scheduled:, tax_id:, invoices: nil, nominal_interest: nil, initial_due: nil, count: nil, initial_amount: nil, interval: nil, rebate_amount: nil, amount: nil, interest: nil, tax_amount: nil) ⇒ CreditNotePreview
Returns a new instance of CreditNotePreview.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/credit_preview/credit_note_preview.rb', line 39 def initialize( type:, nominal_amount:, scheduled:, tax_id:, invoices: nil, nominal_interest: nil, initial_due: nil, count: nil, initial_amount: nil, interval: nil, rebate_amount: nil, amount: nil, interest: nil, tax_amount: nil ) @type = type @nominal_amount = nominal_amount @scheduled = scheduled @tax_id = tax_id @invoices = Invoice.parse_invoices(invoices) @nominal_interest = nominal_interest @initial_due = initial_due @count = count @initial_amount = initial_amount @interval = interval @rebate_amount = rebate_amount @amount = amount @interest = interest @tax_amount = tax_amount end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
37 38 39 |
# File 'lib/credit_preview/credit_note_preview.rb', line 37 def amount @amount end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
37 38 39 |
# File 'lib/credit_preview/credit_note_preview.rb', line 37 def count @count end |
#initial_amount ⇒ Object (readonly)
Returns the value of attribute initial_amount.
37 38 39 |
# File 'lib/credit_preview/credit_note_preview.rb', line 37 def initial_amount @initial_amount end |
#initial_due ⇒ Object (readonly)
Returns the value of attribute initial_due.
37 38 39 |
# File 'lib/credit_preview/credit_note_preview.rb', line 37 def initial_due @initial_due end |
#interest ⇒ Object (readonly)
Returns the value of attribute interest.
37 38 39 |
# File 'lib/credit_preview/credit_note_preview.rb', line 37 def interest @interest end |
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
37 38 39 |
# File 'lib/credit_preview/credit_note_preview.rb', line 37 def interval @interval end |
#invoices ⇒ Object (readonly)
Returns the value of attribute invoices.
37 38 39 |
# File 'lib/credit_preview/credit_note_preview.rb', line 37 def invoices @invoices end |
#nominal_amount ⇒ Object (readonly)
Returns the value of attribute nominal_amount.
37 38 39 |
# File 'lib/credit_preview/credit_note_preview.rb', line 37 def nominal_amount @nominal_amount end |
#nominal_interest ⇒ Object (readonly)
Returns the value of attribute nominal_interest.
37 38 39 |
# File 'lib/credit_preview/credit_note_preview.rb', line 37 def nominal_interest @nominal_interest end |
#rebate_amount ⇒ Object (readonly)
Returns the value of attribute rebate_amount.
37 38 39 |
# File 'lib/credit_preview/credit_note_preview.rb', line 37 def rebate_amount @rebate_amount end |
#scheduled ⇒ Object (readonly)
Returns the value of attribute scheduled.
37 38 39 |
# File 'lib/credit_preview/credit_note_preview.rb', line 37 def scheduled @scheduled end |
#tax_amount ⇒ Object (readonly)
Returns the value of attribute tax_amount.
37 38 39 |
# File 'lib/credit_preview/credit_note_preview.rb', line 37 def tax_amount @tax_amount end |
#tax_id ⇒ Object (readonly)
Returns the value of attribute tax_id.
37 38 39 |
# File 'lib/credit_preview/credit_note_preview.rb', line 37 def tax_id @tax_id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
37 38 39 |
# File 'lib/credit_preview/credit_note_preview.rb', line 37 def type @type end |
Class Method Details
.resource ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/credit_preview/credit_note_preview.rb', line 60 def self.resource { resource_name: 'CreditNotePreview', resource_maker: proc { |json| CreditNotePreview.new( type: json['type'], nominal_amount: json['nominal_amount'], scheduled: json['scheduled'], tax_id: json['tax_id'], invoices: json['invoices'], nominal_interest: json['nominal_interest'], initial_due: json['initial_due'], count: json['count'], initial_amount: json['initial_amount'], interval: json['interval'], rebate_amount: json['rebate_amount'], amount: json['amount'], interest: json['interest'], tax_amount: json['tax_amount'] ) } } end |