0001-lingo-add-regie-s-label-to-transaction-s-CSV-report-.patch
combo/apps/lingo/manager_views.py | ||
---|---|---|
182 | 182 |
response = HttpResponse(content_type='text/csv') |
183 | 183 |
response['Content-Disposition'] = 'attachment; filename="transactions.csv"' |
184 | 184 |
writer = csv.writer(response) |
185 |
transactions = Transaction.objects.filter( |
|
186 |
status__in=(eopayment.PAID, eopayment.ACCEPTED), |
|
187 |
start_date__date__gte=form.cleaned_data['start_date'], |
|
188 |
start_date__date__lte=form.cleaned_data['end_date'], |
|
189 |
).order_by('-start_date') |
|
185 |
transactions = ( |
|
186 |
Transaction.objects.filter( |
|
187 |
status__in=(eopayment.PAID, eopayment.ACCEPTED), |
|
188 |
start_date__date__gte=form.cleaned_data['start_date'], |
|
189 |
start_date__date__lte=form.cleaned_data['end_date'], |
|
190 |
) |
|
191 |
.select_related('regie') |
|
192 |
.order_by('-start_date') |
|
193 |
) |
|
190 | 194 |
for transaction in transactions: |
191 | 195 |
row = [ |
192 | 196 |
transaction.order_id, |
... | ... | |
194 | 198 |
transaction.start_date.strftime('%Y-%m-%d %H:%M:%S'), |
195 | 199 |
transaction.get_user_name(), |
196 | 200 |
str(transaction.amount), |
201 |
transaction.regie.label, |
|
197 | 202 |
] |
198 | 203 |
for item in transaction.items.all(): |
199 | 204 |
row.extend([item.subject, str(item.amount)]) |
tests/test_lingo_manager.py | ||
---|---|---|
213 | 213 |
assert row[1] == trans2.bank_transaction_id |
214 | 214 |
assert row[3] == '%s %s' % (user.first_name, user.last_name) |
215 | 215 |
assert Decimal(row[4]) == Decimal(trans2.amount) |
216 |
assert row[5] == b_item.subject |
|
217 |
assert Decimal(row[6]) == b_item.amount |
|
216 |
assert row[5] == regie.label |
|
217 |
assert row[6] == b_item.subject |
|
218 |
assert Decimal(row[7]) == b_item.amount |
|
218 | 219 | |
219 | 220 |
resp = app.get('/manage/lingo/transactions/download-csv/', status=200) |
220 | 221 |
resp.forms[0]['start_date'] = datetime.date(2019, 7, 1) |
... | ... | |
229 | 230 |
assert row[1] == trans1.bank_transaction_id |
230 | 231 |
assert row[3] == '%s %s' % (user.first_name, user.last_name) |
231 | 232 |
assert Decimal(row[4]) == Decimal(trans1.amount) |
232 |
assert row[5] == b_item.subject |
|
233 |
assert Decimal(row[6]) == b_item.amount |
|
233 |
assert row[5] == regie.label |
|
234 |
assert row[6] == b_item.subject |
|
235 |
assert Decimal(row[7]) == b_item.amount |
|
234 | 236 | |
235 | 237 | |
236 | 238 |
def test_transactions_search(app, admin_user, payment_backend, regie): |
237 |
- |