Export products and price info to a CSV-file. Task-based execution, triggered by delta messages.
Uses the RPIO Task model.
Based on following SPARQL-query:
|
PREFIX gr: <http://purl.org/goodrelations/v1#> |
|
PREFIX dct: <http://purl.org/dc/terms/> |
|
PREFIX ext: <http://mu.semte.ch/vocabularies/ext/> |
|
PREFIX skos: <http://www.w3.org/2004/02/skos/core#> |
|
PREFIX pricing: <http://data.rollvolet.be/vocabularies/pricing/> |
|
PREFIX stock: <http://data.rollvolet.be/vocabularies/stock-management/> |
|
PREFIX schema: <http://schema.org/> |
|
|
|
SELECT ?id ?category ?subcategory ?name ?supplier ?ikp ?ikpUnit ?vkp ?vkpIncl ?margin ?vkpBase ?vkpUnit ?department WHERE { |
|
GRAPH ?g { |
|
?s a gr:SomeItems ; |
|
gr:name ?name ; |
|
dct:identifier ?id ; |
|
ext:purchaseOffering ?purchase ; |
|
ext:salesOffering ?sales . |
|
OPTIONAL { |
|
?s gr:category ?subcategoryUri . |
|
?subcategoryUri skos:prefLabel ?subcategory . |
|
OPTIONAL { |
|
?subcategoryUri skos:broader/skos:prefLabel ?category . |
|
} |
|
} |
|
OPTIONAL { |
|
?purchase ^gr:offers/gr:name ?supplier ; |
|
gr:hasPriceSpecification ?priceIn . |
|
OPTIONAL { |
|
?priceIn gr:hasCurrencyValue ?ikp . |
|
} |
|
OPTIONAL { |
|
?priceIn gr:hasUnitOfMeasurement/skos:prefLabel ?ikpUnit . |
|
} |
|
} |
|
OPTIONAL { |
|
?sales gr:hasPriceSpecification ?priceOut . |
|
?priceOut gr:valueAddedTaxIncluded "true"^^<http://mu.semte.ch/vocabularies/typed-literals/boolean> . |
|
OPTIONAL { |
|
?priceOut gr:hasCurrencyValue ?vkpIncl . |
|
} |
|
OPTIONAL { |
|
?priceOut pricing:margin ?margin . |
|
} |
|
OPTIONAL { |
|
?priceOut pricing:calculationBasis ?calc . |
|
?calc skos:prefLabel ?vkpBase . |
|
} |
|
OPTIONAL { |
|
?priceOut gr:hasUnitOfMeasurement/skos:prefLabel ?vkpUnit . |
|
} |
|
} |
|
OPTIONAL { |
|
?s stock:location/stock:department/schema:name ?department . |
|
} |
|
BIND(IF(BOUND(?vkpIncl), ?vkpIncl * 100 / (100 + ${VAT_RATE}), 0) as ?vkp) |
|
} |
|
} ORDER BY ?category ?subcategory ?id |
docker-compose.yml
pricelist-export:
image: rollvolet/pricelist-export-service
volumes:
- ./data/files:/share
config/delta/rules.js
{
match: {
predicate: {
type: "uri",
value: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
},
object: {
type: "uri",
value: "http://redpencil.data.gift/vocabularies/tasks/Task",
},
},
callback: {
url: "http://pricelist-export/delta",
method: "POST"
},
options: {
resourceFormat: "v0.0.1",
gracePeriod: 500,
ignoreFromSelf: true
}
},