コード例 #1
0
ファイル: load_data.py プロジェクト: Ryati/satchmo
def load_US_tax_table():
    """ Load a simple sales tax table for the US """
    from product.models import TaxClass
    from tax.modules.area.models import TaxRate
    from l10n.models import AdminArea, Country
    us = Country.objects.get(iso2_code="US")
    defaultTax, created = TaxClass.objects.get_or_create(description="Default", title="Default")
    if created:
        defaultTax.save()
    dataFile = "tax-table.csv"
    dataDir = os.path.join(settings.DIRNAME,"tax/data")
    reader = csv.reader(open(os.path.join(dataDir, dataFile), "rb"))
    reader.next()       #Skip the header row
    for row in reader:
        state = AdminArea.objects.get(country=us, abbrev=row[0])
        stateTax = TaxRate(taxClass=defaultTax, taxZone=state, percentage=row[1])
        stateTax.save()        
コード例 #2
0
def load_US_tax_table():
    """ Load a simple sales tax table for the US """
    from product.models import TaxClass
    from tax.modules.area.models import TaxRate
    from l10n.models import AdminArea, Country
    us = Country.objects.get(iso2_code="US")
    defaultTax, created = TaxClass.objects.get_or_create(description="Default",
                                                         title="Default")
    if created:
        defaultTax.save()
    dataFile = "tax-table.csv"
    dataDir = os.path.join(settings.DIRNAME, "tax/data")
    reader = csv.reader(open(os.path.join(dataDir, dataFile), "rb"))
    reader.next()  #Skip the header row
    for row in reader:
        state = AdminArea.objects.get(country=us, abbrev=row[0])
        stateTax = TaxRate(taxClass=defaultTax,
                           taxZone=state,
                           percentage=row[1])
        stateTax.save()
コード例 #3
0
ファイル: models.py プロジェクト: mpango/satchmo-multishop
"""
Add a relationship with 'site' to existing (satchmo) models where required.
This allows us to use site / shop specific behaviour for all aspects needed.
"""
#
# product
#
TaxClass.add_to_class('site', models.ForeignKey(Site, blank=True, null=True))

AttributeOption.add_to_class('site', models.ForeignKey(Site, blank=True,
	null=True))

#
#
#
TaxRate.add_to_class('site', models.ForeignKey(Site, blank=True, null=True))

#
# satchmo_store.contact
#
ContactInteractionType.add_to_class('site', models.ForeignKey(Site,
	blank=True, null=True))

ContactOrganizationRole.add_to_class('site', models.ForeignKey(Site,
	blank=True, null=True))

ContactRole.add_to_class('site', models.ForeignKey(Site, blank=True,
	null=True))

Interaction.add_to_class('site', models.ForeignKey(Site, blank=True,
	null=True))