Repository: pretix/pretix

Issue:
Order code splitted at wrong character during bank transfer assignment
Just ran into an issue while manually resolving an unresolved transaction. When I enter the order code of the transaction (just the 5 characters) into the input field, a dropdown opens up to reveal the order. This includes the entire string with the name of the event, the full transfer description that should have been used by the payer. When I click it, this entire description is filled into the input field. When I click confirm however, pretix does not recognize this string. Instead it just wants the 5 characters.

So either clicking the recommendation in the dropdown should just insert the 5 characters instead of the entire transfer string, or the input field should accept both. I guess the second option would be the nicer one.

Sorry I didn't take any screenshots, by the time I had solved my issue, it was already too late ;)
Order code splitted at wrong character during bank transfer assignment
Just ran into an issue while manually resolving an unresolved transaction. When I enter the order code of the transaction (just the 5 characters) into the input field, a dropdown opens up to reveal the order. This includes the entire string with the name of the event, the full transfer description that should have been used by the payer. When I click it, this entire description is filled into the input field. When I click confirm however, pretix does not recognize this string. Instead it just wants the 5 characters.

So either clicking the recommendation in the dropdown should just insert the 5 characters instead of the entire transfer string, or the input field should accept both. I guess the second option would be the nicer one.

Sorry I didn't take any screenshots, by the time I had solved my issue, it was already too late ;)


Discussion:
I cannot reproduce this right now, it should totally accept the full order code including the reference as well. Let me know if you run into this again!
Just made this happen again, but screwed up my screenshots. There's only the order code in the reference, thus it doesn't properly recognize the transaction. If I copy that reference, I get to choose the full code, as shown in the screenshot, which it then does not accept. <img width="1350" alt="screen shot 2017-11-12 at 00 27 13" src="https://user-images.githubusercontent.com/434444/32694482-21e36166-c741-11e7-991d-f6e18786c380.png">
With onle the order code, it works then.
That might be because we split the event slug and the order code at the first ``-`` in [this](https://github.com/pretix/pretix/blob/master/src/pretix/plugins/banktransfer/views.py#L97) and other places, which obviously is wrong, we need to split at the last ``-``. :) Thanks for finding this!
@sturzl Great, go ahead and let me know if you have any questions!
Hi @sturzl, have you been able to try to solve this? :)
Hi, I want to solve this issue. Can you tell me which files need to be changed and how to make unresolved transactions?
I linked the file above. I guess you just need to change the ``code.split('-')`` to ``code.rsplit('-', 1)``. Testing it is harder, you'd need to
* create an event with a ``-`` in the slug
* create a product and quota
* perform an order
* enable the bank transfer plugin
* upload any CSV file via the bank import (you can find sample CSV files in the test folder of the banktransfer plugin, if you want)
* assign the transaction to the orde.r

If it is too much effort, I'd also take an untested PR in this case as an exception.
I cannot reproduce this right now, it should totally accept the full order code including the reference as well. Let me know if you run into this again!
Just made this happen again, but screwed up my screenshots. There's only the order code in the reference, thus it doesn't properly recognize the transaction. If I copy that reference, I get to choose the full code, as shown in the screenshot, which it then does not accept. <img width="1350" alt="screen shot 2017-11-12 at 00 27 13" src="https://user-images.githubusercontent.com/434444/32694482-21e36166-c741-11e7-991d-f6e18786c380.png">
With onle the order code, it works then.
That might be because we split the event slug and the order code at the first ``-`` in [this](https://github.com/pretix/pretix/blob/master/src/pretix/plugins/banktransfer/views.py#L97) and other places, which obviously is wrong, we need to split at the last ``-``. :) Thanks for finding this!
@sturzl Great, go ahead and let me know if you have any questions!
Hi @sturzl, have you been able to try to solve this? :)
Hi, I want to solve this issue. Can you tell me which files need to be changed and how to make unresolved transactions?
I linked the file above. I guess you just need to change the ``code.split('-')`` to ``code.rsplit('-', 1)``. Testing it is harder, you'd need to
* create an event with a ``-`` in the slug
* create a product and quota
* perform an order
* enable the bank transfer plugin
* upload any CSV file via the bank import (you can find sample CSV files in the test folder of the banktransfer plugin, if you want)
* assign the transaction to the orde.r

If it is too much effort, I'd also take an untested PR in this case as an exception.

Resolving patch:
diff --git a/src/pretix/plugins/banktransfer/views.py b/src/pretix/plugins/banktransfer/views.py
--- a/src/pretix/plugins/banktransfer/views.py
+++ b/src/pretix/plugins/banktransfer/views.py
@@ -94,9 +94,9 @@ def _accept_ignore_amount(self, trans):
     def _assign(self, trans, code):
         try:
             if '-' in code:
-                trans.order = self.order_qs().get(code=code.split('-')[1], event__slug__iexact=code.split('-')[0])
+                trans.order = self.order_qs().get(code=code.rsplit('-', 1)[1], event__slug__iexact=code.rsplit('-', 1)[0])
             else:
-                trans.order = self.order_qs().get(code=code.split('-')[-1])
+                trans.order = self.order_qs().get(code=code.rsplit('-', 1)[-1])
         except Order.DoesNotExist:
             return JsonResponse({
                 'status': 'error',


Test patch: