belvo.resources.tax_retentions
1from typing import Dict, List, Union 2 3from belvo.enums import TaxRetentionType 4from belvo.exceptions import BelvoAPIException 5from belvo.resources.base import Resource 6 7 8class TaxRetentions(Resource): 9 endpoint = "/api/tax-retentions/" 10 11 def create( 12 self, 13 link: str, 14 date_from: str, 15 date_to: str, 16 _type: TaxRetentionType, 17 attach_xml: bool = False, 18 save_data: bool = True, 19 raise_exception: bool = False, 20 **kwargs: Dict, 21 ) -> Union[List, Dict]: 22 """Retrieve tax retentions for a link 23 24 Retrieve (inflow or outflow) tax retentions for a fiscal link 25 26 Args: 27 link (str): The fiscal 'link.id' you want specific tax retention information for 28 date_from (str, optional): The starting date you want to get tax retentions for, in `YYYY-MM-DD` format. The value of `date_from` cannot be greater than `date_to`. Defaults to None. 29 date_to (str, optional): The date you want to stop getting tax retentions for, in `YYYY-MM-DD` format. The value of `date_to` cannot be greater than today's date (in other words, no future dates). Defaults to None. 30 _type (TaxRetentionType): The type of tax retention in relation to the invoice (from the perspective of the Link owner). `OUTFLOW` relates to a tax retention for a sent invoice. `INFLOW` related to a tax retention for a received invoice. 31 attach_xml (bool, optional): When set to`True`, you will receive the XML tax retention in the response. 32 save_data (bool, optional): Indicates whether or not to persist the data in Belvo. Defaults to `True`. 33 34 Returns: 35 Dict: The details of the object. For more information on the response from the API, see our [Tax retentions API documentation](https://developers.belvo.com/reference/retrievetaxretentions). 36 """ 37 38 data = { 39 "link": link, 40 "attach_xml": attach_xml, 41 "save_data": save_data, 42 "type": _type.value, 43 "date_from": date_from, 44 "date_to": date_to, 45 } 46 47 return self.session.post( 48 self.endpoint, data=data, raise_exception=raise_exception, **kwargs 49 ) 50 51 def resume(self, **_): 52 raise BelvoAPIException("Method not supported for tax retentions")
9class TaxRetentions(Resource): 10 endpoint = "/api/tax-retentions/" 11 12 def create( 13 self, 14 link: str, 15 date_from: str, 16 date_to: str, 17 _type: TaxRetentionType, 18 attach_xml: bool = False, 19 save_data: bool = True, 20 raise_exception: bool = False, 21 **kwargs: Dict, 22 ) -> Union[List, Dict]: 23 """Retrieve tax retentions for a link 24 25 Retrieve (inflow or outflow) tax retentions for a fiscal link 26 27 Args: 28 link (str): The fiscal 'link.id' you want specific tax retention information for 29 date_from (str, optional): The starting date you want to get tax retentions for, in `YYYY-MM-DD` format. The value of `date_from` cannot be greater than `date_to`. Defaults to None. 30 date_to (str, optional): The date you want to stop getting tax retentions for, in `YYYY-MM-DD` format. The value of `date_to` cannot be greater than today's date (in other words, no future dates). Defaults to None. 31 _type (TaxRetentionType): The type of tax retention in relation to the invoice (from the perspective of the Link owner). `OUTFLOW` relates to a tax retention for a sent invoice. `INFLOW` related to a tax retention for a received invoice. 32 attach_xml (bool, optional): When set to`True`, you will receive the XML tax retention in the response. 33 save_data (bool, optional): Indicates whether or not to persist the data in Belvo. Defaults to `True`. 34 35 Returns: 36 Dict: The details of the object. For more information on the response from the API, see our [Tax retentions API documentation](https://developers.belvo.com/reference/retrievetaxretentions). 37 """ 38 39 data = { 40 "link": link, 41 "attach_xml": attach_xml, 42 "save_data": save_data, 43 "type": _type.value, 44 "date_from": date_from, 45 "date_to": date_to, 46 } 47 48 return self.session.post( 49 self.endpoint, data=data, raise_exception=raise_exception, **kwargs 50 ) 51 52 def resume(self, **_): 53 raise BelvoAPIException("Method not supported for tax retentions")
def
create( self, link: str, date_from: str, date_to: str, _type: belvo.enums.TaxRetentionType, attach_xml: bool = False, save_data: bool = True, raise_exception: bool = False, **kwargs: Dict) -> Union[List, Dict]:
12 def create( 13 self, 14 link: str, 15 date_from: str, 16 date_to: str, 17 _type: TaxRetentionType, 18 attach_xml: bool = False, 19 save_data: bool = True, 20 raise_exception: bool = False, 21 **kwargs: Dict, 22 ) -> Union[List, Dict]: 23 """Retrieve tax retentions for a link 24 25 Retrieve (inflow or outflow) tax retentions for a fiscal link 26 27 Args: 28 link (str): The fiscal 'link.id' you want specific tax retention information for 29 date_from (str, optional): The starting date you want to get tax retentions for, in `YYYY-MM-DD` format. The value of `date_from` cannot be greater than `date_to`. Defaults to None. 30 date_to (str, optional): The date you want to stop getting tax retentions for, in `YYYY-MM-DD` format. The value of `date_to` cannot be greater than today's date (in other words, no future dates). Defaults to None. 31 _type (TaxRetentionType): The type of tax retention in relation to the invoice (from the perspective of the Link owner). `OUTFLOW` relates to a tax retention for a sent invoice. `INFLOW` related to a tax retention for a received invoice. 32 attach_xml (bool, optional): When set to`True`, you will receive the XML tax retention in the response. 33 save_data (bool, optional): Indicates whether or not to persist the data in Belvo. Defaults to `True`. 34 35 Returns: 36 Dict: The details of the object. For more information on the response from the API, see our [Tax retentions API documentation](https://developers.belvo.com/reference/retrievetaxretentions). 37 """ 38 39 data = { 40 "link": link, 41 "attach_xml": attach_xml, 42 "save_data": save_data, 43 "type": _type.value, 44 "date_from": date_from, 45 "date_to": date_to, 46 } 47 48 return self.session.post( 49 self.endpoint, data=data, raise_exception=raise_exception, **kwargs 50 )
Retrieve tax retentions for a link
Retrieve (inflow or outflow) tax retentions for a fiscal link
Arguments:
- link (str): The fiscal 'link.id' you want specific tax retention information for
- date_from (str, optional): The starting date you want to get tax retentions for, in
YYYY-MM-DD
format. The value ofdate_from
cannot be greater thandate_to
. Defaults to None. - date_to (str, optional): The date you want to stop getting tax retentions for, in
YYYY-MM-DD
format. The value ofdate_to
cannot be greater than today's date (in other words, no future dates). Defaults to None. - _type (TaxRetentionType): The type of tax retention in relation to the invoice (from the perspective of the Link owner).
OUTFLOW
relates to a tax retention for a sent invoice.INFLOW
related to a tax retention for a received invoice. - attach_xml (bool, optional): When set to
True
, you will receive the XML tax retention in the response. - save_data (bool, optional): Indicates whether or not to persist the data in Belvo. Defaults to
True
.
Returns:
Dict: The details of the object. For more information on the response from the API, see our Tax retentions API documentation.
def
resume(self, **_):
Resume a resource sessions
Example:
# Login to Belvo API
client = Client("Secret Key ID", "Secret Key PASSWORD", "sandbox")
# Resume a link
link = client.Links.resume(
session="session_id",
token="token",
link="link_id"
)
Arguments:
- session (str): The session you want to resume (UUID).
- token (str): The MFA token required to continue the session.
- link (str, optional): The Link ID . Defaults to None.
- raise_exception (bool, optional): Boolean indicating whether to return an API error or to raise an exception. Defaults to False.
Returns:
Union[List[Dict], Dict]: On success, returns the resource data requests.