{"action":"created","issue":{"url":"https://api.github.com/repos/Dolibarr/dolibarr/issues/4858","repository_url":"https://api.github.com/repos/Dolibarr/dolibarr","labels_url":"https://api.github.com/repos/Dolibarr/dolibarr/issues/4858/labels{/name}","comments_url":"https://api.github.com/repos/Dolibarr/dolibarr/issues/4858/comments","events_url":"https://api.github.com/repos/Dolibarr/dolibarr/issues/4858/events","html_url":"https://github.com/Dolibarr/dolibarr/pull/4858","id":142104844,"number":4858,"title":"NEW Created Account::__toString, Account::getFieldsToShow and Account::getAccountNumberOrder to refactor the way account number was shown","user":{"login":"marcosgdf","id":168744,"avatar_url":"https://avatars.githubusercontent.com/u/168744?v=3","gravatar_id":"","url":"https://api.github.com/users/marcosgdf","html_url":"https://github.com/marcosgdf","followers_url":"https://api.github.com/users/marcosgdf/followers","following_url":"https://api.github.com/users/marcosgdf/following{/other_user}","gists_url":"https://api.github.com/users/marcosgdf/gists{/gist_id}","starred_url":"https://api.github.com/users/marcosgdf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcosgdf/subscriptions","organizations_url":"https://api.github.com/users/marcosgdf/orgs","repos_url":"https://api.github.com/users/marcosgdf/repos","events_url":"https://api.github.com/users/marcosgdf/events{/privacy}","received_events_url":"https://api.github.com/users/marcosgdf/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Dolibarr/dolibarr/labels/PR%20to%20merge","name":"PR to merge","color":"bfe5bf"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-19T22:01:14Z","updated_at":"2016-04-09T22:03:58Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Dolibarr/dolibarr/pulls/4858","html_url":"https://github.com/Dolibarr/dolibarr/pull/4858","diff_url":"https://github.com/Dolibarr/dolibarr/pull/4858.diff","patch_url":"https://github.com/Dolibarr/dolibarr/pull/4858.patch"},"body":"### Created Account::__toString, Account::getFieldsToShow and Account::getAccountNumberOrder to refactor the way account number was shown.\r\n\r\nBecause there is much complexity all over Dolibarr to show the bank account number, I considered appropiate to refactor so that the logic is centralized in one function.\r\n\r\nTo do so I've created the following functions:\r\n* `Account::getFieldsToShow`: to know which fields this bank account needs to display to the user (depending on Dolibarr configuration and on bank account country)\r\n* `Account::getAccountNumberOrder`: returns the fields of the bank account in the order they are going to be displayed (set by the administrator in bank module configuration)\r\n* `Account::__toString`: to show the bank account number just converting the type of the class. I didn't use IBAN because showing IBAN is just showing out the `iban` property of the class. But if you want to, this behaviour can be modified.\r\n\r\n`CompanyBankAccount` and `UserBankAccount` classes also benefit from this refactor.\r\n\r\nI had to rename `AccountNumber` to `BankAccountNumber` so that the \"key\" matches the translation key too.\r\n\r\nSo, to summarize: we now only need to do `(string) $account` to show the bank account number in the appropiate format. If we need to treat data differently, we will use the other functions (like PDF and bank account cards do)"},"comment":{"url":"https://api.github.com/repos/Dolibarr/dolibarr/issues/comments/207862620","html_url":"https://github.com/Dolibarr/dolibarr/pull/4858#issuecomment-207862620","issue_url":"https://api.github.com/repos/Dolibarr/dolibarr/issues/4858","id":207862620,"user":{"login":"marcosgdf","id":168744,"avatar_url":"https://avatars.githubusercontent.com/u/168744?v=3","gravatar_id":"","url":"https://api.github.com/users/marcosgdf","html_url":"https://github.com/marcosgdf","followers_url":"https://api.github.com/users/marcosgdf/followers","following_url":"https://api.github.com/users/marcosgdf/following{/other_user}","gists_url":"https://api.github.com/users/marcosgdf/gists{/gist_id}","starred_url":"https://api.github.com/users/marcosgdf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcosgdf/subscriptions","organizations_url":"https://api.github.com/users/marcosgdf/orgs","repos_url":"https://api.github.com/users/marcosgdf/repos","events_url":"https://api.github.com/users/marcosgdf/events{/privacy}","received_events_url":"https://api.github.com/users/marcosgdf/received_events","type":"User","site_admin":false},"created_at":"2016-04-09T22:03:57Z","updated_at":"2016-04-09T22:03:57Z","body":"You can merge it now @eldy "}}