spree_zaez_billet 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +14 -0
- data/.rspec +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +11 -0
- data/Guardfile +90 -0
- data/LICENSE +26 -0
- data/README.md +81 -0
- data/Rakefile +21 -0
- data/app/assets/javascripts/spree/backend/app/billet_settings/billet_setting.js.coffee +66 -0
- data/app/assets/javascripts/spree/backend/spree_zaez_billet.js +1 -0
- data/app/assets/javascripts/spree/frontend/spree_zaez_billet.js +2 -0
- data/app/assets/stylesheets/spree/backend/spree_zaez_billet.css +3 -0
- data/app/assets/stylesheets/spree/frontend/spree_zaez_billet.css +4 -0
- data/app/controllers/spree/admin/billet_settings_controller.rb +29 -0
- data/app/controllers/spree/admin/billets_controller.rb +61 -0
- data/app/controllers/spree/billets_controller.rb +35 -0
- data/app/models/spree/address_decorator.rb +17 -0
- data/app/models/spree/billet.rb +257 -0
- data/app/models/spree/payment_method/billet.rb +83 -0
- data/app/overrides/spree/admin/shared/_main_menu/add_payment_tab_to_main_menu.html.erb.deface +6 -0
- data/app/overrides/spree/admin/shared/sub_menu/_configuration/add_billet_settings_tab.html.erb.deface +2 -0
- data/app/overrides/spree/payments/_payment/add_billet_info_to_order_details.html.erb.deface +6 -0
- data/app/views/spree/admin/billet_settings/edit.html.erb +154 -0
- data/app/views/spree/admin/billets/return.html.erb +40 -0
- data/app/views/spree/admin/billets/return_info.html.erb +32 -0
- data/app/views/spree/admin/billets/shipping.html.erb +39 -0
- data/app/views/spree/admin/payments/source_forms/_billet.html.erb +4 -0
- data/app/views/spree/admin/payments/source_views/_billet.html.erb +39 -0
- data/app/views/spree/admin/shared/sub_menu/_payment.html.erb +4 -0
- data/app/views/spree/checkout/payment/_billet.html.erb +4 -0
- data/bin/rails +7 -0
- data/config/locales/en.yml +58 -0
- data/config/locales/pt-br.yml +57 -0
- data/config/routes.rb +13 -0
- data/db/migrate/20150617193744_create_spree_billets.rb +14 -0
- data/lib/generators/spree_zaez_billet/install/install_generator.rb +31 -0
- data/lib/spree/billet_configuration.rb +31 -0
- data/lib/spree_zaez_billet.rb +5 -0
- data/lib/spree_zaez_billet/engine.rb +31 -0
- data/lib/spree_zaez_billet/factories.rb +34 -0
- data/spec/features/admin/billet_payments_spec.rb +85 -0
- data/spec/features/admin/billet_settings_spec.rb +207 -0
- data/spec/features/admin/billets_return_spec.rb +39 -0
- data/spec/features/admin/billets_shipping_spec.rb +87 -0
- data/spec/features/checkout_with_billet_spec.rb +84 -0
- data/spec/fixtures/files/cnab240.ret +16 -0
- data/spec/fixtures/files/cnab400.ret +54 -0
- data/spec/lib/spree/billet_configuration_spec.rb +14 -0
- data/spec/models/spree/address_decorator_spec.rb +13 -0
- data/spec/models/spree/billet_spec.rb +366 -0
- data/spec/spec_helper.rb +95 -0
- data/spec/support/capybara_login.rb +13 -0
- data/spec/support/shared_contexts/checkout_setup.rb +10 -0
- data/spec/support/verify_input_field.rb +16 -0
- data/spree_zaez_billet.gemspec +38 -0
- metadata +72 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 082b30ffaa71c1b7e6c8f6b4196bb6c03f6bff60
|
4
|
+
data.tar.gz: 53e2adb80b39f868e8d0045efe26b6cd7bccbc38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dd53b7e06195e138647cafcda1a27d9c88b8b5793278dcb7835472423ff277e0f981ac743597c1d76fe4dc4edff3e71e9553455e8e07bda87863740e0427bc3
|
7
|
+
data.tar.gz: 545a773aacb03425575bc7a179bff18f61c03df9f97d644913b2229ef9738e71e3786bb31d0ab7679dbf6276b595f9e4e0e7b9024447bba30f834488ab735930
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format documentation --color
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'spree', github: 'spree/spree', branch: '3-0-stable'
|
4
|
+
|
5
|
+
# Provides basic authentication functionality for testing parts of your engine
|
6
|
+
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
|
7
|
+
|
8
|
+
# Fork para a inclusão dos arquivos remessa
|
9
|
+
gem 'brcobranca', github: 'zaeznet/brcobranca'
|
10
|
+
|
11
|
+
gemspec
|
data/Guardfile
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec feature)
|
6
|
+
|
7
|
+
## Uncomment to clear the screen before every task
|
8
|
+
# clearing :on
|
9
|
+
|
10
|
+
## Guard internally checks for changes in the Guardfile and exits.
|
11
|
+
## If you want Guard to automatically start up again, run guard in a
|
12
|
+
## shell loop, e.g.:
|
13
|
+
##
|
14
|
+
## $ while bundle exec guard; do echo "Restarting Guard..."; done
|
15
|
+
##
|
16
|
+
## Note: if you are using the `directories` clause above and you are not
|
17
|
+
## watching the project directory ('.'), the you will want to move the Guardfile
|
18
|
+
## to a watched dir and symlink it back, e.g.
|
19
|
+
#
|
20
|
+
# $ mkdir config
|
21
|
+
# $ mv Guardfile config/
|
22
|
+
# $ ln -s config/Guardfile .
|
23
|
+
#
|
24
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
25
|
+
|
26
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
27
|
+
# rspec may be run, below are examples of the most common uses.
|
28
|
+
# * bundler: 'bundle exec rspec'
|
29
|
+
# * bundler binstubs: 'bin/rspec'
|
30
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
31
|
+
# installed the spring binstubs per the docs)
|
32
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
33
|
+
# * 'just' rspec: 'rspec'
|
34
|
+
|
35
|
+
guard :shell do
|
36
|
+
watch(/^db\/migrate\/.*\.rb/) do |m|
|
37
|
+
puts "#{m[0]} Changed"
|
38
|
+
`bundle exec rake test_app`
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
guard :bundler do
|
43
|
+
watch('Gemfile')
|
44
|
+
# Uncomment next line if Gemfile contain `gemspec' command
|
45
|
+
watch(/^.+\.gemspec/)
|
46
|
+
end
|
47
|
+
|
48
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
49
|
+
require "guard/rspec/dsl"
|
50
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
51
|
+
|
52
|
+
# Feel free to open issues for suggestions and improvements
|
53
|
+
|
54
|
+
# RSpec files
|
55
|
+
rspec = dsl.rspec
|
56
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
57
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
58
|
+
watch(rspec.spec_files)
|
59
|
+
|
60
|
+
# Ruby files
|
61
|
+
ruby = dsl.ruby
|
62
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
63
|
+
|
64
|
+
# Rails files
|
65
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
66
|
+
dsl.watch_spec_files_for(rails.app_files)
|
67
|
+
dsl.watch_spec_files_for(rails.views)
|
68
|
+
|
69
|
+
watch(rails.controllers) do |m|
|
70
|
+
[
|
71
|
+
rspec.spec.("routing/#{m[1]}_routing"),
|
72
|
+
rspec.spec.("controllers/#{m[1]}_controller"),
|
73
|
+
rspec.spec.("acceptance/#{m[1]}")
|
74
|
+
]
|
75
|
+
end
|
76
|
+
|
77
|
+
# Rails config changes
|
78
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
79
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
80
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
81
|
+
|
82
|
+
# Capybara features specs
|
83
|
+
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
|
84
|
+
|
85
|
+
# Turnip features and steps
|
86
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
87
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
88
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
89
|
+
end
|
90
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2015 Zaez Inovação Digital
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
Spree Billet [![Build Status](https://travis-ci.org/zaeznet/spree_zaez_billet.svg?branch=master)](https://travis-ci.org/zaeznet/spree_zaez_billet)
|
2
|
+
===============
|
3
|
+
|
4
|
+
Extension to add the functionalities of billets to Spree Commerce.
|
5
|
+
This extension uses the gem [brcobranca](https://github.com/kivanio/brcobranca) to generate the billet, the shipping file and read the return file.
|
6
|
+
To documentation and additional information about generation, see the [fork of Zaez](https://github.com/zaeznet/brcobranca) about that.
|
7
|
+
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
|
11
|
+
Add spree_zaez_billet to your Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'spree_zaez_billet', github: 'zaeznet/spree_zaez_billet'
|
15
|
+
```
|
16
|
+
|
17
|
+
Bundle your dependencies and run the installation generator:
|
18
|
+
|
19
|
+
```shell
|
20
|
+
bundle
|
21
|
+
bundle exec rails g spree_zaez_billet:install
|
22
|
+
```
|
23
|
+
|
24
|
+
Banks
|
25
|
+
------------
|
26
|
+
|
27
|
+
The banks and types of files supported for this extension are:
|
28
|
+
|
29
|
+
### Billet
|
30
|
+
* Banco do Brasil;
|
31
|
+
* Itaú;
|
32
|
+
* Bradesco;
|
33
|
+
* Caixa;
|
34
|
+
* Santander Banespa;
|
35
|
+
* HSBC;
|
36
|
+
* Sicredi.
|
37
|
+
|
38
|
+
See the docs to [available wallets](https://github.com/zaeznet/brcobranca).
|
39
|
+
|
40
|
+
### Shipping File (arquivo remessa)
|
41
|
+
* Banco do Brasil (CNAB240);
|
42
|
+
* Caixa (CNAB240);
|
43
|
+
* Itaú (CNAB400);
|
44
|
+
* Bradesco (CNAB400).
|
45
|
+
|
46
|
+
See the docs to [configure the information](https://github.com/zaeznet/brcobranca/wiki).
|
47
|
+
|
48
|
+
### Return file (arquivo retorno)
|
49
|
+
* CNAB400;
|
50
|
+
* CNAB240;
|
51
|
+
* CBR643.
|
52
|
+
|
53
|
+
|
54
|
+
Settings
|
55
|
+
------------
|
56
|
+
|
57
|
+
To configure the settings, you can go to admin/billet_settings page, or in an initialize file you can modify the settings like that:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
Spree::BilletConfig[:account] = '1234'
|
61
|
+
```
|
62
|
+
|
63
|
+
|
64
|
+
Testing
|
65
|
+
-------
|
66
|
+
|
67
|
+
First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using `rake test_app`.
|
68
|
+
|
69
|
+
```shell
|
70
|
+
bundle
|
71
|
+
bundle exec rake
|
72
|
+
```
|
73
|
+
|
74
|
+
When testing your applications integration with this extension you may use it's factories.
|
75
|
+
Simply add this require statement to your spec_helper:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
require 'spree_zaez_billet/factories'
|
79
|
+
```
|
80
|
+
|
81
|
+
Copyright (c) 2015 Zaez Inovação Digital, released under the New BSD License
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'spree/testing_support/extension_rake'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new
|
8
|
+
|
9
|
+
task :default do
|
10
|
+
if Dir["spec/dummy"].empty?
|
11
|
+
Rake::Task[:test_app].invoke
|
12
|
+
Dir.chdir("../../")
|
13
|
+
end
|
14
|
+
Rake::Task[:spec].invoke
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Generates a dummy app for testing'
|
18
|
+
task :test_app do
|
19
|
+
ENV['LIB_NAME'] = 'spree_zaez_billet'
|
20
|
+
Rake::Task['extension:test_app'].invoke
|
21
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#= require_self
|
2
|
+
class window.BilletSetting
|
3
|
+
afterConstructor: ->
|
4
|
+
|
5
|
+
beforeConstructor: ->
|
6
|
+
|
7
|
+
constructor: (defaultExecution = true) ->
|
8
|
+
do @beforeConstructor
|
9
|
+
do @defaultExecution if defaultExecution
|
10
|
+
do @afterConstructor
|
11
|
+
|
12
|
+
defaultExecution: ->
|
13
|
+
@setBankForm()
|
14
|
+
$('#bank').change => do @setBankForm
|
15
|
+
|
16
|
+
# Verifica qual banco foi selecionado
|
17
|
+
# e monta o formulario dele
|
18
|
+
setBankForm: ->
|
19
|
+
switch $('#bank').val()
|
20
|
+
when 'banco_brasil' then @setBancoBrasil()
|
21
|
+
when 'caixa' then @setCaixa()
|
22
|
+
when 'itau' then @setItau()
|
23
|
+
when 'bradesco' then @setBradesco()
|
24
|
+
when 'hsbc' then @setHsbc()
|
25
|
+
when 'santander' then @setSantander()
|
26
|
+
when 'sicredi' then @setSicredi()
|
27
|
+
else @clearForm()
|
28
|
+
|
29
|
+
# Exibe os campos utilizados pelo Banco do Brasil
|
30
|
+
setBancoBrasil: ->
|
31
|
+
@clearForm()
|
32
|
+
$('#agreement_box, #wallet_box, #variation_wallet_box').show()
|
33
|
+
|
34
|
+
# Exibe os campos utilizados pela Caixa
|
35
|
+
setCaixa: ->
|
36
|
+
@clearForm()
|
37
|
+
$('#agreement_box, #account_digit_box, #app_version_box').show()
|
38
|
+
|
39
|
+
# Exibe os campos utilizados pelo Itau
|
40
|
+
setItau: ->
|
41
|
+
@clearForm()
|
42
|
+
$('#account_digit_box, #wallet_box, #agreement_box').show()
|
43
|
+
|
44
|
+
# Exibe os campos utilizados pelo Bradesco
|
45
|
+
setBradesco: ->
|
46
|
+
@clearForm()
|
47
|
+
$('#account_digit_box, #wallet_box, #company_code_box').show()
|
48
|
+
|
49
|
+
# Exibe os campos utilizados pelo HSBC
|
50
|
+
setHsbc: ->
|
51
|
+
@clearForm()
|
52
|
+
$('#wallet_box').show()
|
53
|
+
|
54
|
+
# Exibe os campos utilizados pelo Santander Banespa
|
55
|
+
setSantander: ->
|
56
|
+
@clearForm()
|
57
|
+
$('#wallet_box, #agreement_box').show()
|
58
|
+
|
59
|
+
# Exibe os campos utilizados pelo Sicredi
|
60
|
+
setSicredi: ->
|
61
|
+
@clearForm()
|
62
|
+
$('#wallet_box, #byte_idt_box, #office_code_box').show()
|
63
|
+
|
64
|
+
# Esconde todos os campos que nao sao comum a todos os bancos
|
65
|
+
clearForm: ->
|
66
|
+
$('#account_digit_box, #agreement_box, #wallet_box, #variation_wallet_box, #app_version_box, #company_code_box, #office_code_box, #byte_idt_box').hide()
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require ./app/billet_settings/billet_setting
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Spree::Admin::BilletSettingsController < Spree::Admin::BaseController
|
2
|
+
|
3
|
+
def edit
|
4
|
+
@config = Spree::BilletConfiguration.new
|
5
|
+
@banks = [:banco_brasil, :itau, :caixa, :hsbc, :bradesco, :santander, :sicredi]
|
6
|
+
@user_attr = Spree::User.new.attribute_names.sort_by { |item| item }
|
7
|
+
end
|
8
|
+
|
9
|
+
def update
|
10
|
+
config = Spree::BilletConfiguration.new
|
11
|
+
|
12
|
+
params.each do |name, value|
|
13
|
+
next unless config.has_preference?(name)
|
14
|
+
config[name] = value
|
15
|
+
end
|
16
|
+
|
17
|
+
config.registered = false unless params.include?(:registered)
|
18
|
+
|
19
|
+
flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:billet_settings))
|
20
|
+
redirect_to edit_admin_billet_settings_path
|
21
|
+
end
|
22
|
+
|
23
|
+
def clear_shipping
|
24
|
+
Spree::BilletConfig.shipping_number = 1
|
25
|
+
flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:billet_settings))
|
26
|
+
redirect_to edit_admin_billet_settings_path
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class Spree::Admin::BilletsController < Spree::Admin::BaseController
|
2
|
+
|
3
|
+
def shipping
|
4
|
+
@billets = Spree::Billet.unregistered
|
5
|
+
end
|
6
|
+
|
7
|
+
def register
|
8
|
+
shipping = Spree::Billet.generate_shipping
|
9
|
+
if shipping.is_a? String
|
10
|
+
# formats the name of the file
|
11
|
+
name = ''
|
12
|
+
name << 'C' + Spree::BilletConfig.bank[0].upcase
|
13
|
+
name << Date.today.day.to_s.rjust(2, '0')
|
14
|
+
name << Date.today.month.to_s.rjust(2, '0')
|
15
|
+
name << SecureRandom.hex(1).upcase
|
16
|
+
name
|
17
|
+
|
18
|
+
send_data shipping, :content_type => 'text/plain', :filename => "#{name}.rem"
|
19
|
+
else
|
20
|
+
flash[:error] = Spree.t("errors.#{shipping[:reason]}")
|
21
|
+
redirect_to :admin_billets_shipping
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# def return
|
26
|
+
# end
|
27
|
+
|
28
|
+
def return_info
|
29
|
+
data = case params[:file_type].to_sym
|
30
|
+
when :cnab240 then Brcobranca::Retorno::RetornoCnab240.load_lines params[:file].path
|
31
|
+
when :cnab400 then Brcobranca::Retorno::RetornoCnab400.load_lines params[:file].path
|
32
|
+
when :cbr643 then Brcobranca::Retorno::RetornoCbr643.load_lines params[:file].path
|
33
|
+
end
|
34
|
+
|
35
|
+
@lines = []
|
36
|
+
data.each do |line|
|
37
|
+
# se for o registro trailer passa para a proxima iteracao
|
38
|
+
next if line == data.last
|
39
|
+
payment = Spree::Payment.find_by id: line.nosso_numero
|
40
|
+
|
41
|
+
if payment and line.valor_recebido.to_i > 0 and !(payment.completed? or payment.void?)
|
42
|
+
amount_paid = line.valor_recebido.to_f + line.valor_tarifa.to_f
|
43
|
+
payment.capture! amount_paid
|
44
|
+
|
45
|
+
# formats the date
|
46
|
+
year = line.data_credito.size == 6 ? line.data_credito : "20#{line.data_credito}"
|
47
|
+
paid_at = "#{year}#{line.data_credito[2..3]}#{line.data_credito[0..1]}".to_date
|
48
|
+
# formats the value
|
49
|
+
value = (line.valor_titulo.to_f / 100) + (line.valor_tarifa.to_f / 100)
|
50
|
+
|
51
|
+
@lines.push({document_number: line.nosso_numero,
|
52
|
+
value: Spree::Money.new(value, { currency: payment.currency }),
|
53
|
+
paid_at: paid_at,
|
54
|
+
order_id: payment.order_id,
|
55
|
+
order_number: payment.order.number})
|
56
|
+
end
|
57
|
+
end
|
58
|
+
# rescue
|
59
|
+
# flash[:error] = Spree.t('errors.error_in_billets_return')
|
60
|
+
end
|
61
|
+
end
|