Skip to content

Commit

Permalink
Merge pull request #4 from starkbank/fix/unformatted-tax-id-comparison
Browse files Browse the repository at this point in the history
Fix/unformatted tax id comparison
  • Loading branch information
matheuscferraz authored Mar 11, 2020
2 parents 1277c65 + 2d23a33 commit 6314558
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The package can be installed by adding `stark_bank` to your list of dependencies
```elixir
def deps do
[
{:stark_bank, "~> 1.1.0"}
{:stark_bank, "~> 1.1.1"}
]
end
```
Expand Down
2 changes: 2 additions & 0 deletions lib/auth/auth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule StarkBank.Auth do
Functions:
- login
- update_access_token
- insert_external_access_token
- logout
- get_env
- get_workspace
Expand All @@ -14,6 +15,7 @@ defmodule StarkBank.Auth do
- get_workspace_id
- get_name
- get_permissions
- get_auto_refresh
"""

alias StarkBank.Utils.Requests, as: Requests
Expand Down
6 changes: 4 additions & 2 deletions lib/charge/charge.ex
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,12 @@ defmodule StarkBank.Charge do
base_address = base_customer.address
comp_address = comp_customer.address

customer_tax_id = base_customer.tax_id |> ChargeHelpers.Customer.normalize_tax_id()
comp_customer_tax_id = comp_customer.tax_id |> ChargeHelpers.Customer.normalize_tax_id()

Helpers.nullable_fields_match?(base_customer.name, comp_customer.name) and
Helpers.nullable_fields_match?(base_customer.email, comp_customer.email) and
Helpers.nullable_fields_match?(base_customer.tax_id, comp_customer.tax_id) and
Helpers.nullable_fields_match?(base_customer.phone, comp_customer.phone) and
Helpers.nullable_fields_match?(customer_tax_id, comp_customer_tax_id) and
Helpers.nullable_fields_match?(
Helpers.lowercase_list_of_strings(base_customer.tags),
comp_customer.tags
Expand Down
12 changes: 12 additions & 0 deletions lib/charge/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ defmodule StarkBank.Charge.Helpers do
tags: customer_map["tags"]
}
end

def normalize_tax_id(tax_id) when is_binary(tax_id) do
tax_id
|> String.replace(".", "")
|> String.replace("-", "")
end

def normalize_tax_id(tax_id) do
tax_id
|> to_string()
|> normalize_tax_id()
end
end

defmodule Charge do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule StarkBank.MixProject do
[
app: :stark_bank,
name: :stark_bank,
version: "1.1.0",
version: "1.1.1",
homepage_url: "https://starkbank.com",
source_url: "https://github.com/starkbank/sdk-elixir",
description: description(),
Expand Down

0 comments on commit 6314558

Please sign in to comment.