Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
it-bott-integrasjoner
ubw-client
Commits
3d3541e3
Commit
3d3541e3
authored
Dec 07, 2020
by
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
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
config.example.yaml
View file @
3d3541e3
...
...
@@ -33,6 +33,8 @@ rest:
url
:
konteringsregler/v1
koststeder
:
url
:
koststeder/v1
avgiftskoder
:
url
:
avgiftskoder/v1
ressurser
:
url
:
ressurser/v1
...
...
tests/conftest.py
View file @
3d3541e3
...
...
@@ -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"
)
...
...
tests/fixtures/avgiftskoder.json
0 → 100644
View file @
3d3541e3
[
{
"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"
:
{}
}
]
tests/fixtures/bruker.json
View file @
3d3541e3
...
...
@@ -20,7 +20,7 @@
"passwordUpdated"
:
"2019-03-14T18:50:10.827"
,
"unit4Id"
:
""
},
"role
s
AndCompan
ies
"
:
[
"roleAndCompan
y
"
:
[
{
"roleId"
:
"D-ANMODER"
,
"companyId"
:
"72"
,
...
...
tests/test_client.py
View file @
3d3541e3
...
...
@@ -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
):
...
...
tests/test_model.py
View file @
3d3541e3
...
...
@@ -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
.
role
s
_and_compan
ies
assert
bruker
.
role_and_compan
y
assert
bruker
.
contact_points
...
...
ubw_client/client.py
View file @
3d3541e3
...
...
@@ -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
...
...
ubw_client/models.py
View file @
3d3541e3
...
...
@@ -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
]]
role
s
_and_compan
ies
:
typing
.
Optional
[
typing
.
List
[
RoleAndCompany
]]
role_and_compan
y
:
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment