Skip to content

Commit

Permalink
fix: aligns embedded object namings, adds bounds
Browse files Browse the repository at this point in the history
* fixed payment postion

* optional product, order_index -> position, single tax + single tax context

* context.number -> custom_id

* vat -> tax

* example fixes
  • Loading branch information
eljefedelrodeodeljefe committed Dec 19, 2018
2 parents 4d29116 + 572d605 commit f2b8025
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 25 deletions.
2 changes: 1 addition & 1 deletion lib/v1/transactions/base.js
Expand Up @@ -191,7 +191,7 @@ module.exports = {
additionalProperties: false,
description: 'Cashier face values.',
properties: {
number: {
custom_id: {
type: 'string',
example: '005'
},
Expand Down
66 changes: 51 additions & 15 deletions lib/v1/transactions/items/base.js
Expand Up @@ -77,6 +77,7 @@ module.exports = {
maxLength: 3
},
product: {
default: null, // in case of expenses a product makes no sense
...oneOf({
type: 'string',
format: 'uuid',
Expand All @@ -92,6 +93,15 @@ module.exports = {
example: 'AKI-1234566'
})
},
tax: {
default: null,
...oneOf({
type: 'string',
format: 'uuid',
example: '9d110eb2-2245-4e14-9574-49b502f3a9b3',
description: 'If a single tax applies (normally VAT) - the applicable Tillhub tax resource with tax accounts.'
})
},
vat_rate: {
type: 'number',
description: 'The VAT rate of this item. E.g. 0.19 for 19% German VAT. If no VAT applies, set to 0.',
Expand Down Expand Up @@ -140,10 +150,12 @@ module.exports = {
type: 'string',
example: 'a3be1e02-7983-4cba-b7b8-94453c0536ef'
},
order_index: {
position: {
description: 'Position of the specific tax.',
type: 'integer',
example: '0'
minimum: 0,
maximum: 30,
example: '1'
},
rate: {
type: 'number',
Expand All @@ -154,16 +166,21 @@ module.exports = {
multipleOf: 0.001
},
// flat values here because we do not want to align another array from context
account: {
description: 'Custom number identifier.',
type: 'string',
example: '440165'
custom_id: {
default: null,
...oneOf({
description: 'Custom tax account number identifier.',
type: 'string',
example: '440165'
})
},
display: {
description: 'Custom description.',
default: null,
type: 'string',
example: 'Another tax'
...oneOf({
description: 'Custom tax account description.',
type: 'string',
example: 'Another tax'
})
}
}
}),
Expand Down Expand Up @@ -292,7 +309,7 @@ module.exports = {
type: 'object',
description: 'Account face values.',
properties: {
number: {
custom_id: {
description: 'Account number.', // account or expense_account fa_account_number
type: 'string',
example: '1776'
Expand All @@ -306,12 +323,32 @@ module.exports = {
}),
default: null
},
tax: {
...oneOf({
type: 'object',
description: 'In case of a single tax (usually VAT) - the tax account face values.',
properties: {
custom_id: {
description: 'Custom number identifier.',
type: 'string',
example: '440165'
},
display: {
description: 'Custom description.',
default: null,
type: 'string',
example: 'Another tax'
}
}
}),
default: null
},
product: {
...oneOf({
type: 'object',
description: 'Product face values.',
properties: {
number: {
custom_id: {
type: 'string',
example: '0032039845'
},
Expand All @@ -328,7 +365,7 @@ module.exports = {
type: 'object',
description: 'Product face values.',
properties: {
number: {
custom_id: {
type: 'string',
example: '0032039845'
},
Expand All @@ -349,7 +386,7 @@ module.exports = {
type: 'boolean',
example: 'true'
},
number: {
custom_id: {
type: 'string',
example: '012'
},
Expand All @@ -369,8 +406,7 @@ module.exports = {
}
},
required: [
'account',
'product'
'account'
]
}),
default: null
Expand Down
15 changes: 6 additions & 9 deletions lib/v1/transactions/payments/base.js
Expand Up @@ -48,10 +48,10 @@ module.exports = {
default: null,
...oneOf({
type: 'number',
description: 'The position description of the payment item. E.g. positon 1 (2, 3 etc.) in the cart.',
example: '1',
maximum: 32767,
minimum: 0
description: 'The position of the payment item. E.g. positon 1 (2, 3 etc.) in the transaction.',
minimum: 0,
maximum: 300,
example: '1'
})
},
date: {
Expand Down Expand Up @@ -190,7 +190,7 @@ module.exports = {
additionalProperties: false,
description: 'Account face values.',
properties: {
number: {
custom_id: {
type: 'string',
example: '1009'
}
Expand All @@ -211,10 +211,7 @@ module.exports = {
}),
default: null
}
},
required: [
'account'
]
}
}),
default: null
},
Expand Down

0 comments on commit f2b8025

Please sign in to comment.