コード例 #1
0
ファイル: utils.py プロジェクト: iniForum/tendenci
def donation_inv_add(user, donation, **kwargs):
    inv = Invoice()
    inv.title = "Donation Invoice"
    inv.bill_to = donation.first_name + ' ' + donation.last_name
    inv.bill_to_first_name = donation.first_name
    inv.bill_to_last_name = donation.last_name
    inv.bill_to_company = donation.company
    inv.bill_to_address = donation.address
    inv.bill_to_city = donation.city
    inv.bill_to_state = donation.state
    inv.bill_to_zip_code = donation.zip_code
    inv.bill_to_country = donation.country
    inv.bill_to_phone = donation.phone
    inv.bill_to_email = donation.email
    inv.ship_to = donation.first_name + ' ' + donation.last_name
    inv.ship_to_first_name = donation.first_name
    inv.ship_to_last_name = donation.last_name
    inv.ship_to_company = donation.company
    inv.ship_to_address = donation.address
    inv.ship_to_city = donation.city
    inv.ship_to_state = donation.state
    inv.ship_to_zip_code = donation.zip_code
    inv.ship_to_country = donation.country
    inv.ship_to_phone = donation.phone
    #self.ship_to_fax = make_payment.fax
    inv.ship_to_email = donation.email
    inv.terms = "Due on Receipt"
    inv.due_date = datetime.now()
    inv.ship_date = datetime.now()
    inv.message = 'Thank You.'
    inv.status = True

    if donation.donate_to_entity:
        inv.entity = donation.donate_to_entity

    inv.estimate = True
    inv.status_detail = 'tendered'
    inv.object_type = ContentType.objects.get(
        app_label=donation._meta.app_label, model=donation._meta.model_name)
    inv.object_id = donation.id
    inv.subtotal = donation.donation_amount
    inv.total = donation.donation_amount
    inv.balance = donation.donation_amount

    inv.save(user)
    donation.invoice = inv

    return inv
コード例 #2
0
ファイル: utils.py プロジェクト: MohammedRashidKP/tencenci
def corp_memb_inv_add(user, corp_memb, app=None, **kwargs):
    """
    Add an invoice for this corporate membership
    """
    corp_profile = corp_memb.corp_profile
    renewal = kwargs.get('renewal', False)
    renewal_total = kwargs.get('renewal_total', 0)
    if not corp_memb.invoice or renewal:
        inv = Invoice()
        inv.entity = corp_profile.entity
        inv.object_type = ContentType.objects.get(
            app_label=corp_memb._meta.app_label,
            model=corp_memb._meta.model_name)
        inv.object_id = corp_memb.id
        inv.title = corp_memb.corp_profile.name

        if not user.is_anonymous:
            inv.bill_to = '%s %s' % (user.first_name, user.last_name)
            inv.bill_to_first_name = user.first_name
            inv.bill_to_last_name = user.last_name
            inv.bill_to_email = user.email
            inv.set_creator(user)
            inv.set_owner(user)
        else:
            if corp_memb.anonymous_creator:
                cmc = corp_memb.anonymous_creator
                inv.bill_to = '%s %s' % (cmc.first_name, cmc.last_name)
                inv.bill_to_first_name = cmc.first_name
                inv.bill_to_last_name = cmc.last_name
                inv.bill_to_email = cmc.email
            else:
                inv.bill_to = corp_memb.name

        inv.bill_to_company = corp_profile.name
        inv.bill_to_address = corp_profile.address
        inv.bill_to_city = corp_profile.city
        inv.bill_to_state = corp_profile.state
        inv.bill_to_zip_code = corp_profile.zip
        inv.bill_to_country = corp_profile.country
        inv.bill_to_phone = corp_profile.phone
        inv.ship_to = corp_profile.name
        inv.ship_to_company = corp_profile.name
        inv.ship_to_address = corp_profile.address
        inv.ship_to_city = corp_profile.city
        inv.ship_to_state = corp_profile.state
        inv.ship_to_zip_code = corp_profile.zip
        inv.ship_to_country = corp_profile.country
        inv.ship_to_phone = corp_profile.phone
        inv.ship_to_email = corp_profile.email
        inv.terms = "Due on Receipt"
        inv.due_date = datetime.now()
        inv.ship_date = datetime.now()
        inv.message = 'Thank You.'
        inv.status = True

        if not renewal:
            inv.total = corp_memb.corporate_membership_type.price
        else:
            inv.total = renewal_total
        inv.subtotal = inv.total
        inv.balance = inv.total

        tax = 0
        if app and app.include_tax:
            tax = inv.total * app.tax_rate
            inv.tax = tax
            total = inv.total + tax
            inv.subtotal = total
            inv.total = total
            inv.balance = total

        inv.estimate = True
        inv.status_detail = 'estimate'
        inv.save(user)

        if not corp_memb.payment_method:
            is_online = True
            if inv.balance <= 0:
                is_online = False
            corp_memb.payment_method = corp_memb.get_payment_method(
                is_online=is_online)

        if user.profile.is_superuser:
            # if offline payment method
            if not corp_memb.payment_method.is_online:
                inv.tender(user)  # tendered the invoice for admin if offline

                # mark payment as made
                payment = Payment()
                payment.payments_pop_by_invoice_user(user, inv, inv.guid)
                payment.mark_as_paid()
                payment.method = corp_memb.payment_method.machine_name
                payment.save(user)

                # this will make accounting entry
                inv.make_payment(user, payment.amount)
        return inv
    return None
コード例 #3
0
ファイル: utils.py プロジェクト: tendenci/tendenci
def corp_memb_inv_add(user, corp_memb, app=None, **kwargs):
    """
    Add an invoice for this corporate membership
    """
    corp_profile = corp_memb.corp_profile
    renewal = kwargs.get('renewal', False)
    renewal_total = kwargs.get('renewal_total', 0)
    if not corp_memb.invoice or renewal:
        inv = Invoice()
        inv.entity = corp_profile.entity
        inv.object_type = ContentType.objects.get(
                                      app_label=corp_memb._meta.app_label,
                                      model=corp_memb._meta.model_name)
        inv.object_id = corp_memb.id
        inv.title = corp_memb.corp_profile.name

        if not user.is_anonymous:
            inv.bill_to = '%s %s' % (user.first_name, user.last_name)
            inv.bill_to_first_name = user.first_name
            inv.bill_to_last_name = user.last_name
            inv.bill_to_email = user.email
            inv.set_creator(user)
            inv.set_owner(user)
        else:
            if corp_memb.anonymous_creator:
                cmc = corp_memb.anonymous_creator
                inv.bill_to = '%s %s' % (cmc.first_name, cmc.last_name)
                inv.bill_to_first_name = cmc.first_name
                inv.bill_to_last_name = cmc.last_name
                inv.bill_to_email = cmc.email
            else:
                inv.bill_to = corp_memb.name

        inv.bill_to_company = corp_profile.name
        inv.bill_to_address = corp_profile.address
        inv.bill_to_city = corp_profile.city
        inv.bill_to_state = corp_profile.state
        inv.bill_to_zip_code = corp_profile.zip
        inv.bill_to_country = corp_profile.country
        inv.bill_to_phone = corp_profile.phone
        inv.ship_to = corp_profile.name
        inv.ship_to_company = corp_profile.name
        inv.ship_to_address = corp_profile.address
        inv.ship_to_city = corp_profile.city
        inv.ship_to_state = corp_profile.state
        inv.ship_to_zip_code = corp_profile.zip
        inv.ship_to_country = corp_profile.country
        inv.ship_to_phone = corp_profile.phone
        inv.ship_to_email = corp_profile.email
        inv.terms = "Due on Receipt"
        inv.due_date = datetime.now()
        inv.ship_date = datetime.now()
        inv.message = 'Thank You.'
        inv.status = True

        if not renewal:
            inv.total = corp_memb.corporate_membership_type.price
        else:
            inv.total = renewal_total
        inv.subtotal = inv.total
        inv.balance = inv.total

        tax = 0
        if app and app.include_tax:
            tax = inv.total * app.tax_rate
            inv.tax = tax
            total = inv.total + tax
            inv.subtotal =total
            inv.total = total
            inv.balance = total

        inv.estimate = True
        inv.status_detail = 'estimate'
        inv.save(user)

        if not corp_memb.payment_method:
            is_online = True
            if inv.balance <= 0:
                is_online = False
            corp_memb.payment_method = corp_memb.get_payment_method(
                                            is_online=is_online)

        if user.profile.is_superuser:
            # if offline payment method
            if not corp_memb.payment_method.is_online:
                inv.tender(user)  # tendered the invoice for admin if offline

                # mark payment as made
                payment = Payment()
                payment.payments_pop_by_invoice_user(user, inv, inv.guid)
                payment.mark_as_paid()
                payment.method = corp_memb.payment_method.machine_name
                payment.save(user)

                # this will make accounting entry
                inv.make_payment(user, payment.amount)
        return inv
    return None