func (catalog *Catalog) ship_item(w http.ResponseWriter, r *http.Request) {
	item := catalog.get_item(w, r)
	if item == nil {
		return
	}
	username := r.FormValue("user")
	timestamp := r.FormValue("ts")
	qtyString := r.FormValue("qty")
	qty, err := strconv.ParseUint(qtyString, 10, 64)
	if err != nil {
		services.Http_respond_error(w, r, "Failed to parse 'qty' parameter to uint: "+err.Error(), http.StatusBadRequest)
		return
	}
	if shipment, existed, err := item.Ship(username, qty, timestamp); err != nil {
		services.Http_respond_error(w, r, "Failed to ship item: "+err.Error(), http.StatusInternalServerError)
	} else {
		var code int
		if existed {
			code = http.StatusOK
		} else {
			code = http.StatusCreated
		}
		services.Http_respond(w, r, ([]byte)(shipment.id), code)
	}
}
func (store *AccountStore) cancel_transaction(w http.ResponseWriter, r *http.Request) {
	if trans := store.get_transaction(w, r); trans != nil {
		if err := trans.Cancel(); err != nil {
			services.Http_application_error(w, r, err)
		}
		services.Http_respond(w, r, nil, http.StatusOK)
	}
}
func (payments *Payments) cancel_payment(w http.ResponseWriter, r *http.Request) {
	if payment := payments.get_payment(w, r, true); payment != nil {
		if err := payment.Cancel(); err != nil {
			services.Http_application_error(w, r, err)
		} else {
			services.Http_respond(w, r, nil, http.StatusOK)
		}
	}
}
func (catalog *Catalog) cancel_shipment(w http.ResponseWriter, r *http.Request) {
	if shipment := catalog.get_shipment(w, r); shipment != nil {
		if err := shipment.Cancel(); err != nil {
			services.Http_application_error(w, r, err)
		} else {
			services.Http_respond(w, r, nil, http.StatusOK)
		}
	}
}
func (store *AccountStore) handle_deposit(w http.ResponseWriter, r *http.Request) {
	account := store.get_account(w, r)
	value, ok := store.get_value_query(w, r)
	if !ok {
		return
	}

	trans := store.NewTransaction(account, -value, nil)
	if store.optionally_commit_transaction(trans, w, r) {
		services.Http_respond(w, r, ([]byte)(trans.Id), http.StatusOK)
	}
}
func (store *AccountStore) handle_transfer(w http.ResponseWriter, r *http.Request) {
	account := store.get_account(w, r)
	value, ok := store.get_value_query(w, r)
	if !ok {
		return
	}

	target := r.FormValue("target")
	if target == "" {
		services.Http_respond_error(w, r, "Need 'target' string parameter", http.StatusBadRequest)
		return
	}
	targetAccount := store.GetAccount(target)

	trans := store.NewTransaction(account, value, targetAccount)
	if store.optionally_commit_transaction(trans, w, r) {
		services.Http_respond(w, r, ([]byte)(trans.Id), http.StatusOK)
	}
}
func (payments *Payments) new_payment(w http.ResponseWriter, r *http.Request) {
	value, err := strconv.ParseFloat(r.FormValue("value"), 64)
	if err != nil {
		services.Http_respond_error(w, r, "Failed to parse 'value' parameter to float: "+err.Error(), http.StatusBadRequest)
		return
	}
	username := r.FormValue("user")
	timestamp := r.FormValue("ts")
	payment, existed, err := payments.NewPayment(username, value, timestamp)
	if err != nil {
		services.Http_respond_error(w, r, "Error creating payment: "+err.Error(), http.StatusInternalServerError)
	} else {
		var code int
		if existed {
			code = http.StatusOK
		} else {
			code = http.StatusCreated
		}
		services.Http_respond(w, r, ([]byte)(payment.id), code)
	}
}