Automatically create a new document when issuing a cash payment document and then convert the form of payment into the current document into credit.

This is required in case of connection to analytic accounting where it is required to properly maintain the cash.
Copy the following code into the settings->purchases/sales->documents->run SQL in the document you want to create at the same time.

You must fill in the fields:
dd            the line ID of the new document to be created.
loy           the product handle to be included in the new document with the full amount.
paym      the payment method line ID for the new document.
cpaym    the payment method line ID for the current document. It will change along with the creation of the new document.