EugeneT, учёл в посте со структурой
ещё-бы разобраться с возвратами/разрушениями чеков
есть лог удаления результатов работы кассы (наши сервисмены рекомендовали пользоваться если что-то не работает)
Код:
--------------
select @kassa:=4
--------------
+-----------+
| @kassa:=4 |
+-----------+
| 4 |
+-----------+
1 row in set (0.00 sec)
--------------
select @cash_id:=id from ukm_cash_registers where CR_NUMBER=@kassa
--------------
+--------------+
| @cash_id:=id |
+--------------+
| 100011003 |
+--------------+
1 row in set (0.05 sec)
--------------
select @smena:=220
--------------
+-------------+
| @smena:=220 |
+-------------+
| 220 |
+-------------+
1 row in set (0.00 sec)
--------------
select @shift_id:=@smena
--------------
+-------------------+
| @shift_id:=@smena |
+-------------------+
| 220 |
+-------------------+
1 row in set (0.00 sec)
--------------
select @login_id:=login from trm_out_shift_open where cash_id=@cash_id and id=@shift_id
--------------
+------------------+
| @login_id:=login |
+------------------+
| 793 |
+------------------+
1 row in set (0.00 sec)
--------------
delete from trm_out_logout where cash_id=@cash_id and id>=@shift_id
--------------
Query OK, 302 rows affected (0.06 sec)
--------------
delete from trm_out_login where cash_id=@cash_id and id>=@shift_id
--------------
Query OK, 315 rows affected (0.05 sec)
--------------
select @shift_number:=number from trm_out_shift_open where cash_id=@cash_id and id=@shift_id
--------------
+-----------------------+
| @shift_number:=number |
+-----------------------+
| 220 |
+-----------------------+
1 row in set (0.00 sec)
--------------
select @mo_id:=min(id) from trm_out_moneyoperation where cash_id=@cash_id and shift_number=@shift_number
--------------
+-----------------+
| @mo_id:=min(id) |
+-----------------+
| 716 |
+-----------------+
1 row in set (0.01 sec)
--------------
delete from trm_out_moneyoperation_note where cash_id=@cash_id and moneyoperation>=@mo_id
--------------
Query OK, 15 rows affected (0.05 sec)
--------------
delete from trm_out_moneyoperation where cash_id=@cash_id and id>=@mo_id
--------------
Query OK, 15 rows affected (0.03 sec)
--------------
select @header_id:=min(id) from trm_out_receipt_header where cash_id=@cash_id and shift_open=@shift_id
--------------
+---------------------+
| @header_id:=min(id) |
+---------------------+
| 84129 |
+---------------------+
1 row in set (0.00 sec)
--------------
delete from trm_out_receipt_link where cash_id=@cash_id and receipt_link_header>=@header_id
--------------
Query OK, 4 rows affected (0.01 sec)
--------------
select @item_id:=min(id) from trm_out_receipt_item where cash_id=@cash_id and receipt_header=@header_id
--------------
+-------------------+
| @item_id:=min(id) |
+-------------------+
| 659498 |
+-------------------+
1 row in set (0.00 sec)
--------------
delete from trm_out_receipt_item_discount where cash_id=@cash_id and receipt_item>=@item_id
--------------
Query OK, 2843 rows affected (0.13 sec)
--------------
delete from trm_out_receipt_item_handler where cash_id=@cash_id and owner_id>=@item_id
--------------
Query OK, 0 rows affected (0.02 sec)
--------------
delete from trm_out_receipt_item_tax where cash_id=@cash_id and receipt_item>=@item_id
--------------
Query OK, 0 rows affected (0.00 sec)
--------------
delete from trm_out_receipt_item where cash_id=@cash_id and id>=@item_id
--------------
Query OK, 16177 rows affected (39.70 sec)
--------------
delete from trm_out_receipt_subtotal where cash_id=@cash_id and id>=@header_id
--------------
Query OK, 1893 rows affected (0.08 sec)
--------------
select @discount_id:=min(id) from trm_out_receipt_discounts where cash_id=@cash_id and receipt_header>=@header_id
--------------
+-----------------------+
| @discount_id:=min(id) |
+-----------------------+
| 3802 |
+-----------------------+
1 row in set (0.02 sec)
--------------
delete from trm_out_receipt_discount_handler where cash_id=@cash_id and owner_id>=@discount_id
--------------
Query OK, 114 rows affected (0.06 sec)
--------------
delete from trm_out_receipt_discount_properties where cash_id=@cash_id and receipt_discount>=@discount_id
--------------
Query OK, 342 rows affected (0.08 sec)
--------------
delete from trm_out_receipt_discounts where cash_id=@cash_id and id>=@discount_id
--------------
Query OK, 114 rows affected (0.06 sec)
--------------
delete from trm_out_receipt_tax where cash_id=@cash_id and id>=@header_id
--------------
Query OK, 0 rows affected (0.00 sec)
--------------
select @payment_id:=min(id) from trm_out_receipt_payment where cash_id=@cash_id and receipt_header=@header_id
--------------
+----------------------+
| @payment_id:=min(id) |
+----------------------+
| 84170 |
+----------------------+
1 row in set (0.03 sec)
--------------
delete from trm_out_receipt_payment_handler where cash_id=@cash_id and owner_id>=@payment_id
--------------
Query OK, 1894 rows affected (0.13 sec)
--------------
delete from trm_out_receipt_payment where cash_id=@cash_id and id>=@payment_id
--------------
Query OK, 1894 rows affected (32.56 sec)
--------------
delete from trm_out_receipt_footer where cash_id=@cash_id and id>=@header_id
--------------
Query OK, 1899 rows affected (0.44 sec)
--------------
delete from trm_out_receipt_header where cash_id=@cash_id and id>=@header_id
--------------
Query OK, 1899 rows affected (19.23 sec)
--------------
delete from trm_out_shift_payments where cash_id=@cash_id and id>=@shift_id
--------------
Query OK, 0 rows affected (0.00 sec)
--------------
delete from trm_out_shift_open where cash_id=@cash_id and id>=@shift_id
--------------
Query OK, 4 rows affected (0.13 sec)
--------------
delete from trm_out_shift_close where cash_id=@cash_id and id>=@shift_id
--------------
Query OK, 4 rows affected (0.09 sec)
--------------
UPDATE cnv_unload_state set last_unload_obj_id := @smena-1 where obj_type =5 and cash_id=@cash_id
--------------
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
--------------
commit
--------------
Query OK, 0 rows affected (0.00 sec)