Permalink
Browse files

WHISTLE-1534: ignore previous cdrs

  • Loading branch information...
k-anderson committed Aug 14, 2012
1 parent 90d31d4 commit 2963ab46b2e4261d91452c5086a2eded6dba5b38
Showing with 1 addition and 1 deletion.
  1. +1 −1 whistle_apps/apps/crossbar/priv/couchdb/account/transactions.json
@@ -14,7 +14,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_type=='cdr'){var Secs=doc.billing_seconds||0;var Cost=0;if(Secs>=1){var R=parseFloat(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;R=Math.round(R*10000);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){emit(doc._id,Cost)}else{return}}else if((doc.pvt_type=='credit'||doc.pvt_type=='debit')&&doc.call_id&&doc.account_id==doc.pvt_account_id){var modifier=(doc.pvt_type=='credit'?1:-1);emit(doc.call_id,doc.amount*modifier)}else{return}}",
+ "map": "function (doc) {if (doc.pvt_created < 63512380800) return;if (doc.pvt_type == 'cdr') {var Secs = doc.billing_seconds || 0;var Cost = 0;if (Secs >= 1) {var R = parseFloat(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;R = Math.round(R * 10000);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) {emit(doc._id, Cost)} else {return}} else if ((doc.pvt_type == 'credit' || doc.pvt_type == 'debit') && doc.call_id && doc.account_id == doc.pvt_account_id) {var modifier = (doc.pvt_type == 'credit' ? 1 : -1);emit(doc.call_id, doc.amount * modifier)} else {return}}",
"reduce": "_sum"
}
}

0 comments on commit 2963ab4

Please sign in to comment.