Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YARD docs to Faker::Invoice #2022

Merged
merged 1 commit into from May 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 32 additions & 5 deletions lib/faker/default/invoice.rb
Expand Up @@ -5,7 +5,18 @@ class Invoice < Base
flexible :invoice

class << self
# Generate random amount between values with 2 decimals
##
# Produces a random amount between values with 2 decimals
#
# @param from [Integer] Specifies lower limit.
# @param to [Integer] Specifies upper limit.
# @return [Integer]
#
# @example
# Faker::Finance.amount_between #=> 0
# Faker::Finance.amount_between(0, 10) #=> 4.33
#
# @faker.version 1.9.0
def amount_between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to: 0)
warn_for_deprecated_arguments do |keywords|
keywords << :from if legacy_from != NOT_GIVEN
Expand All @@ -15,8 +26,16 @@ def amount_between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 0, to:
Faker::Base.rand_in_range(from, to).round(2)
end

# International bank slip reference https://en.wikipedia.org/wiki/Creditor_Reference
# ref is optional so that we can create unit tests
##
# Produces a random valid reference accoring to the International bank slip reference https://en.wikipedia.org/wiki/Creditor_Reference
#
# @param ref [String] Specifies reference base.
# @return [String]
#
# @example
# Faker::Invoice.creditor_reference #=> "RF34118592570724925498"
#
# @faker.version 1.9.0
def creditor_reference(legacy_ref = NOT_GIVEN, ref: '')
warn_for_deprecated_arguments do |keywords|
keywords << :ref if legacy_ref != NOT_GIVEN
Expand All @@ -27,8 +46,16 @@ def creditor_reference(legacy_ref = NOT_GIVEN, ref: '')
'RF' + iban_checksum('RF', ref) + ref
end

# Payment references have some rules in certain countries
# ref is optional so that we can create unit tests
##
# Produces a random valid reference.
#
# @param ref [String] Specifies reference base.
# @return [String]
#
# @example
# Faker::Invoice.reference #=> "45656646957845"
#
# @faker.version 1.9.0
def reference(legacy_ref = NOT_GIVEN, ref: '')
warn_for_deprecated_arguments do |keywords|
keywords << :ref if legacy_ref != NOT_GIVEN
Expand Down