コード例 #1
0
ファイル: sellabledialog.py プロジェクト: tmaxter/stoq
 def delete_model(self, model, store):
     sellables = store.find(Sellable, tax_constant=model)
     quantity = sellables.count()
     if quantity > 0:
         msg = _(u"You can't remove this tax, since %d products or "
                 "services are taxed with '%s'.") % (
                     quantity, model.get_description())
         info(msg)
     else:
         SellableTaxConstant.delete(model.id, store=store)
コード例 #2
0
ファイル: parameters.py プロジェクト: esosaja/stoq
    def _set_product_tax_constant_default(self, store):
        if self.has_object("DEFAULT_PRODUCT_TAX_CONSTANT"):
            return

        from stoqlib.domain.sellable import SellableTaxConstant
        tax_constant = SellableTaxConstant.get_by_type(TaxType.NONE, store)
        self.set_object(store, "DEFAULT_PRODUCT_TAX_CONSTANT", tax_constant)
コード例 #3
0
 def create_sellable_tax_constant(self):
     from stoqdrivers.enum import TaxType
     from stoqlib.domain.sellable import SellableTaxConstant
     return SellableTaxConstant(description=u"18",
                                tax_type=int(TaxType.CUSTOM),
                                tax_value=18,
                                store=self.store)
コード例 #4
0
    def _set_product_tax_constant_default(self, store):
        if self.has_object("DEFAULT_PRODUCT_TAX_CONSTANT"):
            return

        from stoqlib.domain.sellable import SellableTaxConstant
        tax_constant = SellableTaxConstant.get_by_type(TaxType.NONE, store)
        self.set_object(store, "DEFAULT_PRODUCT_TAX_CONSTANT", tax_constant)
コード例 #5
0
 def create_model(self, store):
     tax_constant = SellableTaxConstant.get_by_type(TaxType.SERVICE, self.store)
     sellable = Sellable(description=u"", price=currency(0), store=store)
     sellable.tax_constant = tax_constant
     sellable.unit_id = sysparam.get_object_id("SUGGESTED_UNIT")
     model = Service(sellable=sellable, store=store)
     return model
コード例 #6
0
ファイル: serviceeditor.py プロジェクト: pauloscarin1972/stoq
 def create_model(self, store):
     tax_constant = SellableTaxConstant.get_by_type(TaxType.SERVICE,
                                                    self.store)
     sellable = Sellable(description=u'', price=currency(0), store=store)
     sellable.tax_constant = tax_constant
     sellable.unit_id = sysparam.get_object_id('SUGGESTED_UNIT')
     model = Service(sellable=sellable, store=store)
     return model
コード例 #7
0
    def __init__(self):
        super(ServiceImporter, self).__init__()
        default_store = get_default_store()
        self.tax_constant = SellableTaxConstant.get_by_type(
            TaxType.SERVICE, default_store)

        self._code = 11
        assert self.tax_constant
コード例 #8
0
    def __init__(self):
        super(ServiceImporter, self).__init__()
        default_store = get_default_store()
        self.tax_constant = SellableTaxConstant.get_by_type(
            TaxType.SERVICE, default_store)

        self._code = 11
        assert self.tax_constant
コード例 #9
0
 def test_get_tax_constant_for_device_invalid_tax_value(self):
     sellable = self.create_sellable()
     sellable.tax_constant = SellableTaxConstant(
         store=self.store,
         description=u'',
         tax_value=decimal.Decimal('3.1415'),
         tax_type=int(TaxType.CUSTOM))
     self.assertRaises(
         DeviceError, self.ecf_printer.get_tax_constant_for_device, sellable)
コード例 #10
0
    def _create_product_tax_constant(self):
        from stoqlib.domain.sellable import SellableTaxConstant
        key = u"DEFAULT_PRODUCT_TAX_CONSTANT"
        if self.get_parameter_by_field(key, SellableTaxConstant):
            return

        tax_constant = SellableTaxConstant.get_by_type(
            TaxType.NONE, self.store)
        self._set_schema(key, tax_constant.id)
コード例 #11
0
ファイル: exampledata.py プロジェクト: rg3915/stoq
    def create_service(self, description=u"Description", price=10):
        from stoqlib.domain.sellable import Sellable, SellableTaxConstant
        from stoqlib.domain.service import Service

        tax_constant = SellableTaxConstant.get_by_type(TaxType.SERVICE, self.store)
        sellable = Sellable(price=price, description=description, store=self.store)
        sellable.tax_constant = tax_constant
        service = Service(sellable=sellable, store=self.store)
        return service
コード例 #12
0
ファイル: parameters.py プロジェクト: esosaja/stoq
 def _set_delivery_default(self, store):
     if self.has_object("DELIVERY_SERVICE"):
         return
     from stoqlib.domain.sellable import (Sellable, SellableTaxConstant)
     from stoqlib.domain.service import Service
     tax_constant = SellableTaxConstant.get_by_type(TaxType.SERVICE, store)
     sellable = Sellable(store=store, description=_(u'Delivery'))
     sellable.tax_constant = tax_constant
     service = Service(sellable=sellable, store=store)
     self.set_object(store, "DELIVERY_SERVICE", service)
コード例 #13
0
ファイル: serviceeditor.py プロジェクト: romaia/stoq
 def create_model(self, store):
     tax_constant = SellableTaxConstant.get_by_type(TaxType.SERVICE, self.store)
     sellable = Sellable(description=u'',
                         price=currency(0),
                         store=store)
     sellable.status = Sellable.STATUS_AVAILABLE
     sellable.tax_constant = tax_constant
     sellable.unit = sysparam(self.store).SUGGESTED_UNIT
     model = Service(sellable=sellable, store=store)
     return model
コード例 #14
0
 def create_service(self, description=u'Description', price=10):
     from stoqlib.domain.sellable import Sellable, SellableTaxConstant
     from stoqlib.domain.service import Service
     tax_constant = SellableTaxConstant.get_by_type(TaxType.SERVICE,
                                                    self.store)
     sellable = Sellable(price=price,
                         description=description,
                         store=self.store)
     sellable.tax_constant = tax_constant
     service = Service(sellable=sellable, store=self.store)
     return service
コード例 #15
0
    def _set_delivery_default(self, store):
        if self.has_object("DELIVERY_SERVICE"):
            return
        from stoqlib.domain.sellable import Sellable, SellableTaxConstant
        from stoqlib.domain.service import Service

        tax_constant = SellableTaxConstant.get_by_type(TaxType.SERVICE, store)
        sellable = Sellable(store=store, description=_(u"Delivery"))
        sellable.tax_constant = tax_constant
        service = Service(sellable=sellable, store=store)
        self.set_object(store, "DELIVERY_SERVICE", service)
コード例 #16
0
 def create_delivery_service(self):
     from stoqlib.domain.sellable import (Sellable,
                                          SellableTaxConstant)
     from stoqlib.domain.service import Service
     key = u"DELIVERY_SERVICE"
     store = new_store()
     tax_constant = SellableTaxConstant.get_by_type(TaxType.SERVICE, store)
     sellable = Sellable(description=_(u'Delivery'),
                         store=store)
     sellable.tax_constant = tax_constant
     service = Service(sellable=sellable, store=store)
     self._set_schema(key, service.id)
     store.commit(close=True)
コード例 #17
0
 def _add_product(self, sale, tax=None, price=None, code=None):
     product = self.create_product(price=price)
     sellable = product.sellable
     if code:
         sellable.code = code
     sellable.tax_constant = SellableTaxConstant(
         description=unicode(tax),
         tax_type=int(TaxType.CUSTOM),
         tax_value=tax,
         store=self.store)
     sale.add_sellable(sellable, quantity=1)
     self.create_storable(product, get_current_branch(self.store), stock=100)
     return sellable
コード例 #18
0
ファイル: test_sellable.py プロジェクト: hackedbellini/stoq
    def test_get_value(self):
        constant = SellableTaxConstant(store=self.store,
                                       tax_type=TaxType.NONE)
        self.assertEqual(constant.get_value(), 'TAX_NONE')

        constant = SellableTaxConstant(store=self.store,
                                       tax_type=TaxType.EXEMPTION)
        self.assertEqual(constant.get_value(), 'TAX_EXEMPTION')

        constant = SellableTaxConstant(store=self.store,
                                       tax_type=TaxType.SUBSTITUTION)
        self.assertEqual(constant.get_value(), 'TAX_SUBSTITUTION')

        constant = SellableTaxConstant(store=self.store,
                                       tax_type=TaxType.SERVICE)
        self.assertEqual(constant.get_value(), 'TAX_SERVICE')
コード例 #19
0
ファイル: admin.py プロジェクト: 5l1v3r1/stoq-1
def ensure_sellable_constants(store):
    """ Create native sellable constants. """
    log.info("Creating sellable units")
    unit_list = [(u"Kg", UnitType.WEIGHT), (u"Lt", UnitType.LITERS),
                 (u"m ", UnitType.METERS)]
    for desc, enum in unit_list:
        SellableUnit(description=desc, unit_index=int(enum), store=store)

    log.info("Creating sellable tax constants")
    for enum in [
            TaxType.SUBSTITUTION, TaxType.EXEMPTION, TaxType.NONE,
            TaxType.SERVICE
    ]:
        desc = describe_constant(enum)
        SellableTaxConstant(description=desc,
                            tax_type=int(enum),
                            tax_value=None,
                            store=store)
コード例 #20
0
ファイル: test_sellable.py プロジェクト: victornovy/stoq
 def test_get_description(self):
     constant = SellableTaxConstant(store=self.store, description=u'foo')
     self.assertEqual(constant.get_description(), u'foo')
コード例 #21
0
    def _populate_constants(self, model, status):
        driver = status.get_driver()
        for tax_enum, device_value, value in driver.get_tax_constants():
            if tax_enum == TaxType.CUSTOM:
                constant = self.store.find(SellableTaxConstant,
                                           tax_value=value).one()
                # If the constant is not defined in the system, create it
                if not constant:
                    constant = SellableTaxConstant(
                        tax_value=value,
                        tax_type=int(TaxType.CUSTOM),
                        description=u'%0.2f %%' % value,
                        store=self.store)
            elif tax_enum == TaxType.SERVICE:
                constant = self.store.find(DeviceConstant,
                                           constant_enum=int(tax_enum),
                                           printer=model).one()
                # Skip, If we have a service tax defined for this printer
                # This needs to be improved when we support more than one
                # service tax
                if constant is not None:
                    continue
            else:
                constant = self.store.find(SellableTaxConstant,
                                           tax_type=int(tax_enum)).one()
                # Ignore if its unkown tax
                if not constant:
                    continue

            if value:
                constant_name = u'%0.2f %%' % (value, )
            elif constant:
                constant_name = constant.description
            else:
                constant_name = None
            DeviceConstant(constant_enum=int(tax_enum),
                           constant_name=constant_name,
                           constant_type=DeviceConstant.TYPE_TAX,
                           constant_value=value,
                           device_value=device_value,
                           printer=model,
                           store=self.store)

        # This is going to be ugly, most printers don't support
        # a real constant for the payment methods, so we have to look
        # at the description and guess
        payment_enums = {
            'dinheiro': PaymentMethodType.MONEY,
            'cheque': PaymentMethodType.CHECK,
            'boleto': PaymentMethodType.BILL,
            'cartao credito': PaymentMethodType.CREDIT_CARD,
            'cartao debito': PaymentMethodType.DEBIT_CARD,
            'financeira': PaymentMethodType.FINANCIAL,
            'vale compra': PaymentMethodType.GIFT_CERTIFICATE
        }

        payment_methods = []
        for device_value, constant_name in driver.get_payment_constants():
            lower = constant_name.lower()
            lower = lower.replace('é', 'e')  # Workaround method names with
            lower = lower.replace('ã', 'a')  # accents
            payment_enum = payment_enums.get(lower)
            if payment_enum is None:
                continue

            # Avoid register the same method twice for the same device
            if payment_enum in payment_methods:
                continue
            DeviceConstant(constant_enum=int(payment_enum),
                           constant_name=unicode(constant_name),
                           constant_type=DeviceConstant.TYPE_PAYMENT,
                           constant_value=None,
                           device_value=device_value,
                           printer=model,
                           store=self.store)
            payment_methods.append(payment_enum)
コード例 #22
0
 def create_model(self, store):
     return SellableTaxConstant(tax_type=int(TaxType.CUSTOM),
                                tax_value=None,
                                description=u'',
                                store=store)
コード例 #23
0
    def test_registers(self):
        order = self.create_receiving_order()
        receiving_invoice = order.receiving_invoice
        order.receival_date = localdate(2007, 6, 1)
        receiving_invoice.discount_value = 10
        # order.purchase.discount_value = 5
        # order.purchase.surcharge_value = 8
        # order.surcharge_value = 15
        receiving_invoice.ipi_total = 10
        receiving_invoice.freight_total = 6
        receiving_invoice.secure_value = 6
        receiving_invoice.expense_value = 12
        supplier = self.create_supplier()
        company = supplier.person.has_individual_or_company_facets()
        company.state_registry = u'103238426117'
        receiving_invoice.supplier = supplier
        employee = self.create_employee()
        branch = get_current_branch(self.store)
        branch.manager = employee

        purchase = order.purchase_orders.find()[0]
        purchase.status = purchase.ORDER_PENDING

        sellable = self.create_sellable()
        sellable.tax_constant = SellableTaxConstant(description=u"18",
                                                    tax_type=int(
                                                        TaxType.CUSTOM),
                                                    tax_value=18,
                                                    store=self.store)
        self.create_receiving_order_item(order, sellable=sellable)

        sellable2 = self.create_sellable()
        sellable2.tax_constant = SellableTaxConstant(description=u"6",
                                                     tax_type=int(
                                                         TaxType.CUSTOM),
                                                     tax_value=6,
                                                     store=self.store)
        self.create_receiving_order_item(order, sellable=sellable2)

        purchase.confirm()
        order.confirm()

        sellable.code = u'9999'
        sellable2.code = u'10000'

        sale = self.create_sale()
        sale.open_date = localdate(2007, 6, 10)

        sellable3 = self.create_sellable()
        product = sellable3.product
        sellable.tax_constant = SellableTaxConstant(description=u"18",
                                                    tax_type=int(
                                                        TaxType.CUSTOM),
                                                    tax_value=18,
                                                    store=self.store)

        sale.add_sellable(sellable3, quantity=1)

        self.create_storable(product,
                             get_current_branch(self.store),
                             stock=100)

        sale.order()

        method = PaymentMethod.get_by_name(self.store, u'money')
        method.create_payment(Payment.TYPE_IN, sale.group, sale.branch,
                              sale.get_sale_subtotal())

        sale.confirm()
        sale.group.pay()
        sale.close_date = localdate(2007, 6, 10)
        sale.confirm_date = localdate(2007, 6, 10)
        sellable3.code = u'09999'

        inventory = self.create_inventory(branch=branch)
        inventory.open_date = localdate(2007, 6, 15)

        # product came from sellable3
        inventory_item = InventoryItem(product=product,
                                       product_cost=product.sellable.cost,
                                       inventory=inventory,
                                       recorded_quantity=99,
                                       store=self.store)
        inventory_item.cfop_data = self.store.find(CfopData).order_by(
            CfopData.code).first()
        inventory_item.reason = u'Test'
        inventory_item.actual_quantity = 99
        inventory_item.counted_quantity = 99
        inventory_item.adjust(invoice_number=999)
        inventory.close()
        inventory.close_date = localdate(2007, 6, 15)

        generator = StoqlibSintegraGenerator(self.store, localdate(2007, 6, 1),
                                             localdate(2007, 6, 30))

        try:
            compare_sintegra_file(generator.sintegra, 'sintegra-receival')
        except AssertionError as e:
            self.fail(e)
コード例 #24
0
ファイル: serviceeditor.py プロジェクト: pauloscarin1972/stoq
 def get_taxes(self):
     service_tax = SellableTaxConstant.get_by_type(TaxType.SERVICE,
                                                   self.store)
     return [(_(u'No tax'), None), (service_tax.description, service_tax)]
コード例 #25
0
ファイル: test_sellable.py プロジェクト: hackedbellini/stoq
 def test_get_description(self):
     constant = SellableTaxConstant(store=self.store,
                                    description=u'foo')
     self.assertEqual(constant.get_description(), u'foo')
コード例 #26
0
ファイル: serviceeditor.py プロジェクト: LeonamSilva/stoq
 def get_taxes(self):
     service_tax = SellableTaxConstant.get_by_type(TaxType.SERVICE,
                                                   self.store)
     return [(_(u'No tax'), None), (service_tax.description, service_tax)]
コード例 #27
0
ファイル: test_sellable.py プロジェクト: victornovy/stoq
    def test_get_value(self):
        constant = SellableTaxConstant(store=self.store, tax_type=TaxType.NONE)
        self.assertEqual(constant.get_value(), 'TAX_NONE')

        constant = SellableTaxConstant(store=self.store,
                                       tax_type=TaxType.EXEMPTION)
        self.assertEqual(constant.get_value(), 'TAX_EXEMPTION')

        constant = SellableTaxConstant(store=self.store,
                                       tax_type=TaxType.SUBSTITUTION)
        self.assertEqual(constant.get_value(), 'TAX_SUBSTITUTION')

        constant = SellableTaxConstant(store=self.store,
                                       tax_type=TaxType.SERVICE)
        self.assertEqual(constant.get_value(), 'TAX_SERVICE')