Edit in JSFiddle

Survey.Survey.cssType = "bootstrap";

function discount(params) {
  if(!params || params.length < 1 || !params[0]) return 0;
  var v = params[0];
  if(v <= 500) return 0;
  if(v <= 1000) return v / 20;
  if(v <= 3000) return v / 10;
  if(v <= 5000) return v * 15 / 1000;
  return v / 5;
}
Survey.FunctionFactory.Instance.register("discount", discount);

var json = {
 pages: [
  {
   elements: [
    {
     type: "paneldynamic",
     name: "items",
     title: "Invoice Items",
     templateElements: [
      {
       type: "text",
       isRequired: true,
       name: "name",
       title: "Name:"
      },
      {
       type: "text",
       inputType: "number",
       isRequired: true,
       name: "cost",
       title: "Item Cost:"
      },
      {
       type: "text",
       inputType: "number",
       isRequired: true,
       name: "quantity",
       startWithNewLine: false,
       title: "Quantity:"
      },
      {
       type: "expression",
       currency: "EUR",
       displayStyle: "currency",
       expression: "{panel.cost} * {panel.quantity}",
       name: "total",
       startWithNewLine: false,
       title: "Total Item Cost:"
      }
     ],
     templateTitle: "item #{panelIndex}",
     minPanelCount: 1,
     keyName: "name",
     panelAddText: "Add another  item",
     panelRemoveText: "Remove item",
     showQuestionNumbers: "none"
    },
    {
     type: "panel",
     name: "panel1",
     elements: [
      {
       type: "expression",
       displayStyle: "none",
       expression: "sumInArray({items}, 'quantity'",
       name: "totalQuantity",
       title: "Total  Quantity:"
      },
      {
       type: "expression",
       currency: "EUR",
       displayStyle: "currency",
       expression: "sumInArray({items}, 'total'",
       name: "totalCost",
       startWithNewLine: false,
       title: "Total Cost:"
      },
      {
       type: "expression",
       currency: "EUR",
       displayStyle: "currency",
       expression: "discount({totalCost})",
       name: "discount",
       startWithNewLine: false,
       title: "Discount:"
      },
      {
       type: "expression",
       currency: "EUR",
       displayStyle: "currency",
       expression: "{totalCost} - {discount}",
       name: "total",
       startWithNewLine: false,
       title: "Total:"
      },
			{
       type: "html",
       html: "<br/>Discount tiers are as follows: 500+ Euro - 5%, 1,000+ Euro - 10%, 3,000+ Euro - 15%, 5,000+ Euro – 20%."
      }
     ],
     title: "Totals"
    }
   ],
   name: "page1"
  }
 ],
 showQuestionNumbers: "off"
};

var survey = new Survey.Model(json);

survey
  .onComplete
  .add(function(result) {
    document
      .querySelector('#surveyResult')
      .innerHTML = "result: " + JSON.stringify(result.data);
  });

$("#surveyElement").Survey({
  model: survey
});
<div id="surveyElement"></div>
<div id="surveyResult"></div>