Exemple #1
0
 def _create_fiscal_sale_data(self, sale):
     store = sale.store
     FiscalSaleHistory(sale=sale,
                       document_type=self._customer_document_type,
                       document=self._customer_document,
                       coo=self.get_coo(),
                       document_counter=self.get_ccf(),
                       store=store)
Exemple #2
0
    def test_complete(self):
        station = self.create_station()
        today = datetime.date(2007, 1, 1)
        reduction_date = datetime.datetime(2007, 1, 1, 23, 59)
        day = FiscalDayHistory(store=self.store,
                               emission_date=today,
                               station=station,
                               serial=u'serial',
                               serial_id=1,
                               coupon_start=1,
                               coupon_end=23,
                               crz=18,
                               cro=25,
                               period_total=Decimal("456.00"),
                               total=Decimal("123141.00"),
                               reduction_date=reduction_date)
        for code, value, type in [(u'2500', Decimal("123.00"), u'ICMS'),
                                  (u'F', Decimal("789.00"), u'ICMS')]:
            FiscalDayTax(fiscal_day_history=day, code=code,
                         value=value, type=type,
                         store=self.store)

        printer = ECFPrinter(
            store=self.store,
            model=u'FS345',
            brand=u'daruma',
            device_name=u'test',
            device_serial=u'serial',
            baudrate=9600,
            station=station,
            user_number=1,
            register_date=today,
            register_cro=1,
        )

        f = CATFile(printer)
        f.software_version = '6.6.6'  # kiko sends <3

        appinfo = get_utility(IAppInfo)
        f.add_software_house(company, appinfo.get('name'),
                             appinfo.get('version'))
        # Cant call add_ecf_identification, since it depends on a
        # conected printer
        # f.add_ecf_identification()

        for item in self.store.find(FiscalDayHistory):
            f.add_z_reduction(item)
            for i, tax in enumerate(item.taxes):
                f.add_z_reduction_details(item, tax, i + 1)

        sale = self.create_sale()
        sale.client = self.create_client()
        sale.confirm_date = today
        sellable = self.add_product(sale, price=100)
        sellable.code = u'09999'

        self.add_payments(sale)
        history = FiscalSaleHistory(store=self.store,
                                    sale=sale)

        f.add_fiscal_coupon(sale, sale.client, history)
        for i, item in enumerate(sale.get_items()):
            f.add_fiscal_coupon_details(sale, sale.client, history,
                                        item, 800, i + 1)

        for payment in sale.payments:
            f.add_payment_method(sale, history, payment)

        diff = compare_files(f, 'cat52')
        self.assertFalse(diff, '%s\n%s' % ("Files differ, output:", diff))