diff --git a/app/assets/javascripts/admin/api.js b/app/assets/javascripts/admin/api.js
index 63a043c60..f3a342e13 100644
--- a/app/assets/javascripts/admin/api.js
+++ b/app/assets/javascripts/admin/api.js
@@ -520,8 +520,8 @@ angular.module('api.bountysource',[]).
});
};
- this.refund_bounty = function(id) {
- return this.call("/admin/bounties/"+id+"/refund", 'POST', function(response) {
+ this.refund_bounty = function(id, is_fraud) {
+ return this.call("/admin/bounties/"+id+"/refund" + (is_fraud ? '?fraud=true' : ''), 'POST', function(response) {
return response;
});
};
diff --git a/app/assets/javascripts/admin/bounties/show.html b/app/assets/javascripts/admin/bounties/show.html
index 689655a05..1546eecff 100644
--- a/app/assets/javascripts/admin/bounties/show.html
+++ b/app/assets/javascripts/admin/bounties/show.html
@@ -23,7 +23,9 @@
Options
Actions
-
+
+
+
diff --git a/app/assets/javascripts/admin/bounties/show.js b/app/assets/javascripts/admin/bounties/show.js
index d087ff0f7..617f66450 100644
--- a/app/assets/javascripts/admin/bounties/show.js
+++ b/app/assets/javascripts/admin/bounties/show.js
@@ -48,9 +48,9 @@ angular.module('app')
return split.transaction.audited;
};
- $scope.refund = function(bounty_id) {
+ $scope.refund = function(bounty_id, is_fraud) {
if (confirm("Are you sure?")) {
- $api.refund_bounty(bounty_id).then(function(response) {
+ $api.refund_bounty(bounty_id, is_fraud).then(function(response) {
if (response.meta.success) {
$window.location.reload();
} else {
diff --git a/app/assets/javascripts/admin/issues/controllers/show.js b/app/assets/javascripts/admin/issues/controllers/show.js
index 33bee5a0b..059706b7c 100644
--- a/app/assets/javascripts/admin/issues/controllers/show.js
+++ b/app/assets/javascripts/admin/issues/controllers/show.js
@@ -27,7 +27,7 @@ angular.module('app')
if (confirm("Are you sure?")) {
angular.forEach($scope.issue.bounties, function(bounty) {
if (bounty.checked && (bounty.status==='active')) {
- $api.refund_bounty(bounty.id).then(function(response) {
+ $api.refund_bounty(bounty.id, false).then(function(response) {
if (response.meta.success) {
angular.forEach($scope.issue.bounties, function(sub_bounty, $index) {
if (sub_bounty.id === bounty.id) {
diff --git a/app/controllers/api/v0/bounties_controller.rb b/app/controllers/api/v0/bounties_controller.rb
index 8f662f57d..2d6315715 100644
--- a/app/controllers/api/v0/bounties_controller.rb
+++ b/app/controllers/api/v0/bounties_controller.rb
@@ -33,7 +33,7 @@ def update
end
def refund
- @bounty.refund!
+ @bounty.refund!(!!params[:fraud])
if @bounty.errors.empty?
render "api/v0/bounties/show"
diff --git a/app/models/bounty.rb b/app/models/bounty.rb
index d06df3d87..5aa98806e 100644
--- a/app/models/bounty.rb
+++ b/app/models/bounty.rb
@@ -227,13 +227,15 @@ def frontend_url
# Refund bounty to the person who created it. The amount refundable is simply
# the amount - (amount * bs fee)
- def refund!
+ def refund!(is_fraud=false)
if refundable?
self.class.transaction do
transaction = Transaction.build do |tr|
- tr.description = "Refund Bounty(#{id}) - Bounty Amount: $#{amount} Refunded: $#{amount}"
+ tr.description = "Refund Bounty(#{id}) #{'FOR FRAUD ' if is_fraud}- Bounty Amount: $#{amount} Refunded: $#{amount}"
tr.splits.create(amount: -amount, item: issue)
- if owner_type == "Team"
+ if is_fraud
+ tr.splits.create(amount: +amount, account: Account::Liability.instance)
+ elsif owner_type == "Team"
tr.splits.create(amount: +amount, item: owner)
else
tr.splits.create(amount: +amount, item: person)
@@ -246,7 +248,7 @@ def refund!
update_attributes status: Status::REFUNDED or raise ActiveRecord::Rollback
# email the backer
- person.send_email :bounty_refunded, bounty: self, transaction: transaction
+ person.send_email :bounty_refunded, bounty: self, transaction: transaction unless is_fraud
end
# update displayed bounty total on issue