Commit 3d3541e3 authored by Karen Bjørndalen's avatar Karen Bjørndalen
Browse files

Merge remote-tracking branch 'origin/master' into OM-41-ansattnr

parents 6229b6dc fdaf6ca9
Pipeline #48037 passed with stage
in 2 minutes and 13 seconds
......@@ -33,6 +33,8 @@ rest:
url: konteringsregler/v1
koststeder:
url: koststeder/v1
avgiftskoder:
url: avgiftskoder/v1
ressurser:
url: ressurser/v1
......
......@@ -187,6 +187,11 @@ def koststeder_data():
return load_json_file("koststeder.json")
@pytest.fixture
def avgiftskoder_data():
return load_json_file("avgiftskoder.json")
@pytest.fixture
def transaction_report_data():
return load_xml("transaction_report.xml")
......
[
{
"allowAmendingCalculatedVat": false,
"cashPrinciple": false,
"companyId": "72",
"currencyCode": "*",
"description": "25% mva fjernlev tjenester fra utland (ikke fradrag for inng mva) GENERERT",
"rounding": 0,
"roundingClosest": true,
"roundingDownwards": false,
"roundingUpwards": false,
"taxCode": "3P",
"type": "G",
"updateAmount": true,
"usedInAccountsPayable": true,
"usedInAccountsReceivable": false,
"usedInGeneralLedger": true,
"useNetBasedCalculation": true,
"percentage": {
"dateFrom": "2010-01-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"factorVat": 100,
"status": "N",
"vatAccount": "",
"vatPercent": 25
},
"lastUpdated": {
"updatedAt": "2019-08-08T14:30:06.983",
"updatedBy": "R.AMBE"
},
"relatedValues": [],
"customFieldGroups": {}
},
{
"allowAmendingCalculatedVat": false,
"cashPrinciple": false,
"companyId": "72",
"currencyCode": "*",
"description": "Registrering av direktepostert mva i staten",
"rounding": 0,
"roundingClosest": true,
"roundingDownwards": false,
"roundingUpwards": false,
"taxCode": "79",
"type": "N",
"updateAmount": true,
"usedInAccountsPayable": true,
"usedInAccountsReceivable": false,
"usedInGeneralLedger": true,
"useNetBasedCalculation": true,
"percentage": {
"dateFrom": "2005-01-01T00:00:00.000",
"dateTo": "2005-12-31T00:00:00.000",
"factorVat": 100,
"status": "C",
"vatAccount": "9999",
"vatPercent": 0
},
"lastUpdated": {
"updatedAt": "2019-08-08T14:37:29.710",
"updatedBy": "R.AMBE"
},
"linkedTaxCodes": [
{
"linkedTaxCode": "91",
"taxSystem": "",
"useBaseInclusiveVat": false
}
],
"relatedValues": [],
"customFieldGroups": {}
},
{
"allowAmendingCalculatedVat": false,
"cashPrinciple": false,
"companyId": "72",
"currencyCode": "*",
"description": "Registrering av direktepostert mva i staten",
"rounding": 0,
"roundingClosest": true,
"roundingDownwards": false,
"roundingUpwards": false,
"taxCode": "79",
"type": "N",
"updateAmount": true,
"usedInAccountsPayable": true,
"usedInAccountsReceivable": false,
"usedInGeneralLedger": true,
"useNetBasedCalculation": true,
"percentage": {
"dateFrom": "2014-10-01T00:00:00.000",
"dateTo": "2099-12-31T00:00:00.000",
"factorVat": 100,
"status": "C",
"vatAccount": "1987",
"vatPercent": 100
},
"lastUpdated": {
"updatedAt": "2019-08-08T14:37:29.717",
"updatedBy": "R.AMBE"
},
"linkedTaxCodes": [
{
"linkedTaxCode": "91",
"taxSystem": "",
"useBaseInclusiveVat": false
}
],
"relatedValues": [],
"customFieldGroups": {}
}
]
......@@ -20,7 +20,7 @@
"passwordUpdated": "2019-03-14T18:50:10.827",
"unit4Id": ""
},
"rolesAndCompanies": [
"roleAndCompany": [
{
"roleId": "D-ANMODER",
"companyId": "72",
......
......@@ -26,6 +26,7 @@ from ubw_client.models import (
ServerProcessResponse,
ServerProcessResult,
Transaction,
Avgiftskode,
UbwRestBase,
)
......@@ -293,6 +294,27 @@ def test_get_konteringsregel(client, requests_mock, konteringsregler_data):
assert received == expected
def test_get_avgiftskode(client, requests_mock, avgiftskoder_data):
# Test get many
company_id = "72"
requests_mock.get(
f"https://example.com/avgiftskoder/v1/{company_id}", json=avgiftskoder_data
)
expected_many = [Avgiftskode(**i) for i in avgiftskoder_data]
got_many = client.get_avgiftskode(company_id)
assert expected_many == got_many
# Test get single
avgiftskode = "3P"
requests_mock.get(
f"https://example.com/avgiftskoder/v1/{company_id}/{avgiftskode}",
json=avgiftskoder_data[:1],
)
expected_single = [Avgiftskode(**i) for i in avgiftskoder_data[:1]]
single_got = client.get_avgiftskode(company_id, avgiftskode)
assert single_got == expected_single
def test_get_transaction_report(
client, base_url, requests_mock, transaction_report_data
):
......
......@@ -35,7 +35,7 @@ def test_bruker(bruker_data):
assert hasattr(bruker.user_status, "status")
assert hasattr(bruker.security, "disabled_until")
assert hasattr(bruker.usage, "is_enabled_for_workflow_process")
assert bruker.roles_and_companies
assert bruker.role_and_company
assert bruker.contact_points
......
......@@ -119,6 +119,15 @@ class Endpoints:
koststed,
)
def get_avgiftskode(
self, company_id: str, avgiftskode: typing.Optional[str] = None
):
return self._prepend_base_url(
self.rest.endpoints.avgiftskoder.url or "avgiftskoder/v1",
company_id,
avgiftskode,
)
def get_ressurser(self, company_id: str, ressurs_id: typing.Optional[str] = None):
return self._prepend_base_url(
self.rest.endpoints.ressurser.url or "ressurser/v1", company_id, ressurs_id
......@@ -633,6 +642,38 @@ class UBWClient:
response = self.get(url, headers=headers)[0]
return models.Konteringsregel(**response)
def get_avgiftskode(
self,
company_id: str,
avgiftskode: typing.Optional[str] = None,
filters: typing.Dict[str, typing.Union[str, int]] = None,
) -> typing.List[models.Avgiftskode]:
"""
Get all or single avgiftskode of company with company_id
Accepts a dict of filters with the following keys:
"allowAmendingCalculatedVat", "cashPrinciple", "companyId",
"currencyCode", "description", "rounding", "roundingClosest",
"roundingDownwards", "roundingUpwards", "taxCode", "type",
"updateAmount", "usedInAccountsPayable", "usedInAccountsReceivable",
"usedInGeneralLedger", "useNetBasedCalculation"
with values as bool, int or str
"""
url = self.urls.get_avgiftskode(company_id, avgiftskode)
headers = self.config.rest.endpoints.avgiftskoder.headers
if avgiftskode and filters:
raise ValueError(
"Filters are not allowed when getting a single avgiftskode"
)
params = None
if filters:
items = [" eq ".join((k, v)) for k, v in filters.items()]
params = {"filters": " and ".join(items)}
response = self.get(url, params=params, headers=headers)
return [models.Avgiftskode(**x) for x in response]
def get_ressurser(self, company_id: str) -> typing.List[models.Ressurs]:
url = self.urls.get_ressurser(company_id)
headers = self.config.rest.endpoints.ressurser.headers
......
......@@ -81,6 +81,7 @@ class UbwRestEndpoints(BaseModel):
konteringsregler: UbwRestEndpoint = UbwRestEndpoint()
konteringsregel: UbwRestEndpoint = UbwRestEndpoint()
koststeder: UbwRestEndpoint = UbwRestEndpoint()
avgiftskoder: UbwRestEndpoint = UbwRestEndpoint()
ressurser: UbwRestEndpoint = UbwRestEndpoint()
......@@ -533,13 +534,13 @@ class Firma(BaseModel):
tax_office_reference: str
tax_system: str
vat_registration_number: str
multi_company_information: Connection
accounting: Accounts
currency_information: Currency
vat_information: VAT
multi_company_information: typing.Optional[Connection]
accounting: typing.Optional[Accounts]
currency_information: typing.Optional[Currency]
vat_information: typing.Optional[VAT]
last_updated: UpdatedInfo
contact_points: typing.List[ContactPoint]
related_values: typing.List[RelatedValue]
contact_points: typing.Optional[typing.List[ContactPoint]]
related_values: typing.Optional[typing.List[RelatedValue]]
class Config:
alias_generator = to_lower_camel
......@@ -599,7 +600,7 @@ class Bruker(BaseModel):
language_code: typing.Optional[str]
usage: typing.Optional[Usage]
contact_points: typing.Optional[typing.List[ContactPoint]]
roles_and_companies: typing.Optional[typing.List[RoleAndCompany]]
role_and_company: typing.Optional[typing.List[RoleAndCompany]]
class Config:
alias_generator = to_lower_camel
......@@ -856,6 +857,61 @@ class Konteringsregel(BaseModel):
allow_population_by_field_name = True
class PercentageInfo(BaseModel):
date_from: datetime.datetime
date_to: datetime.datetime
factor_vat: int
status: str
vat_account: str
vat_percent: int
class Config:
alias_generator = to_lower_camel
allow_population_by_field_name = True
class LinkedTaxCodesInfo(BaseModel):
linked_tax_code: str
tax_system: str
use_base_inclusive_vat: bool
class Config:
alias_generator = to_lower_camel
allow_population_by_field_name = True
class AvgiftskodeCustomFieldGroups(BaseModel):
pass
class Avgiftskode(BaseModel):
allow_amending_calculated_vat: bool
cash_principle: bool
company_id: str
currency_code: str
description: str
rounding: int
rounding_closest: bool
rounding_downwards: bool
rounding_upwards: bool
tax_code: str
type: str
update_amount: bool
used_in_accounts_payable: bool
used_in_accounts_receivable: bool
used_in_general_ledger: bool
use_net_based_calculation: bool
percentage: PercentageInfo
last_updated: UpdatedInfo
linked_tax_codes: typing.Optional[typing.List[LinkedTaxCodesInfo]]
related_values: typing.List[RelatedValue]
custom_field_groups: AvgiftskodeCustomFieldGroups
class Config:
alias_generator = to_lower_camel
allow_population_by_field_name = True
class Ressurs(BaseModel):
age: int
birth_date: datetime.datetime
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment