Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAZOO-731: Cherry pick accepted commits from pull request #10 #14

Merged
merged 3 commits into from
Apr 3, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/whistle-1.0.0/src/wh_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ a1hash(User, Realm, Password) ->
-spec floor(integer() | float()) -> integer().
floor(X) when X < 0 ->
T = trunc(X),
case X - T =:= 0 of
case X - T == 0 of
'true' -> T;
'false' -> T - 1
end;
Expand All @@ -701,7 +701,7 @@ floor(X) -> trunc(X).
ceiling(X) when X < 0 -> trunc(X);
ceiling(X) ->
T = trunc(X),
case X - T =:= 0 of
case X - T == 0 of
'true' -> T;
'false' -> T + 1
end.
Expand Down
2 changes: 1 addition & 1 deletion whistle_apps/apps/crossbar/priv/couchdb/account/cdrs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"language": "javascript",
"views": {
"crossbar_listing": {
"map": "function (doc) {if (doc.pvt_deleted || doc.pvt_type != 'cdr') return;if (doc.pvt_type == 'cdr' && doc.custom_channel_vars && (doc.custom_channel_vars.account_billing == 'per_minute' || doc.custom_channel_vars.account_billing == 'per_minute_limit') && doc.custom_channel_vars.account_id == doc.pvt_account_id && doc.pvt_vsn && parseInt(doc.pvt_vsn) == 2) {var Secs = (parseInt(doc.billing_seconds) || 0) - (parseInt(doc.custom_channel_vars.billing_seconds_offset) || 0);var Cost = 0;if (Secs >= 1) {var R = parseInt(doc.custom_channel_vars.rate) || 0;var RInc = parseInt(doc.custom_channel_vars.increment) || 60;var RMin = parseInt(doc.custom_channel_vars.rate_minimum) || 0;var Sur = parseInt(doc.custom_channel_vars.surcharge) || 0;if (RInc < 1) {RInc = 60;}if (Secs <= RMin) {Cost = Sur + ((RMin / 60) * R);} else {Cost = Sur + ((RMin / 60) * R) + (Math.ceil((Secs - RMin) / RInc) * ((RInc / 60) * R));}}}if (Cost) {var Discount = (parseInt(doc.custom_channel_vars.discount_percentage) || 0) * 0.01 * Cost;emit(doc.pvt_created, {id: doc._id,caller_id_name: doc.caller_id_name,caller_id_number: doc.caller_id_number,callee_id_name: doc.callee_id_name,callee_id_number: doc.callee_id_number,duration_seconds: doc.duration_seconds,billing_seconds: doc.billing_seconds,timestamp: doc.timestamp,hangup_cause: doc.hangup_cause,other_leg_call_id: doc.other_leg_call_id,owner_id: doc.custom_channel_vars.owner_id,to: doc.to_uri,from: doc.from_uri,inception: doc.custom_channel_vars.inception,cost: Cost - Discount});} else {emit(doc.pvt_created, {id: doc._id,caller_id_name: doc.caller_id_name,caller_id_number: doc.caller_id_number,callee_id_name: doc.callee_id_name,callee_id_number: doc.callee_id_number,duration_seconds: doc.duration_seconds,billing_seconds: doc.billing_seconds,timestamp: doc.timestamp,hangup_cause: doc.hangup_cause,other_leg_call_id: doc.other_leg_call_id,owner_id: doc.custom_channel_vars.owner_id,to: doc.to_uri,from: doc.from_uri,inception: doc.custom_channel_vars.inception});}}"
"map": "function (doc) {if (doc.pvt_deleted || doc.pvt_type != 'cdr') return;if (doc.pvt_type == 'cdr' && doc.custom_channel_vars && (doc.custom_channel_vars.account_billing == 'per_minute' || doc.custom_channel_vars.account_billing == 'per_minute_limit') && doc.custom_channel_vars.account_id == doc.pvt_account_id && doc.pvt_vsn && parseInt(doc.pvt_vsn) == 2) {var Secs = (parseInt(doc.billing_seconds) || 0) - (parseInt(doc.custom_channel_vars.billing_seconds_offset) || 0);var Cost = 0;if (Secs >= 1) {var R = parseInt(doc.custom_channel_vars.rate) || 0;var RInc = parseInt(doc.custom_channel_vars.rate_increment) || 60;var RMin = parseInt(doc.custom_channel_vars.rate_minimum) || 0;var Sur = parseInt(doc.custom_channel_vars.surcharge) || 0;if (RInc < 1) {RInc = 60;}if (Secs <= RMin) {Cost = Sur + ((RMin / 60) * R);} else {Cost = Sur + ((RMin / 60) * R) + (Math.ceil((Secs - RMin) / RInc) * ((RInc / 60) * R));}}}if (Cost) {var Discount = (parseInt(doc.custom_channel_vars.discount_percentage) || 0) * 0.01 * Cost;emit(doc.pvt_created, {id: doc._id,caller_id_name: doc.caller_id_name,caller_id_number: doc.caller_id_number,callee_id_name: doc.callee_id_name,callee_id_number: doc.callee_id_number,duration_seconds: doc.duration_seconds,billing_seconds: doc.billing_seconds,timestamp: doc.timestamp,hangup_cause: doc.hangup_cause,other_leg_call_id: doc.other_leg_call_id,owner_id: doc.custom_channel_vars.owner_id,to: doc.to_uri,from: doc.from_uri,inception: doc.custom_channel_vars.inception,cost: Cost - Discount});} else {emit(doc.pvt_created, {id: doc._id,caller_id_name: doc.caller_id_name,caller_id_number: doc.caller_id_number,callee_id_name: doc.callee_id_name,callee_id_number: doc.callee_id_number,duration_seconds: doc.duration_seconds,billing_seconds: doc.billing_seconds,timestamp: doc.timestamp,hangup_cause: doc.hangup_cause,other_leg_call_id: doc.other_leg_call_id,owner_id: doc.custom_channel_vars.owner_id,to: doc.to_uri,from: doc.from_uri,inception: doc.custom_channel_vars.inception});}}"
},
"listing_by_owner" : {
"map": "function(doc) { if(doc.pvt_deleted || !doc.custom_channel_vars.owner_id || doc.pvt_type != 'cdr') return; emit([doc.custom_channel_vars.owner_id, doc.pvt_created], {'id':doc._id, 'caller_id_name': doc.caller_id_name, 'caller_id_number': doc.caller_id_number, 'callee_id_name': doc.callee_id_name, 'callee_id_number': doc.callee_id_number, 'duration_seconds': doc.duration_seconds, 'timestamp': doc.timestamp, 'hangup_cause':doc.hangup_cause, 'other_leg_call_id':doc.other_leg_call_id, 'call_direction':doc.call_direction, 'to': doc.to_uri, 'from': doc.from_uri, 'inception':doc.custom_channel_vars.inception})}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"map": "function(doc) { if ( (doc.pvt_type != 'credit' && doc.pvt_type != 'debit') || doc.pvt_deleted) return; emit(doc.pvt_created, doc._id); }"
},
"reconcile_by_callid": {
"map": "function (doc) {if (doc.pvt_deleted || (doc.pvt_type != 'cdr' && doc.pvt_type != 'credit' && doc.pvt_type != 'debit') || !doc.pvt_vsn || parseInt(doc.pvt_vsn) != 2) return;if (doc.pvt_type == 'cdr' && doc.custom_channel_vars && (doc.custom_channel_vars.account_billing == 'per_minute' || doc.custom_channel_vars.account_billing == 'per_minute_limit') && doc.custom_channel_vars.account_id == doc.pvt_account_id) {var Secs = (parseInt(doc.billing_seconds) || 0) - (parseInt(doc.custom_channel_vars.billing_seconds_offset) || 0);var Cost = 0;if (Secs >= 1) {var R = parseInt(doc.custom_channel_vars.rate) || 0;var RInc = parseInt(doc.custom_channel_vars.increment) || 60;var RMin = parseInt(doc.custom_channel_vars.rate_minimum) || 0;var Sur = parseInt(doc.custom_channel_vars.surcharge) || 0;if (RInc < 1) {RInc = 60;}if (Secs <= RMin) {Cost = Sur + ((RMin / 60) * R);} else {Cost = Sur + ((RMin / 60) * R) + (Math.ceil((Secs - RMin) / RInc) * ((RInc / 60) * R));}}if (Cost) {var Discount = (parseInt(doc.custom_channel_vars.discount_percentage) || 0) * 0.01 * Cost;emit(doc._id, Cost - Discount);}} else if (doc.pvt_code && parseInt(doc.pvt_code) == 1001 && doc.call_id) {var modifier = (doc.pvt_type == 'credit' ? 1 : -1);var amount = doc.pvt_amount;emit(doc.call_id, amount * modifier);}}",
"map": "function (doc) {if (doc.pvt_deleted || (doc.pvt_type != 'cdr' && doc.pvt_type != 'credit' && doc.pvt_type != 'debit') || !doc.pvt_vsn || parseInt(doc.pvt_vsn) != 2) return;if (doc.pvt_type == 'cdr' && doc.custom_channel_vars && (doc.custom_channel_vars.account_billing == 'per_minute' || doc.custom_channel_vars.account_billing == 'per_minute_limit') && doc.custom_channel_vars.account_id == doc.pvt_account_id) {var Secs = (parseInt(doc.billing_seconds) || 0) - (parseInt(doc.custom_channel_vars.billing_seconds_offset) || 0);var Cost = 0;if (Secs >= 1) {var R = parseInt(doc.custom_channel_vars.rate) || 0;var RInc = parseInt(doc.custom_channel_vars.rate_increment) || 60;var RMin = parseInt(doc.custom_channel_vars.rate_minimum) || 0;var Sur = parseInt(doc.custom_channel_vars.surcharge) || 0;if (RInc < 1) {RInc = 60;}if (Secs <= RMin) {Cost = Sur + ((RMin / 60) * R);} else {Cost = Sur + ((RMin / 60) * R) + (Math.ceil((Secs - RMin) / RInc) * ((RInc / 60) * R));}}if (Cost) {var Discount = (parseInt(doc.custom_channel_vars.discount_percentage) || 0) * 0.01 * Cost;emit(doc._id, Cost - Discount);}} else if (doc.pvt_code && parseInt(doc.pvt_code) == 1001 && doc.call_id) {var modifier = (doc.pvt_type == 'credit' ? 1 : -1);var amount = doc.pvt_amount;emit(doc.call_id, amount * modifier);}}",
"reduce": "_sum"
}
}
Expand Down