Template.coreOrderShippingInvoice.onCreated(function () {
  this.state = new ReactiveDict();

  // template.orderDep = new Tracker.Dependency;
  this.refunds = new ReactiveVar([]);
  this.refundAmount = new ReactiveVar(0.00);

  // function getOrder(orderId) {
  //   template.orderDep.depend();
  //   return Orders.findOne(orderId);
  // }

  this.autorun(() => {
    const currentData = Template.currentData();
    const order = Orders.findOne(currentData.orderId);
    const shop = Shops.findOne({});

    this.state.set("order", order);
    this.state.set("currency", shop.currencies[shop.currency]);

    // template.order = getOrder(currentData.orderId);
    if (order) {
      const paymentMethod = order.billing[0].paymentMethod;
      Meteor.call("orders/refunds/list", paymentMethod, (error, result) => {
        if (!error) {
          this.refunds.set(result);
        }
      });
    }
  });
});