예제 #1
0
    def test_next_charge_date(self):
        self.set_datastore_hr_probability(1)

        order, _ = self._create_customer_and_subscription_order([u'MSUP', u'BEAC', u'KSUP', u'ILOS'])

        next_charge_dt = datetime.datetime.utcfromtimestamp(order.next_charge_date)
        self.assertGreater(next_charge_dt, datetime.datetime.utcfromtimestamp(today() + 2 * 363 * 86400))
        self.assertLess(next_charge_dt, datetime.datetime.utcfromtimestamp(today() + 2 * 366 * 86400))

        order_key = recurrentbilling._qry(order.next_charge_date + 86400).get()
        self.assertEqual(order.key(), order_key)
예제 #2
0
def create_task_if_not_order(customer_id):
    customer = Customer.get_by_id(customer_id)
    # Check if the customer has linked his credit card after he clicked the 'pay' button
    # If he didn't (one hour after the last time he tried to pay), create a new ShopTask to call this customer.
    if not customer.stripe_valid and customer.team_id:
        if customer.prospect_id:
            rmt, prospect = db.get([
                RegioManagerTeam.create_key(customer.team_id),
                Prospect.create_key(customer.prospect_id)
            ])
        else:
            prospect = create_prospect_from_customer(customer)
            rmt = RegioManagerTeam.get(
                RegioManagerTeam.create_key(customer.team_id))
        azzert(rmt.support_manager,
               'No support manager found for team %s' % rmt.name)
        task = create_task(
            prospect_or_key=prospect,
            status=ShopTask.STATUS_NEW,
            task_type=ShopTask.TYPE_SUPPORT_NEEDED,
            address=None,
            created_by=STORE_MANAGER.email(),
            assignee=rmt.support_manager,
            execution_time=today() + 86400 + 11 * 3600,  # tomorrow, 11:00,
            app_id=prospect.app_id,
            comment=u"Customer wanted to pay an order in the customer store, "
            "but didn't succeed because he did not link his creditcard.",
            notify_by_email=True)
        task.put()
예제 #3
0
def get_expired_vouchers(app_id, cursor=None, limit=50):
    parnet_key = SolutionCityVoucher.create_parent_key(app_id)
    qry = SolutionCityVoucher.all().with_cursor(cursor).ancestor(parnet_key)
    qry.filter('expiration_date <=', today()).order('-expiration_date')
    data = qry.fetch(limit)
    new_cursor = unicode(qry.cursor())
    has_more = new_cursor != cursor
    return new_cursor, data, has_more
예제 #4
0
def export_reseller_invoices_this_week():
    current_date = datetime.datetime.utcfromtimestamp(today())
    current_weekday = current_date.weekday()
    beginning_of_current_week = current_date - datetime.timedelta(days=current_weekday)
    start_of_last_week = datetime.timedelta(weeks=1)
    last_week = beginning_of_current_week - start_of_last_week
    start_timestamp = time.mktime(last_week.utctimetuple())
    end_timestamp = time.mktime(beginning_of_current_week.utctimetuple())
    export_reseller_invoices(int(start_timestamp), int(end_timestamp), True)
예제 #5
0
def create_task_for_order(customer_team_id, prospect_id, order_number):
    team, prospect = db.get([
        RegioManagerTeam.create_key(customer_team_id),
        Prospect.create_key(prospect_id)
    ])
    azzert(team.support_manager,
           u'No support manager found for team %s' % team.name)
    comment = u'Customer placed a new order: %s' % (order_number)
    task = create_task(
        created_by=STORE_MANAGER.email(),
        prospect_or_key=prospect,
        app_id=prospect.app_id,
        status=ShopTask.STATUS_NEW,
        task_type=ShopTask.TYPE_SUPPORT_NEEDED,
        address=None,
        assignee=team.support_manager,
        comment=comment,
        execution_time=today() + 86400 + 11 * 3600,  # tomorrow at 11:00
        notify_by_email=True)
    task.put()
    broadcast_task_updates([team.support_manager])
 def create_cloudstorage_path(user):
     # type: (str) -> str
     return '/'.join([FRIEND_HELPER_BUCKET, str(today()), user, guid()])
예제 #7
0
 def expired(self):
     return self.expiration_date and self.expiration_date <= today()
예제 #8
0
def expired_vouchers_reminder():
    run_job(city_vouchers_enabled_qry, [], remind_user_with_expired_vouchers,
            [today()])