Skip to main content
Skip table of contents

(Before 7.0.2) Project Transaction cube from custom fields

This is an example on how Project Transaction cube can be build based on SERP data.
This cube definition contains these sections:

  • Defining Project transaction dimensions

  • Binding project transaction to dimensions

  • Defining Project transaction measures

    Note: Cube name is given a name when you import fist Custom field

Note: to see re- used standard Dimensions see sections “ for_standard_dimensions”, to see new dimension setup see sections “ for_custom_dimension”

Idea: With Javascript you can manipulate values during import and use them in a different way , see sections “ javascript_code"

CODE
#### Start of project transactions cube ####

#Defining Project transaction dimensions
#--------------------------
[TBIVVc.date]
name = 'Project Transaction Date'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
rest_api_field = 'TransDate'
data_type = 'date'
for_standard_dimension = "Time"
import_sort_date = true

[TBIVVc.code]
name = 'Project Transaction Code'
for_custom_dimension = 'Project Transaction'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
rest_api_field = 'SerNr'
key_field = true

[TBIVVc.name]
name = 'Project Transaction Name'
for_custom_dimension = 'Project Transaction'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
rest_api_field = 'PRName'
name_field = true

[TBIVVc.item_type]
name = 'Project Transaction Item Type'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
rest_api_field = 'ItemType'
dimension = true
javascript_code = '''
switch(doc.ItemType) {
  case "0":
    doc.ItemType = "Plain";
    break;
  case "1":
    doc.ItemType = "Stocked";
    break;
  case "3":
    doc.ItemType = "Service";
    break;
  case "5":
      doc.ItemType = "Materials";
    break; }
'''

[TBIVVc.transaction_surce]
name = 'Project Transaction Source'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
rest_api_field = 'oVc'
dimension = true
javascript_code = '''
switch(doc.oVc) {
  case "1":
    doc.oVc = "Timesheet";
    break;
  case "2":
    doc.oVc = "Purchase inv.";
    break;
  case "3":
    doc.oVc = "Expense";
    break;
  case "4":
    doc.oVc = "Delivery";
    break;
  case "5":
    doc.oVc = "Activity";
    break;
  case "6":
    doc.oVc = "Ret. goods";
    break;
  case "7":
    doc.oVc = "Depreciation";
    break;
   }
'''

[TBIVVc.invoice_status]
name = 'Project Transaction Invoice Statuss'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
skip_request = true
dimension = true
javascript_code = '''
if (doc.Invoice) {
  doc.invoice_status = 'Invoiced'
}
else {
  doc.invoice_status = 'Not Invoiced'
}
'''

[TBIVVc.objects]
name = 'Objects'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
rest_api_field = 'Objects'
for_extra_dimension_type = "Object types"

#Binding project transaction to dimensions
#--------------------------

[TBIVVc.invoice_code]
name = 'Project Transaction Invoice Code'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
for_standard_dimension = 'Invoice'
bind_field_name = 'code'
rest_api_field = 'Invoice'

[TBIVVc.invoice_item_position]
name = 'Project Transaction Invoice Item Position'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
for_standard_dimension = 'Invoice'
for_standard_dimension_level = 'Invoice Item'
bind_field_name = 'position'
skip_import = true
javascript_code = '''
doc.invoice_item_position = "-1"
'''

[TBIVVc.currency_code]
name = 'Project Transaction Currency Code'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
for_standard_dimension = 'Currency'
bind_field_name = 'currency'
rest_api_field = 'CurncyCode'

[TBIVVc.project_code]
name = 'Project Transaction Project Code'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
for_standard_dimension = 'Project (Job)'
for_standard_dimension_level = "Project"
bind_field_name = 'code'
rest_api_field = 'PRCode'

[TBIVVc.project_item_position]
name = 'Project Transaction Project Item Position'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
for_standard_dimension = 'Project (Job)'
for_standard_dimension_level = 'Project Item'
bind_field_name = 'position'
skip_import = true
javascript_code = '''
doc.project_item_position = "-1"
'''

[TBIVVc.item_code]
name = 'Project Transaction Item Code'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
for_standard_dimension = 'Item'
bind_field_name = 'code'
rest_api_field = 'ArtCode'

[TBIVVc.person_code]
name = 'Project Transaction Person Code'
dimension_name = 'Project Transaction'
cube_name = "HansaWorld Project Transactions"
for_standard_dimension = 'Person'
bind_field_name = 'code'
rest_api_field = 'EMCode'

#Defining Project transaction measures
#--------------------------

[TBIVVc.quantity]
name = "Project Transaction Quantity"
cube_name =  "HansaWorld Project Transactions"
dimension_name = 'Project Transaction'
measure = true
cubes_for_measure_sharing = ["HansaWorld Invoices"]
rest_api_field = "Qty"

[TBIVVc.gross_profit]
name = "Project Transaction Gross Profit"
cube_name =  "HansaWorld Project Transactions"
dimension_name = 'Project Transaction'
cubes_for_measure_sharing = ["HansaWorld Invoices"]
measure = true
rest_api_field = "GP"

[TBIVVc.cost]
name = "Project Transaction Cost"
cube_name =  "HansaWorld Project Transactions"
dimension_name = 'Project Transaction'
measure = true
cubes_for_measure_sharing = ["HansaWorld Invoices"]
skip_request = true
javascript_code = '''
if (doc.CostPrice) {
doc.cost = String(doc.CostPrice * doc.Qty)
}
'''

[TBIVVc.sum]
name = "Project Transaction Amount"
cube_name =  "HansaWorld Project Transactions"
dimension_name = 'Project Transaction'
measure = true
rest_api_field = "Sum"
cubes_for_measure_sharing = ["HansaWorld Invoices"]
javascript_code = '''
doc._source_id = doc.SerNr;
'''

#### End of project transactions cube ####
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.