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

Wrong commission percentage values #28

Closed
zangrandi opened this issue Jun 10, 2013 · 2 comments
Closed

Wrong commission percentage values #28

zangrandi opened this issue Jun 10, 2013 · 2 comments

Comments

@zangrandi
Copy link

In Moip documentation (https://labs.moip.com.br/parametro/comissoes/) the commissions with percentage values are not from 0 to 1, but from 0 to 100:

        <Comissionamento>
            <Comissionado>
                <LoginMoIP>recebedor_secundario</LoginMoIP>
            </Comissionado>
            <Razao>Motivo da comissão</Razao>
            <ValorFixo>10.00</ValorFixo>
            **<ValorPercentual>12.00</ValorPercentual>**
        </Comissionamento>
        <PagadorTaxa>
            <LoginMoIP>recebedor_secundario</LoginMoIP>
        </PagadorTaxa>
    </Comissoes>

This caused an error when I went to production. This code generated a commission value of R$ 1 in an item that costs R$ 100:

commissions << MyMoip::Commission.new(
    reason: "Venda de curso na escola #{current_school.name}",
    receiver_login: current_school.moip_login,
    percentage_value: 1.0
)

I got no time right now to contribute to the project, so I fixed it locally overring the commission "to_xml" method:

module MyMoip
    class Commission
        def to_xml(root = nil)
      raise InvalidComission if invalid?

      if root.nil?
        xml  = ""
        root ||= Builder::XmlMarkup.new(target: xml)
      end

      root.Comissionamento do |n1|
        n1.Razao(reason)
        n1.Comissionado {|n2| n2.LoginMoIP(receiver_login)}
        n1.ValorFixo(fixed_value) if fixed_value
        n1.ValorPercentual(percentage_value*100) if percentage_value
      end

      xml
        end
    end
end

It's working, including in production. The commissions are being generated ok now.

@Irio
Copy link
Owner

Irio commented Jun 13, 2013

Thanks @zangrandi, it's a really important bug, apparently fixed in fix-commission-percentage-format branch.

It will be released in a new gem version as soon as possible.

@Irio
Copy link
Owner

Irio commented Jun 13, 2013

You can now update to 0.6.1 with this patch included.

@Irio Irio closed this as completed Jun 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants