{"action":"created","comment":{"url":"https://api.github.com/repos/kivanio/brcobranca/pulls/comments/49885479","id":49885479,"diff_hunk":"@@ -0,0 +1,109 @@\n+# -*- encoding: utf-8 -*-\n+module Brcobranca\n+  module Boleto\n+    class Mercantil < Base # Banco Mercantil\n+\n+      validates_length_of :agencia, :maximum => 4, :message => \"deve ser menor ou igual a 4 dígitos.\"\n+      validates_length_of :conta_corrente, :maximum => 8, :message => \"deve ser menor ou igual a 8 dígitos.\"\n+      validates_length_of :carteira, :maximum => 2, :message => \"deve ser menor ou igual a 2 dígitos.\"\n+      validates_length_of :numero_documento, :maximum => 11, :message => \"deve ser menor ou igual a 11 dígitos.\"\n+      validates_presence_of :conta_corrente, :message => \"não pode ser branco\"\n+\n+      # Nova instancia do Banco Mercantil\n+      # @param (see Brcobranca::Boleto::Base#initialize)\n+      def initialize(campos={})\n+        campos = {:carteira => \"06\", :codigo_servico => false,\n+            :especie_documento => \"DM\", :especie => \"R$\", \n+            :local_pagamento => \"PAGÁVEL EM QUALQUER AGÊNCIA BANCÁRIA ATÉ O VENCIMENTO\",\n+            :data_processamento => Date.today\n+          }.merge!(campos)\n+        super(campos)\n+      end\n+\n+      # Codigo do banco emissor (3 dígitos sempre)\n+      #\n+      # @return [String] 3 caracteres numéricos.\n+      def banco\n+        \"389\"\n+      end\n+\n+      # Carteira\n+      #\n+      # @return [String] 2 caracteres numéricos.\n+      def carteira=(valor)\n+        @carteira = valor.to_s.rjust(2,'0') unless valor.nil?\n+      end\n+\n+      # Número seqüencial utilizado para identificar o boleto.\n+      # @return [String] 10 caracteres numéricos.\n+      def numero_documento=(valor)\n+        @numero_documento = valor.to_s.rjust(10,'0') unless valor.nil?\n+      end\n+\n+      # Dígito verificador do nosso número.\n+      # @return [String] 1 caracteres numéricos.\n+      # @see #numero_documento\n+      def nosso_numero_dv\n+        #QUANDO FOR O CÁLCULO DO NOSSO NÚMERO USAR => SE RESTO FOR IGUAL A 0(ZERO) OU 1(UM) \n+        #O DIGITO DEVERÁ SER 0(ZERO), CASO CONTRÁRIO, O DIGITO SERÁ A DIFERENÇA ENTRE 11 E O RESTO.\n+        \"#{self.agencia}#{self.numero_documento}\".modulo11_mercantil { |valor| [0,1].include?(valor) ? 0 : (11 - valor) }\n+      end\n+\n+      # Nosso número para exibir no boleto.\n+      # @return [String]\n+      # @example\n+      #  boleto.nosso_numero_boleto #=> \"11600051123\"\n+      def nosso_numero_boleto\n+        \"#{self.numero_documento}-#{nosso_numero_dv}\"\n+      end\n+\n+      # Agência + conta corrente do cliente para exibir no boleto.\n+      # @return [String]\n+      # @example\n+      #  boleto.agencia_conta_boleto #=> \"0548 / 000014486\"\n+      def agencia_conta_boleto\n+        \"#{self.agencia} / #{self.conta_corrente.to_s.rjust(9,'0')}\"\n+      end\n+\n+      # Conta corrente\n+      # @return [String] 8 caracteres numéricos.\n+      def conta_corrente=(valor)\n+        @conta_corrente = valor.to_s.rjust(8,'0') unless valor.nil?\n+      end\n+\n+      # Segunda parte do código de barras.\n+      # @return [String] 25 caracteres numéricos.\n+      def codigo_barras_segunda_parte\n+        \"#{self.agencia}#{nosso_numero}#{numero_contrato}2\"\n+      end\n+      \n+      def dac_recebe\n+        #QUANDO FOR O CÁLCULO DO DAC USAR => SE RESTO FOR IGUAL A 0(ZERO) OU 1(UM) \n+        #O DIGITO DEVERÁ SER 1(UM), CASO CONTRÁRIO, O DIGITO SERÁ A DIFERENÇA ENTRE 11 E O RESTO.\n+        \"#{self.banco}#{self.moeda}#{self.fator_vencimento}#{valor_documento_formatado}#{self.agencia}#{self.numero_documento}#{nosso_numero_dv}#{numero_contrato}2\".modulo11_mercantil { |valor| [0,1].include?(valor) ? 1 : (11 - valor) }\n+      end\n+      ","path":"lib/brcobranca/boleto/mercantil.rb","position":85,"original_position":85,"commit_id":"4f306ad852120a8a9d59132867f0b15b565d30b1","original_commit_id":"4f306ad852120a8a9d59132867f0b15b565d30b1","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Trailing whitespace detected.","created_at":"2016-01-15T18:16:47Z","updated_at":"2016-01-15T18:16:47Z","html_url":"https://github.com/kivanio/brcobranca/pull/115#discussion_r49885479","pull_request_url":"https://api.github.com/repos/kivanio/brcobranca/pulls/115","_links":{"self":{"href":"https://api.github.com/repos/kivanio/brcobranca/pulls/comments/49885479"},"html":{"href":"https://github.com/kivanio/brcobranca/pull/115#discussion_r49885479"},"pull_request":{"href":"https://api.github.com/repos/kivanio/brcobranca/pulls/115"}}},"pull_request":{"url":"https://api.github.com/repos/kivanio/brcobranca/pulls/115","id":53845233,"html_url":"https://github.com/kivanio/brcobranca/pull/115","diff_url":"https://github.com/kivanio/brcobranca/pull/115.diff","patch_url":"https://github.com/kivanio/brcobranca/pull/115.patch","issue_url":"https://api.github.com/repos/kivanio/brcobranca/issues/115","number":115,"state":"open","locked":false,"title":"Inclusão de Boleto Mercantil","user":{"login":"lesio","id":389829,"avatar_url":"https://avatars.githubusercontent.com/u/389829?v=3","gravatar_id":"","url":"https://api.github.com/users/lesio","html_url":"https://github.com/lesio","followers_url":"https://api.github.com/users/lesio/followers","following_url":"https://api.github.com/users/lesio/following{/other_user}","gists_url":"https://api.github.com/users/lesio/gists{/gist_id}","starred_url":"https://api.github.com/users/lesio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lesio/subscriptions","organizations_url":"https://api.github.com/users/lesio/orgs","repos_url":"https://api.github.com/users/lesio/repos","events_url":"https://api.github.com/users/lesio/events{/privacy}","received_events_url":"https://api.github.com/users/lesio/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-16T14:08:28Z","updated_at":"2016-01-15T18:16:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kivanio/brcobranca/pulls/115/commits","review_comments_url":"https://api.github.com/repos/kivanio/brcobranca/pulls/115/comments","review_comment_url":"https://api.github.com/repos/kivanio/brcobranca/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kivanio/brcobranca/issues/115/comments","statuses_url":"https://api.github.com/repos/kivanio/brcobranca/statuses/4f306ad852120a8a9d59132867f0b15b565d30b1","head":{"label":"lesio:master","ref":"master","sha":"4f306ad852120a8a9d59132867f0b15b565d30b1","user":{"login":"lesio","id":389829,"avatar_url":"https://avatars.githubusercontent.com/u/389829?v=3","gravatar_id":"","url":"https://api.github.com/users/lesio","html_url":"https://github.com/lesio","followers_url":"https://api.github.com/users/lesio/followers","following_url":"https://api.github.com/users/lesio/following{/other_user}","gists_url":"https://api.github.com/users/lesio/gists{/gist_id}","starred_url":"https://api.github.com/users/lesio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lesio/subscriptions","organizations_url":"https://api.github.com/users/lesio/orgs","repos_url":"https://api.github.com/users/lesio/repos","events_url":"https://api.github.com/users/lesio/events{/privacy}","received_events_url":"https://api.github.com/users/lesio/received_events","type":"User","site_admin":false},"repo":{"id":2882865,"name":"brcobranca","full_name":"lesio/brcobranca","owner":{"login":"lesio","id":389829,"avatar_url":"https://avatars.githubusercontent.com/u/389829?v=3","gravatar_id":"","url":"https://api.github.com/users/lesio","html_url":"https://github.com/lesio","followers_url":"https://api.github.com/users/lesio/followers","following_url":"https://api.github.com/users/lesio/following{/other_user}","gists_url":"https://api.github.com/users/lesio/gists{/gist_id}","starred_url":"https://api.github.com/users/lesio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lesio/subscriptions","organizations_url":"https://api.github.com/users/lesio/orgs","repos_url":"https://api.github.com/users/lesio/repos","events_url":"https://api.github.com/users/lesio/events{/privacy}","received_events_url":"https://api.github.com/users/lesio/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lesio/brcobranca","description":"Gem para emissão de bloquetos de cobrança para bancos brasileiros","fork":true,"url":"https://api.github.com/repos/lesio/brcobranca","forks_url":"https://api.github.com/repos/lesio/brcobranca/forks","keys_url":"https://api.github.com/repos/lesio/brcobranca/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lesio/brcobranca/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lesio/brcobranca/teams","hooks_url":"https://api.github.com/repos/lesio/brcobranca/hooks","issue_events_url":"https://api.github.com/repos/lesio/brcobranca/issues/events{/number}","events_url":"https://api.github.com/repos/lesio/brcobranca/events","assignees_url":"https://api.github.com/repos/lesio/brcobranca/assignees{/user}","branches_url":"https://api.github.com/repos/lesio/brcobranca/branches{/branch}","tags_url":"https://api.github.com/repos/lesio/brcobranca/tags","blobs_url":"https://api.github.com/repos/lesio/brcobranca/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lesio/brcobranca/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lesio/brcobranca/git/refs{/sha}","trees_url":"https://api.github.com/repos/lesio/brcobranca/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lesio/brcobranca/statuses/{sha}","languages_url":"https://api.github.com/repos/lesio/brcobranca/languages","stargazers_url":"https://api.github.com/repos/lesio/brcobranca/stargazers","contributors_url":"https://api.github.com/repos/lesio/brcobranca/contributors","subscribers_url":"https://api.github.com/repos/lesio/brcobranca/subscribers","subscription_url":"https://api.github.com/repos/lesio/brcobranca/subscription","commits_url":"https://api.github.com/repos/lesio/brcobranca/commits{/sha}","git_commits_url":"https://api.github.com/repos/lesio/brcobranca/git/commits{/sha}","comments_url":"https://api.github.com/repos/lesio/brcobranca/comments{/number}","issue_comment_url":"https://api.github.com/repos/lesio/brcobranca/issues/comments{/number}","contents_url":"https://api.github.com/repos/lesio/brcobranca/contents/{+path}","compare_url":"https://api.github.com/repos/lesio/brcobranca/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lesio/brcobranca/merges","archive_url":"https://api.github.com/repos/lesio/brcobranca/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lesio/brcobranca/downloads","issues_url":"https://api.github.com/repos/lesio/brcobranca/issues{/number}","pulls_url":"https://api.github.com/repos/lesio/brcobranca/pulls{/number}","milestones_url":"https://api.github.com/repos/lesio/brcobranca/milestones{/number}","notifications_url":"https://api.github.com/repos/lesio/brcobranca/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lesio/brcobranca/labels{/name}","releases_url":"https://api.github.com/repos/lesio/brcobranca/releases{/id}","created_at":"2011-11-30T12:26:09Z","updated_at":"2014-11-14T17:13:50Z","pushed_at":"2016-01-15T18:16:42Z","git_url":"git://github.com/lesio/brcobranca.git","ssh_url":"git@github.com:lesio/brcobranca.git","clone_url":"https://github.com/lesio/brcobranca.git","svn_url":"https://github.com/lesio/brcobranca","homepage":"http://rubygems.org/gems/brcobranca","size":1038,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"kivanio:master","ref":"master","sha":"2813b91b2b5435e02628e9be00940398b06c5037","user":{"login":"kivanio","id":5107,"avatar_url":"https://avatars.githubusercontent.com/u/5107?v=3","gravatar_id":"","url":"https://api.github.com/users/kivanio","html_url":"https://github.com/kivanio","followers_url":"https://api.github.com/users/kivanio/followers","following_url":"https://api.github.com/users/kivanio/following{/other_user}","gists_url":"https://api.github.com/users/kivanio/gists{/gist_id}","starred_url":"https://api.github.com/users/kivanio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kivanio/subscriptions","organizations_url":"https://api.github.com/users/kivanio/orgs","repos_url":"https://api.github.com/users/kivanio/repos","events_url":"https://api.github.com/users/kivanio/events{/privacy}","received_events_url":"https://api.github.com/users/kivanio/received_events","type":"User","site_admin":false},"repo":{"id":165755,"name":"brcobranca","full_name":"kivanio/brcobranca","owner":{"login":"kivanio","id":5107,"avatar_url":"https://avatars.githubusercontent.com/u/5107?v=3","gravatar_id":"","url":"https://api.github.com/users/kivanio","html_url":"https://github.com/kivanio","followers_url":"https://api.github.com/users/kivanio/followers","following_url":"https://api.github.com/users/kivanio/following{/other_user}","gists_url":"https://api.github.com/users/kivanio/gists{/gist_id}","starred_url":"https://api.github.com/users/kivanio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kivanio/subscriptions","organizations_url":"https://api.github.com/users/kivanio/orgs","repos_url":"https://api.github.com/users/kivanio/repos","events_url":"https://api.github.com/users/kivanio/events{/privacy}","received_events_url":"https://api.github.com/users/kivanio/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kivanio/brcobranca","description":"Emissão de bloquetos de cobrança para bancos brasileiros","fork":false,"url":"https://api.github.com/repos/kivanio/brcobranca","forks_url":"https://api.github.com/repos/kivanio/brcobranca/forks","keys_url":"https://api.github.com/repos/kivanio/brcobranca/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kivanio/brcobranca/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kivanio/brcobranca/teams","hooks_url":"https://api.github.com/repos/kivanio/brcobranca/hooks","issue_events_url":"https://api.github.com/repos/kivanio/brcobranca/issues/events{/number}","events_url":"https://api.github.com/repos/kivanio/brcobranca/events","assignees_url":"https://api.github.com/repos/kivanio/brcobranca/assignees{/user}","branches_url":"https://api.github.com/repos/kivanio/brcobranca/branches{/branch}","tags_url":"https://api.github.com/repos/kivanio/brcobranca/tags","blobs_url":"https://api.github.com/repos/kivanio/brcobranca/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kivanio/brcobranca/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kivanio/brcobranca/git/refs{/sha}","trees_url":"https://api.github.com/repos/kivanio/brcobranca/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kivanio/brcobranca/statuses/{sha}","languages_url":"https://api.github.com/repos/kivanio/brcobranca/languages","stargazers_url":"https://api.github.com/repos/kivanio/brcobranca/stargazers","contributors_url":"https://api.github.com/repos/kivanio/brcobranca/contributors","subscribers_url":"https://api.github.com/repos/kivanio/brcobranca/subscribers","subscription_url":"https://api.github.com/repos/kivanio/brcobranca/subscription","commits_url":"https://api.github.com/repos/kivanio/brcobranca/commits{/sha}","git_commits_url":"https://api.github.com/repos/kivanio/brcobranca/git/commits{/sha}","comments_url":"https://api.github.com/repos/kivanio/brcobranca/comments{/number}","issue_comment_url":"https://api.github.com/repos/kivanio/brcobranca/issues/comments{/number}","contents_url":"https://api.github.com/repos/kivanio/brcobranca/contents/{+path}","compare_url":"https://api.github.com/repos/kivanio/brcobranca/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kivanio/brcobranca/merges","archive_url":"https://api.github.com/repos/kivanio/brcobranca/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kivanio/brcobranca/downloads","issues_url":"https://api.github.com/repos/kivanio/brcobranca/issues{/number}","pulls_url":"https://api.github.com/repos/kivanio/brcobranca/pulls{/number}","milestones_url":"https://api.github.com/repos/kivanio/brcobranca/milestones{/number}","notifications_url":"https://api.github.com/repos/kivanio/brcobranca/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kivanio/brcobranca/labels{/name}","releases_url":"https://api.github.com/repos/kivanio/brcobranca/releases{/id}","created_at":"2009-04-02T02:03:17Z","updated_at":"2016-01-05T01:45:52Z","pushed_at":"2016-01-15T18:16:43Z","git_url":"git://github.com/kivanio/brcobranca.git","ssh_url":"git@github.com:kivanio/brcobranca.git","clone_url":"https://github.com/kivanio/brcobranca.git","svn_url":"https://github.com/kivanio/brcobranca","homepage":"https://brcobranca.herokuapp.com/","size":4485,"stargazers_count":218,"watchers_count":218,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":121,"mirror_url":null,"open_issues_count":8,"forks":121,"open_issues":8,"watchers":218,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kivanio/brcobranca/pulls/115"},"html":{"href":"https://github.com/kivanio/brcobranca/pull/115"},"issue":{"href":"https://api.github.com/repos/kivanio/brcobranca/issues/115"},"comments":{"href":"https://api.github.com/repos/kivanio/brcobranca/issues/115/comments"},"review_comments":{"href":"https://api.github.com/repos/kivanio/brcobranca/pulls/115/comments"},"review_comment":{"href":"https://api.github.com/repos/kivanio/brcobranca/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kivanio/brcobranca/pulls/115/commits"},"statuses":{"href":"https://api.github.com/repos/kivanio/brcobranca/statuses/4f306ad852120a8a9d59132867f0b15b565d30b1"}}}}