Conciliação

A conciliação pode ser feita de várias Contas a Pagar / Receber com vários Movimentos Bancários (relação n:m) e segue as seguintes restrições:

  • A soma das Contas a Pagar / Receber deve ser igual a soma dos Movimentos Bancários, em valores absolutos;
  • Conciliar apenas Contas a Pagar com Débitos e Contas a Receber com Créditos;
  • A Conta do Movimento Bancário deve ser da mesma entidade da Conta a Pagar / Receber;
  • A Conta a Pagar / Receber deve estar paga / recebida.

Realizar conciliação

POST /entities/:entity_id/reconciles

Enviar os parâmetros para conciliação dos objetos como XML ou JSON (conforme o formato escolhido) no corpo da requisição HTTP.

Em caso de sucesso, retorna 200 Ok, além dos dados dos objetos conciliados. Em caso de erro, retorna 422 Unprocessable Entity e as mensagens de erro informando porque não foi possível realizar a conciliação.

Exemplo de Requisição

{
  "selected_financial_account_ids": [
    2565,
    100588
  ],
  "selected_financial_transaction_ids": [
    6632,
    215334,
    89988
  ]
}
<?xml version="1.0" encoding="UTF-8"?>
  <selected-financial-account-ids type="array">
    <id>2565</id>
    <id>100588</id>
  </selected-financial-account-ids>
  <selected-financial-transaction-ids type="array">
    <id>6632</id>
    <id>215334</id>
    <id>89988</id>
  </selected-financial-transaction-ids>

Exemplo de Resposta

HTTP/1.1 200 Ok
Location: https://app.myfinance.com.br/entities/1/reconciles
Content-Type: application/json; charset=utf-8
Date: Tue, 10 Sep 2013 16:33:02 GMT
{
  "financial_transactions": [
    {
      "id": 6632,
      "guid": null,
      "type": "Debit",
      "absolute_amount": "3000.0",
      "amount": "-3000.0",
      "occurred_at": "2013-09-09",
      "document": "",
      "original_description": null,
      "user_description": "",
      "bank_statement_id": null,
      "classification_center_id": null,
      "deposit_account_id": 1,
      "person_id": null,
      "parent_id": null,
      "currency_id": 2,
      "category_id": null,
      "transfer_id": null,
      "created_at": "2013-09-09T11:47:21-03:00",
      "updated_at": "2013-09-09T11:47:21-03:00",
      "imported_from_sync": false,
      "balance_difference": false,
      "divided": false,
      "attachments_count": 0,
      "observation": "",
      "transfer_deposit_account_id": null,
      "attachment_id_list": [],
      "links": [
        {
          "rel": "self",
          "href": "http://localhost:3000/entities/1/deposit_accounts/1/financial_transactions/6632",
          "method": "get"
        },
        {
          "rel": "destroy",
          "href": "http://localhost:3000/entities/1/deposit_accounts/1/financial_transactions/6632",
          "method": "delete"
        }
      ]
    },
    {
      "id": 215334,
      "guid": null,
      "type": "Debit",
      "absolute_amount": "1000.0",
      "amount": "-1000.0",
      "occurred_at": "2013-09-09",
      "document": "",
      "original_description": null,
      "user_description": "",
      "bank_statement_id": null,
      "classification_center_id": null,
      "deposit_account_id": 1,
      "person_id": null,
      "parent_id": null,
      "currency_id": 2,
      "category_id": null,
      "transfer_id": null,
      "created_at": "2013-09-09T11:47:21-03:00",
      "updated_at": "2013-09-09T11:47:21-03:00",
      "imported_from_sync": false,
      "balance_difference": false,
      "divided": false,
      "attachments_count": 0,
      "observation": "",
      "transfer_deposit_account_id": null,
      "attachment_id_list": [],
      "links": [
        {
          "rel": "self",
          "href": "http://localhost:3000/entities/1/deposit_accounts/1/financial_transactions/215334",
          "method": "get"
        },
        {
          "rel": "destroy",
          "href": "http://localhost:3000/entities/1/deposit_accounts/1/financial_transactions/215334",
          "method": "delete"
        }
      ]
    },
    {
      "id": 89988,
      "guid": null,
      "type": "Debit",
      "absolute_amount": "1000.0",
      "amount": "-1000.0",
      "occurred_at": "2013-09-09",
      "document": "",
      "original_description": null,
      "user_description": "",
      "bank_statement_id": null,
      "classification_center_id": null,
      "deposit_account_id": 1,
      "person_id": null,
      "parent_id": null,
      "currency_id": 2,
      "category_id": null,
      "transfer_id": null,
      "created_at": "2013-09-09T11:47:21-03:00",
      "updated_at": "2013-09-09T11:47:21-03:00",
      "imported_from_sync": false,
      "balance_difference": false,
      "divided": false,
      "attachments_count": 0,
      "observation": "",
      "transfer_deposit_account_id": null,
      "attachment_id_list": [],
      "links": [
        {
          "rel": "self",
          "href": "http://localhost:3000/entities/1/deposit_accounts/1/financial_transactions/89988",
          "method": "get"
        },
        {
          "rel": "destroy",
          "href": "http://localhost:3000/entities/1/deposit_accounts/1/financial_transactions/89988",
          "method": "delete"
        }
      ]
    }
  ],
  "financial_accounts": [
    {
      "id": 2565,
      "entity_id": 1,
      "status": 3,
      "status_name": "reconciled",
      "due_date": "2013-09-06",
      "occurred_at": "2013-09-09",
      "amount": "3000.0",
      "ticket_amount": null,
      "interest_amount": null,
      "discount_amount": null,
      "total_amount": "5000.0",
      "description": "Conserto do carro",
      "document": "654322",
      "observation": null,
      "remind": false,
      "reminded_at": null,
      "category_id": 7,
      "classification_center_id": null,
      "expected_deposit_account_id": 1,
      "financial_transaction_id": null,
      "recurrence_id": null,
      "person_id": null,
      "created_at": "2013-09-09T10:56:14-03:00",
      "updated_at": "2013-09-09T11:47:27-03:00",
      "recurrent": false,
      "parcelled": false,
      "attachment_id_list": [],
      "tax_charges": [],
      "links": [
        {
          "rel": "self",
          "href": "http://localhost:3000/entities/1/payable_accounts/2565",
          "method": "get"
        },
        {
          "rel": "destroy",
          "href": "http://localhost:3000/entities/1/payable_accounts/2565",
          "method": "delete"
        }
      ]
    },
    {
      "id": 100588,
      "entity_id": 1,
      "status": 3,
      "status_name": "reconciled",
      "due_date": "2013-09-06",
      "occurred_at": "2013-09-09",
      "amount": "2000.0",
      "ticket_amount": null,
      "interest_amount": null,
      "discount_amount": null,
      "total_amount": "5000.0",
      "description": "Conserto do carro",
      "document": "654322",
      "observation": null,
      "remind": false,
      "reminded_at": null,
      "category_id": 7,
      "classification_center_id": null,
      "expected_deposit_account_id": 1,
      "financial_transaction_id": null,
      "recurrence_id": null,
      "person_id": null,
      "created_at": "2013-09-09T10:56:14-03:00",
      "updated_at": "2013-09-09T11:47:27-03:00",
      "recurrent": false,
      "parcelled": false,
      "attachment_id_list": [],
      "financial_account_taxes_attributes": [],
      "tax_charges": [],
      "links": [
        {
          "rel": "self",
          "href": "http://localhost:3000/entities/1/payable_accounts/100588",
          "method": "get"
        },
        {
          "rel": "destroy",
          "href": "http://localhost:3000/entities/1/payable_accounts/100588",
          "method": "delete"
        }
      ]
    }
  ]
}
HTTP/1.1 200 Ok
Location: https://app.myfinance.com.br/entities/1/reconciles
Content-Type: application/xml; charset=utf-8
Date: Tue, 10 Sep 2013 16:33:03 GMT
<?xml version="1.0" encoding="UTF-8"?>
  <hash>
    <financial-transactions type="array">
      <financial-transaction>
        <id type="integer">6632</id>
        <guid nil="true"/>
        <type>Debit</type>
        <absolute-amount type="decimal">3000.0</absolute-amount>
        <amount type="decimal">-3000.0</amount>
        <occurred-at type="date">2013-09-09</occurred-at>
        <document>654322</document>
        <original-description nil="true"/>
        <user-description>Conserto do carro</user-description>
        <bank-statement-id nil="true"/>
        <classification-center-id nil="true"/>
        <deposit-account-id type="integer">1</deposit-account-id>
        <person-id nil="true"/>
        <parent-id nil="true"/>
        <currency-id type="integer">2</currency-id>
        <category-id nil="true"/>
        <transfer-id nil="true"/>
        <created-at type="datetime">2013-09-09T12:05:17-03:00</created-at>
        <updated-at type="datetime">2013-09-09T12:05:17-03:00</updated-at>
        <imported-from-sync type="boolean">false</imported-from-sync>
        <balance-difference type="boolean">false</balance-difference>
        <divided type="boolean">false</divided>
        <attachments-count type="integer">0</attachments-count>
        <observation nil="true"/>
        <transfer-deposit-account-id nil="true"/>
        <attachment-id-list type="array"/>
        <links type="array">
          <link>
            <rel>self</rel>
            <href>http://localhost:3000/entities/1/deposit_accounts/1/financial_transactions/6632</href>
            <method>get</method>
          </link>
          <link>
            <rel>destroy</rel>
            <href>http://localhost:3000/entities/1/deposit_accounts/1/financial_transactions/6632</href>
            <method>delete</method>
          </link>
        </links>
      </financial-transaction>
      <financial-transaction>
        <id type="integer">215334</id>
        <guid nil="true"/>
        <type>Debit</type>
        <absolute-amount type="decimal">1000.0</absolute-amount>
        <amount type="decimal">-1000.0</amount>
        <occurred-at type="date">2013-09-09</occurred-at>
        <document>654322</document>
        <original-description nil="true"/>
        <user-description>Conserto do carro</user-description>
        <bank-statement-id nil="true"/>
        <classification-center-id nil="true"/>
        <deposit-account-id type="integer">1</deposit-account-id>
        <person-id nil="true"/>
        <parent-id nil="true"/>
        <currency-id type="integer">2</currency-id>
        <category-id nil="true"/>
        <transfer-id nil="true"/>
        <created-at type="datetime">2013-09-09T12:05:17-03:00</created-at>
        <updated-at type="datetime">2013-09-09T12:05:17-03:00</updated-at>
        <imported-from-sync type="boolean">false</imported-from-sync>
        <balance-difference type="boolean">false</balance-difference>
        <divided type="boolean">false</divided>
        <attachments-count type="integer">0</attachments-count>
        <observation nil="true"/>
        <transfer-deposit-account-id nil="true"/>
        <attachment-id-list type="array"/>
        <links type="array">
          <link>
            <rel>self</rel>
            <href>http://localhost:3000/entities/1/deposit_accounts/1/financial_transactions/215334</href>
            <method>get</method>
          </link>
          <link>
            <rel>destroy</rel>
            <href>http://localhost:3000/entities/1/deposit_accounts/1/financial_transactions/215334</href>
            <method>delete</method>
          </link>
        </links>
      </financial-transaction>
      <financial-transaction>
        <id type="integer">89988</id>
        <guid nil="true"/>
        <type>Debit</type>
        <absolute-amount type="decimal">1000.0</absolute-amount>
        <amount type="decimal">-1000.0</amount>
        <occurred-at type="date">2013-09-09</occurred-at>
        <document>654322</document>
        <original-description nil="true"/>
        <user-description>Conserto do carro</user-description>
        <bank-statement-id nil="true"/>
        <classification-center-id nil="true"/>
        <deposit-account-id type="integer">1</deposit-account-id>
        <person-id nil="true"/>
        <parent-id nil="true"/>
        <currency-id type="integer">2</currency-id>
        <category-id nil="true"/>
        <transfer-id nil="true"/>
        <created-at type="datetime">2013-09-09T12:05:17-03:00</created-at>
        <updated-at type="datetime">2013-09-09T12:05:17-03:00</updated-at>
        <imported-from-sync type="boolean">false</imported-from-sync>
        <balance-difference type="boolean">false</balance-difference>
        <divided type="boolean">false</divided>
        <attachments-count type="integer">0</attachments-count>
        <observation nil="true"/>
        <transfer-deposit-account-id nil="true"/>
        <attachment-id-list type="array"/>
        <links type="array">
          <link>
            <rel>self</rel>
            <href>http://localhost:3000/entities/1/deposit_accounts/1/financial_transactions/89988</href>
            <method>get</method>
          </link>
          <link>
            <rel>destroy</rel>
            <href>http://localhost:3000/entities/1/deposit_accounts/1/financial_transactions/89988</href>
            <method>delete</method>
          </link>
        </links>
      </financial-transaction>
    </financial-transactions>
    <financial-accounts type="array">
      <financial-account>
        <id type="integer">2565</id>
        <entity-id type="integer">1</entity-id>
        <status type="integer">3</status>
        <status-name type="symbol">reconciled</status-name>
        <due-date type="date">2013-09-06</due-date>
        <occurred-at type="date">2013-09-09</occurred-at>
        <amount type="decimal">3000.0</amount>
        <ticket-amount nil="true"/>
        <interest-amount nil="true"/>
        <discount-amount nil="true"/>
        <total-amount type="decimal">5000.0</total-amount>
        <description>Conserto do carro</description>
        <document>654322</document>
        <observation nil="true"/>
        <remind type="boolean">false</remind>
        <reminded-at nil="true"/>
        <category-id type="integer">7</category-id>
        <classification-center-id nil="true"/>
        <expected-deposit-account-id type="integer">1</expected-deposit-account-id>
        <financial-transaction-id nil="true"/>
        <recurrence-id nil="true"/>
        <person-id nil="true"/>
        <created-at type="datetime">2013-09-09T10:56:14-03:00</created-at>
        <updated-at type="datetime">2013-09-09T12:05:17-03:00</updated-at>
        <recurrent type="boolean">false</recurrent>
        <parcelled type="boolean">false</parcelled>
        <attachment-id-list type="array"/>
        <financial-account-taxes-attributes type="array"/>
        <tax-charges type="array"/>
        <links type="array">
          <link>
            <rel>self</rel>
            <href>http://localhost:3000/entities/1/payable_accounts/2565</href>
            <method>get</method>
          </link>
          <link>
            <rel>destroy</rel>
            <href>http://localhost:3000/entities/1/payable_accounts/2565</href>
            <method>delete</method>
          </link>
        </links>
      </financial-account>
      <financial-account>
        <id type="integer">100588</id>
        <entity-id type="integer">1</entity-id>
        <status type="integer">3</status>
        <status-name type="symbol">reconciled</status-name>
        <due-date type="date">2013-09-06</due-date>
        <occurred-at type="date">2013-09-09</occurred-at>
        <amount type="decimal">2000.0</amount>
        <ticket-amount nil="true"/>
        <interest-amount nil="true"/>
        <discount-amount nil="true"/>
        <total-amount type="decimal">5000.0</total-amount>
        <description>Conserto do carro</description>
        <document>654322</document>
        <observation nil="true"/>
        <remind type="boolean">false</remind>
        <reminded-at nil="true"/>
        <category-id type="integer">7</category-id>
        <classification-center-id nil="true"/>
        <expected-deposit-account-id type="integer">1</expected-deposit-account-id>
        <financial-transaction-id nil="true"/>
        <recurrence-id nil="true"/>
        <person-id nil="true"/>
        <created-at type="datetime">2013-09-09T10:56:14-03:00</created-at>
        <updated-at type="datetime">2013-09-09T12:05:17-03:00</updated-at>
        <recurrent type="boolean">false</recurrent>
        <parcelled type="boolean">false</parcelled>
        <attachment-id-list type="array"/>
        <financial-account-taxes-attributes type="array"/>
        <tax-charges type="array"/>
        <links type="array">
          <link>
            <rel>self</rel>
            <href>http://localhost:3000/entities/1/payable_accounts/100588</href>
            <method>get</method>
          </link>
          <link>
            <rel>destroy</rel>
            <href>http://localhost:3000/entities/1/payable_accounts/100588</href>
            <method>delete</method>
          </link>
        </links>
      </financial-account>
    </financial-accounts>
  </hash>

Exemplo de Erro

HTTP/1.1 422 Unprocessable Entity
Location: https://app.myfinance.com.br/entities/1/reconciles
Content-Type: application/json; charset=utf-8
Date: Tue, 10 Sep 2013 16:33:02 GMT
{
  "type": [
    "itens para conciliação não são compatíveis"
  ],
  "entity": [
    "não pertencem à mesma entidade"
  ]
}
HTTP/1.1 422 Unprocessable Entity
Location: https://app.myfinance.com.br/entities/1/reconciles
Content-Type: application/xml; charset=utf-8
Date: Tue, 10 Sep 2013 16:33:02 GMT
<?xml version="1.0" encoding: "UTF-8"?>
<errors>
  <error>Entity não pertencem à mesma entidade</error>
  <error>Type itens para conciliação não são compatíveis</error>
</errors>