Add importer for tax rates from CORE
This commit is contained in:
parent
6ef2e67f76
commit
cf90ca5704
5 changed files with 122 additions and 1 deletions
|
@ -67,6 +67,7 @@ class FromCOREPOSToRattail(importing.FromSQLAlchemyHandler, importing.ToRattailH
|
|||
def get_importers(self):
|
||||
importers = OrderedDict()
|
||||
importers['Employee'] = EmployeeImporter
|
||||
importers['Tax'] = TaxImporter
|
||||
importers['Tender'] = TenderImporter
|
||||
importers['Vendor'] = VendorImporter
|
||||
importers['Department'] = DepartmentImporter
|
||||
|
@ -114,6 +115,28 @@ class EmployeeImporter(FromCOREPOS, corepos_importing.model.EmployeeImporter):
|
|||
}
|
||||
|
||||
|
||||
class TaxImporter(FromCOREPOS, corepos_importing.model.TaxImporter):
|
||||
"""
|
||||
Importer for tax data from CORE POS.
|
||||
"""
|
||||
host_model_class = corepos.TaxRate
|
||||
key = 'corepos_id'
|
||||
supported_fields = [
|
||||
'corepos_id',
|
||||
'code',
|
||||
'description',
|
||||
'rate',
|
||||
]
|
||||
|
||||
def normalize_host_object(self, tax):
|
||||
return {
|
||||
'corepos_id': tax.id,
|
||||
'code': str(tax.id),
|
||||
'description': tax.description,
|
||||
'rate': decimal.Decimal(str(tax.rate * 100)),
|
||||
}
|
||||
|
||||
|
||||
class TenderImporter(FromCOREPOS, corepos_importing.model.TenderImporter):
|
||||
"""
|
||||
Importer for tender data from CORE POS.
|
||||
|
@ -253,6 +276,7 @@ class ProductImporter(FromCOREPOS, corepos_importing.model.ProductImporter):
|
|||
'regular_price_type',
|
||||
'food_stampable',
|
||||
# 'tax1',
|
||||
'tax_code',
|
||||
]
|
||||
|
||||
def normalize_host_object(self, product):
|
||||
|
@ -286,6 +310,8 @@ class ProductImporter(FromCOREPOS, corepos_importing.model.ProductImporter):
|
|||
'regular_price_price': price,
|
||||
'regular_price_multiple': 1 if price is not None else None,
|
||||
'regular_price_type': self.enum.PRICE_TYPE_REGULAR if price is not None else None,
|
||||
|
||||
'tax_code': str(product.tax_rate.id) if product.tax_rate_id else None,
|
||||
}
|
||||
|
||||
if self.fields_active(self.size_fields):
|
||||
|
|
|
@ -131,6 +131,15 @@ class SubdepartmentImporter(importing.model.SubdepartmentImporter):
|
|||
}
|
||||
|
||||
|
||||
class TaxImporter(importing.model.TaxImporter):
|
||||
|
||||
extensions = {
|
||||
'_corepos': [
|
||||
'corepos_id',
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
class TenderImporter(importing.model.TenderImporter):
|
||||
|
||||
extensions = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue