()
| 272 | } |
| 273 | |
| 274 | handlePayments () { |
| 275 | let url = '/db/payments/-/all?nofree=true&project=created,gems,service,amount,productID,prepaidID,currency' |
| 276 | if (utils.getQueryVariable('gtObjectId')) { |
| 277 | url = `${url}>ObjectId=${utils.getQueryVariable('gtObjectId')}` |
| 278 | } |
| 279 | return this.supermodel.addRequestResource({ |
| 280 | url, |
| 281 | method: 'GET', |
| 282 | success: data => { |
| 283 | let dailyGroup, day, group, i, monthlyGroup, revenue, week |
| 284 | const revenueGroupFromPayment = function (payment, price) { |
| 285 | let product = payment.productID || payment.service |
| 286 | const lifetimeToAnnualChange = '2020-11-09' |
| 287 | if (payment.productID === 'lifetime_subscription') { |
| 288 | product = 'usa lifetime' |
| 289 | } else if (/_lifetime_subscription/.test(payment.productID)) { |
| 290 | product = 'intl lifetime' |
| 291 | } else if (utils.isCodeCombat && ((payment.productID === 'basic_subscription') || !payment.productID) && (price === 9900) && (payment.created > lifetimeToAnnualChange)) { |
| 292 | product = 'usa annual' |
| 293 | } else if (payment.productID === 'basic_subscription') { |
| 294 | product = 'usa monthly' |
| 295 | } else if (utils.isCodeCombat && (/_basic_subscription/.test(payment.productID) || !payment.productID) && ([3960, 3999].includes(price)) && (payment.created > lifetimeToAnnualChange)) { |
| 296 | product = 'intl annual' |
| 297 | } else if (/_basic_subscription/.test(payment.productID)) { |
| 298 | product = 'intl monthly' |
| 299 | } else if (/gems/.test(payment.productID)) { |
| 300 | product = 'gems' |
| 301 | } else if (payment.prepaidID) { |
| 302 | if ((price % 9.99) === 0 || (price % 999) === 0) { |
| 303 | product = 'usa monthly' |
| 304 | } else { |
| 305 | // NOTE: assumed to be classroom starter licenses |
| 306 | product = 'classroom' |
| 307 | } |
| 308 | } else if (payment.service === 'stripe') { |
| 309 | if (payment.currency === 'usd') { |
| 310 | if (payment.gems === 3500) { |
| 311 | product = 'usa monthly' |
| 312 | } else if (payment.gems === 42000) { |
| 313 | product = 'usa annual' |
| 314 | } else if (payment.gems === 1500) { |
| 315 | product = 'intl monthly' |
| 316 | } else if (payment.gems === 42000) { |
| 317 | product = 'intl annual' |
| 318 | } |
| 319 | } else if (payment.currency && (payment.currency !== 'usd')) { |
| 320 | if (payment.gems === 3500) { |
| 321 | product = 'intl monthly' |
| 322 | } else if (payment.gems === 1500) { |
| 323 | product = 'intl monthly' |
| 324 | } else if (payment.gems === 42000) { |
| 325 | product = 'intl annual' |
| 326 | } |
| 327 | } else if (((price === 399) || (price === 400)) && !payment.currency) { |
| 328 | product = 'intl monthly' |
| 329 | } else if (((price === 999) || (price === 799)) && !payment.currency) { |
| 330 | product = 'usa monthly' |
| 331 | } else if ((price === 599) && (payment.gems === 3500) && !payment.currency) { |
no test coverage detected