コード例 #1
0
  private void submitSplitPurchase() {
    String store = getStore();
    Date date = getDate();

    List<PurchaseItem> purchaseItems = splitPurchaseGrid.getNewPurcahses();

    double totalCost = sumPurchaseItemCost(purchaseItems);
    PurchaseItem highestCostPurchaseItem = findHighestCostPurchaseItem(purchaseItems);

    BillType highestCostbillType = highestCostPurchaseItem.getBillType();

    sendPurchase(totalCost, highestCostbillType, highestCostPurchaseItem.getNote(), store, date);

    purchaseItems.remove(highestCostPurchaseItem);

    for (PurchaseItem purchaseItem : purchaseItems) {
      double cost = purchaseItem.getCost();
      BillType billType = purchaseItem.getBillType();
      String note = purchaseItem.getNote();

      sendPurchase(((-1) * cost), highestCostbillType, "Subtracting other purchases", store, date);

      sendPurchase(cost, billType, note, store, date);
    }

    finishPurchase();
  }
コード例 #2
0
  private void toggleSplit() {
    isSplit = !isSplit;
    if (isSplit) {
      splitPurchaseGrid = new SplitPurchaseGrid(billTypeManager);

      splitPurchaseGrid.setTotalCost(getCost());

      costField.setFieldLabel("Total Cost");

      fieldPanel.removeRow(3);
      fieldPanel.removeRow(3);

      matchingField.addDisplayableReportWidget(splitPurchaseGrid);
    } else {
      costField.setFieldLabel("Cost");

      fieldPanel.insertRow(3);

      fieldPanel.setText(2, 0, "Bill Type:");
      fieldPanel.setWidget(2, 1, billTypeComboBox);

      fieldPanel.insertRow(4);
      fieldPanel.setText(3, 0, "Note:");
      fieldPanel.setWidget(3, 1, noteField);

      matchingField.addDisplayableReportWidget(null);
    }
  }