Debian Codegraph @

addons/point_of_sale/tests/test_pos_simple_invoiced_orders.py

raw
1 # -*- coding: utf-8 -*-
2 # Part of Odoo. See LICENSE file for full copyright and licensing details.
3
4 import odoo
5
6 from odoo.addons.point_of_sale.tests.common import TestPoSCommon
7
8
9 @odoo.tests.tagged('post_install', '-at_install')
10 class TestPosSimpleInvoicedOrders(TestPoSCommon):
11 """
12 Each test case only make a single **invoiced** order.
13 Name of each test corresponds to a sheet in: https://docs.google.com/spreadsheets/d/1mt2jRSDU7OONPBFjwyTcnhRjITQI8rGMLLQA5K3fAjo/edit?usp=sharing
14 """
15
16 def setUp(self):
17 super(TestPosSimpleInvoicedOrders, self).setUp()
18 self.config = self.basic_config
19 self.product100 = self.create_product('Product_100', self.categ_basic, 100, 50)
20
21 def test_01b(self):
22 self._run_test({
23 'payment_methods': self.cash_pm1,
24 'orders': [
25 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.cash_pm1, 100)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
26 ],
27 'journal_entries_before_closing': {
28 '00100-010-0001': {
29 'invoice': {
30 'line_ids': [
31 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False},
32 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
33 ]
34 },
35 'payments': [
36 ((self.cash_pm1, 100), {
37 'line_ids': [
38 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': True},
39 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': False},
40 ]
41 }),
42 ],
43 }
44 },
45 'journal_entries_after_closing': {
46 'session_journal_entry': {
47 'line_ids': [
48 {'account_id': self.cash_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': True},
49 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': True},
50 ],
51 },
52 'cash_statement': [
53 ((100, ), {
54 'line_ids': [
55 {'account_id': self.cash_pm1.journal_id.default_account_id.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': False},
56 {'account_id': self.cash_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': True},
57 ]
58 })
59 ],
60 'bank_payments': [],
61 },
62 })
63
64 def test_02b(self):
65 self._run_test({
66 'payment_methods': self.cash_pm1 | self.bank_pm1,
67 'orders': [
68 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.bank_pm1, 100)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
69 ],
70 'journal_entries_before_closing': {
71 '00100-010-0001': {
72 'invoice': {
73 'journal_id': self.config.invoice_journal_id.id,
74 'line_ids': [
75 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False},
76 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
77 ]
78 },
79 'payments': [
80 ((self.bank_pm1, 100), {
81 'journal_id': self.config.journal_id.id,
82 'line_ids': [
83 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': True},
84 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': False},
85 ]
86 }),
87 ],
88 }
89 },
90 'journal_entries_after_closing': {
91 'session_journal_entry': {
92 'journal_id': self.config.journal_id.id,
93 'line_ids': [
94 {'account_id': self.bank_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': True},
95 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': True},
96 ],
97 },
98 'cash_statement': [],
99 'bank_payments': [
100 ((100, ), {
101 'journal_id': self.bank_pm1.journal_id.id,
102 'line_ids': [
103 {'account_id': self.bank_pm1.outstanding_account_id.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': False},
104 {'account_id': self.bank_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': True},
105 ]
106 })
107 ],
108 },
109 })
110
111 def test_03b(self):
112 self._run_test({
113 'payment_methods': self.cash_pm1 | self.pay_later_pm,
114 'orders': [
115 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.pay_later_pm, 100)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
116 ],
117 'journal_entries_before_closing': {
118 '00100-010-0001': {
119 'invoice': {
120 'journal_id': self.config.invoice_journal_id.id,
121 'line_ids': [
122 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False},
123 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': False},
124 ]
125 },
126 'payments': [],
127 }
128 },
129 'journal_entries_after_closing': {
130 'session_journal_entry': False,
131 'cash_statement': [],
132 'bank_payments': [],
133 },
134 })
135
136 def test_04b(self):
137 self._run_test({
138 'payment_methods': self.cash_pm1 | self.bank_split_pm1,
139 'orders': [
140 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.bank_split_pm1, 100)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
141 ],
142 'journal_entries_before_closing': {
143 '00100-010-0001': {
144 'invoice': {
145 'journal_id': self.config.invoice_journal_id.id,
146 'line_ids': [
147 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False},
148 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
149 ]
150 },
151 'payments': [
152 ((self.bank_split_pm1, 100), {
153 'journal_id': self.config.journal_id.id,
154 'line_ids': [
155 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': True},
156 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': False},
157 ]
158 }),
159 ],
160 }
161 },
162 'journal_entries_after_closing': {
163 'session_journal_entry': {
164 'journal_id': self.config.journal_id.id,
165 'line_ids': [
166 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
167 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': True},
168 ],
169 },
170 'cash_statement': [],
171 'bank_payments': [
172 ((100, ), {
173 'journal_id': self.bank_split_pm1.journal_id.id,
174 'line_ids': [
175 {'account_id': self.bank_split_pm1.outstanding_account_id.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': False},
176 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': True},
177 ]
178 })
179 ],
180 },
181 })
182
183 def test_05b(self):
184 self._run_test({
185 'payment_methods': self.cash_split_pm1,
186 'orders': [
187 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.cash_split_pm1, 100)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
188 ],
189 'journal_entries_before_closing': {
190 '00100-010-0001': {
191 'invoice': {
192 'line_ids': [
193 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False},
194 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
195 ]
196 },
197 'payments': [
198 ((self.cash_split_pm1, 100), {
199 'line_ids': [
200 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': True},
201 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': False},
202 ]
203 }),
204 ],
205 }
206 },
207 'journal_entries_after_closing': {
208 'session_journal_entry': {
209 'line_ids': [
210 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
211 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': True},
212 ],
213 },
214 'cash_statement': [
215 ((100, ), {
216 'line_ids': [
217 {'account_id': self.cash_split_pm1.journal_id.default_account_id.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': False},
218 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': True},
219 ]
220 })
221 ],
222 'bank_payments': [],
223 },
224 })
225
226 def test_10b(self):
227 self._run_test({
228 'payment_methods': self.cash_pm1 | self.pay_later_pm,
229 'orders': [
230 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.cash_pm1, 200), (self.pay_later_pm, -100)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
231 ],
232 'journal_entries_before_closing': {
233 '00100-010-0001': {
234 'invoice': {
235 'line_ids': [
236 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False},
237 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True, 'partially_reconciled': True},
238 ]
239 },
240 'payments': [
241 ((self.cash_pm1, 200), {
242 'line_ids': [
243 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 200, 'reconciled': False, 'partially_reconciled': True, 'amount_residual': -100},
244 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 200, 'credit': 0, 'reconciled': False, 'amount_residual': 200},
245 ]
246 }),
247 ],
248 }
249 },
250 'journal_entries_after_closing': {
251 'session_journal_entry': {
252 'line_ids': [
253 {'account_id': self.cash_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 200, 'credit': 0, 'reconciled': True},
254 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 200, 'reconciled': True},
255 ],
256 },
257 'cash_statement': [
258 ((200, ), {
259 'line_ids': [
260 {'account_id': self.cash_pm1.journal_id.default_account_id.id, 'partner_id': False, 'debit': 200, 'credit': 0, 'reconciled': False},
261 {'account_id': self.cash_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 0, 'credit': 200, 'reconciled': True},
262 ]
263 })
264 ],
265 'bank_payments': [],
266 },
267 })
268
269 def test_11b(self):
270 self._run_test({
271 'payment_methods': self.cash_pm1 | self.bank_pm1 | self.pay_later_pm,
272 'orders': [
273 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.bank_pm1, 200), (self.pay_later_pm, -100)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
274 ],
275 'journal_entries_before_closing': {
276 '00100-010-0001': {
277 'invoice': {
278 'line_ids': [
279 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False},
280 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True, 'partially_reconciled': True},
281 ]
282 },
283 'payments': [
284 ((self.bank_pm1, 200), {
285 'line_ids': [
286 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 200, 'reconciled': False, 'partially_reconciled': True, 'amount_residual': -100},
287 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 200, 'credit': 0, 'reconciled': False, 'amount_residual': 200},
288 ]
289 }),
290 ],
291 }
292 },
293 'journal_entries_after_closing': {
294 'session_journal_entry': {
295 'line_ids': [
296 {'account_id': self.bank_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 200, 'credit': 0, 'reconciled': True},
297 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 200, 'reconciled': True},
298 ],
299 },
300 'cash_statement': [],
301 'bank_payments': [
302 ((200, ), {
303 'line_ids': [
304 {'account_id': self.bank_pm1.outstanding_account_id.id, 'partner_id': False, 'debit': 200, 'credit': 0, 'reconciled': False},
305 {'account_id': self.bank_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 0, 'credit': 200, 'reconciled': True},
306 ]
307 })
308 ],
309 },
310 })
311
312 def test_12b(self):
313 self._run_test({
314 'payment_methods': self.cash_split_pm1 | self.pay_later_pm,
315 'orders': [
316 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.cash_split_pm1, 200), (self.pay_later_pm, -100)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
317 ],
318 'journal_entries_before_closing': {
319 '00100-010-0001': {
320 'invoice': {
321 'line_ids': [
322 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False},
323 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True, 'partially_reconciled': True},
324 ]
325 },
326 'payments': [
327 ((self.cash_split_pm1, 200), {
328 'line_ids': [
329 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 200, 'reconciled': False, 'partially_reconciled': True, 'amount_residual': -100},
330 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 200, 'credit': 0, 'reconciled': False, 'amount_residual': 200},
331 ]
332 }),
333 ],
334 }
335 },
336 'journal_entries_after_closing': {
337 'session_journal_entry': {
338 'line_ids': [
339 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 200, 'credit': 0, 'reconciled': True},
340 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 200, 'reconciled': True},
341 ],
342 },
343 'cash_statement': [
344 ((200, ), {
345 'line_ids': [
346 {'account_id': self.cash_split_pm1.journal_id.default_account_id.id, 'partner_id': self.customer.id, 'debit': 200, 'credit': 0, 'reconciled': False},
347 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 200, 'reconciled': True},
348 ]
349 })
350 ],
351 'bank_payments': [],
352 },
353 })
354
355 def test_13b(self):
356 self._run_test({
357 'payment_methods': self.cash_pm1 | self.bank_split_pm1 | self.pay_later_pm,
358 'orders': [
359 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.bank_split_pm1, 200), (self.pay_later_pm, -100)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
360 ],
361 'journal_entries_before_closing': {
362 '00100-010-0001': {
363 'invoice': {
364 'line_ids': [
365 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False},
366 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True, 'partially_reconciled': True},
367 ]
368 },
369 'payments': [
370 ((self.bank_split_pm1, 200), {
371 'line_ids': [
372 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 200, 'reconciled': False, 'partially_reconciled': True, 'amount_residual': -100},
373 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 200, 'credit': 0, 'reconciled': False, 'amount_residual': 200},
374 ]
375 }),
376 ],
377 }
378 },
379 'journal_entries_after_closing': {
380 'session_journal_entry': {
381 'line_ids': [
382 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 200, 'credit': 0, 'reconciled': True},
383 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 200, 'reconciled': True},
384 ],
385 },
386 'cash_statement': [],
387 'bank_payments': [
388 ((200, ), {
389 'line_ids': [
390 {'account_id': self.bank_split_pm1.outstanding_account_id.id, 'partner_id': self.customer.id, 'debit': 200, 'credit': 0, 'reconciled': False},
391 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 200, 'reconciled': True},
392 ]
393 })
394 ],
395 },
396 })
397
398 def test_14b(self):
399 self._run_test({
400 'payment_methods': self.cash_pm1,
401 'orders': [
402 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.cash_pm1, 200), (self.cash_pm1, -100)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
403 ],
404 'journal_entries_before_closing': {
405 '00100-010-0001': {
406 'invoice': {
407 'line_ids': [
408 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False},
409 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
410 ]
411 },
412 'payments': [
413 ((self.cash_pm1, 200), {
414 'line_ids': [
415 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 200, 'reconciled': True},
416 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 200, 'credit': 0, 'reconciled': False},
417 ]
418 }),
419 ((self.cash_pm1, -100), {
420 'line_ids': [
421 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
422 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': False},
423 ]
424 }),
425 ],
426 }
427 },
428 'journal_entries_after_closing': {
429 'session_journal_entry': {
430 'line_ids': [
431 {'account_id': self.cash_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': True},
432 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': True},
433 ],
434 },
435 'cash_statement': [
436 ((100, ), {
437 'line_ids': [
438 {'account_id': self.cash_pm1.journal_id.default_account_id.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': False},
439 {'account_id': self.cash_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': True},
440 ]
441 })
442 ],
443 'bank_payments': [],
444 },
445 })
446
447 def test_15b(self):
448 self._run_test({
449 'payment_methods': self.cash_pm1 | self.bank_pm1,
450 'orders': [
451 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.bank_pm1, 200), (self.cash_pm1, -100)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
452 ],
453 'journal_entries_before_closing': {
454 '00100-010-0001': {
455 'invoice': {
456 'line_ids': [
457 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False},
458 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
459 ]
460 },
461 'payments': [
462 ((self.bank_pm1, 200), {
463 'line_ids': [
464 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 200, 'reconciled': True},
465 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 200, 'credit': 0, 'reconciled': False},
466 ]
467 }),
468 ((self.cash_pm1, -100), {
469 'line_ids': [
470 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
471 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': False},
472 ]
473 }),
474 ],
475 }
476 },
477 'journal_entries_after_closing': {
478 'session_journal_entry': {
479 'line_ids': [
480 {'account_id': self.bank_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 200, 'credit': 0, 'reconciled': True},
481 {'account_id': self.cash_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': True},
482 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 200, 'reconciled': True},
483 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': True},
484 ],
485 },
486 'cash_statement': [
487 ((-100, ), {
488 'line_ids': [
489 {'account_id': self.cash_pm1.journal_id.default_account_id.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': False},
490 {'account_id': self.cash_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': True},
491 ]
492 })
493 ],
494 'bank_payments': [
495 ((200, ), {
496 'line_ids': [
497 {'account_id': self.bank_pm1.outstanding_account_id.id, 'partner_id': False, 'debit': 200, 'credit': 0, 'reconciled': False},
498 {'account_id': self.bank_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 0, 'credit': 200, 'reconciled': True},
499 ]
500 })
501 ],
502 },
503 })
504
505 def test_16b(self):
506 self._run_test({
507 'payment_methods': self.cash_pm1 | self.bank_split_pm1,
508 'orders': [
509 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.bank_split_pm1, 200), (self.cash_pm1, -100)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
510 ],
511 'journal_entries_before_closing': {
512 '00100-010-0001': {
513 'invoice': {
514 'line_ids': [
515 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False},
516 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
517 ]
518 },
519 'payments': [
520 ((self.bank_split_pm1, 200), {
521 'line_ids': [
522 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 200, 'reconciled': True},
523 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 200, 'credit': 0, 'reconciled': False},
524 ]
525 }),
526 ((self.cash_pm1, -100), {
527 'line_ids': [
528 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
529 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': False},
530 ]
531 }),
532 ],
533 }
534 },
535 'journal_entries_after_closing': {
536 'session_journal_entry': {
537 'line_ids': [
538 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 200, 'credit': 0, 'reconciled': True},
539 {'account_id': self.cash_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': True},
540 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': True},
541 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 200, 'reconciled': True},
542 ],
543 },
544 'cash_statement': [
545 ((-100, ), {
546 'line_ids': [
547 {'account_id': self.cash_pm1.journal_id.default_account_id.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': False},
548 {'account_id': self.cash_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': True},
549 ]
550 })
551 ],
552 'bank_payments': [
553 ((200, ), {
554 'line_ids': [
555 {'account_id': self.bank_split_pm1.outstanding_account_id.id, 'partner_id': self.customer.id, 'debit': 200, 'credit': 0, 'reconciled': False},
556 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 200, 'reconciled': True},
557 ]
558 })
559 ],
560 },
561 })
562
563 def test_17b(self):
564 self._run_test({
565 'payment_methods': self.cash_split_pm1,
566 'orders': [
567 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.cash_split_pm1, 200), (self.cash_split_pm1, -100)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
568 ],
569 'journal_entries_before_closing': {
570 '00100-010-0001': {
571 'invoice': {
572 'line_ids': [
573 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False},
574 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
575 ]
576 },
577 'payments': [
578 ((self.cash_split_pm1, 200), {
579 'line_ids': [
580 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 200, 'reconciled': True},
581 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 200, 'credit': 0, 'reconciled': False},
582 ]
583 }),
584 ((self.cash_split_pm1, -100), {
585 'line_ids': [
586 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
587 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 100, 'reconciled': False},
588 ]
589 }),
590 ],
591 }
592 },
593 'journal_entries_after_closing': {
594 'session_journal_entry': {
595 'line_ids': [
596 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 200, 'credit': 0, 'reconciled': True},
597 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': True},
598 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 200, 'reconciled': True},
599 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 100, 'credit': 0, 'reconciled': True},
600 ],
601 },
602 'cash_statement': [
603 ((200, ), {
604 'line_ids': [
605 {'account_id': self.cash_split_pm1.journal_id.default_account_id.id, 'partner_id': self.customer.id, 'debit': 200, 'credit': 0, 'reconciled': False},
606 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 200, 'reconciled': True},
607 ]
608 }),
609 ((-100, ), {
610 'line_ids': [
611 {'account_id': self.cash_split_pm1.journal_id.default_account_id.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False},
612 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': True},
613 ]
614 })
615 ],
616 'bank_payments': [],
617 },
618 })
619
620 def test_18b(self):
621 self._run_test({
622 'payment_methods': self.cash_pm1 | self.pay_later_pm,
623 'orders': [
624 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.cash_pm1, 50), (self.pay_later_pm, 50)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
625 ],
626 'journal_entries_before_closing': {
627 '00100-010-0001': {
628 'invoice': {
629 'line_ids': [
630 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False, 'amount_residual': 0},
631 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': False, 'partially_reconciled': True, 'amount_residual': 50},
632 ]
633 },
634 'payments': [
635 ((self.cash_pm1, 50), {
636 'line_ids': [
637 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 50, 'reconciled': True, 'partially_reconciled': True},
638 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 50, 'credit': 0, 'reconciled': False},
639 ]
640 }),
641 ],
642 }
643 },
644 'journal_entries_after_closing': {
645 'session_journal_entry': {
646 'line_ids': [
647 {'account_id': self.cash_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 50, 'credit': 0, 'reconciled': True},
648 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 50, 'reconciled': True},
649 ],
650 },
651 'cash_statement': [
652 ((50, ), {
653 'line_ids': [
654 {'account_id': self.cash_pm1.journal_id.default_account_id.id, 'partner_id': False, 'debit': 50, 'credit': 0, 'reconciled': False},
655 {'account_id': self.cash_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 0, 'credit': 50, 'reconciled': True},
656 ]
657 })
658 ],
659 'bank_payments': [],
660 },
661 })
662
663 def test_19b(self):
664 self._run_test({
665 'payment_methods': self.cash_pm1 | self.bank_pm1 | self.pay_later_pm,
666 'orders': [
667 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.bank_pm1, 50), (self.pay_later_pm, 50)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
668 ],
669 'journal_entries_before_closing': {
670 '00100-010-0001': {
671 'invoice': {
672 'line_ids': [
673 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False, 'amount_residual': 0},
674 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': False, 'partially_reconciled': True, 'amount_residual': 50},
675 ]
676 },
677 'payments': [
678 ((self.bank_pm1, 50), {
679 'line_ids': [
680 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 50, 'reconciled': True, 'partially_reconciled': True},
681 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 50, 'credit': 0, 'reconciled': False},
682 ]
683 }),
684 ],
685 }
686 },
687 'journal_entries_after_closing': {
688 'session_journal_entry': {
689 'line_ids': [
690 {'account_id': self.bank_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 50, 'credit': 0, 'reconciled': True},
691 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 50, 'reconciled': True},
692 ],
693 },
694 'cash_statement': [],
695 'bank_payments': [
696 ((50, ), {
697 'line_ids': [
698 {'account_id': self.bank_pm1.outstanding_account_id.id, 'partner_id': False, 'debit': 50, 'credit': 0, 'reconciled': False},
699 {'account_id': self.bank_pm1.receivable_account_id.id, 'partner_id': False, 'debit': 0, 'credit': 50, 'reconciled': True},
700 ]
701 })
702 ],
703 },
704 })
705
706 def test_20b(self):
707 self._run_test({
708 'payment_methods': self.cash_pm1 | self.bank_split_pm1 | self.pay_later_pm,
709 'orders': [
710 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.bank_split_pm1, 50), (self.pay_later_pm, 50)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
711 ],
712 'journal_entries_before_closing': {
713 '00100-010-0001': {
714 'invoice': {
715 'line_ids': [
716 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False, 'amount_residual': 0},
717 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': False, 'partially_reconciled': True, 'amount_residual': 50},
718 ]
719 },
720 'payments': [
721 ((self.bank_split_pm1, 50), {
722 'line_ids': [
723 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 50, 'reconciled': True, 'partially_reconciled': True},
724 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 50, 'credit': 0, 'reconciled': False},
725 ]
726 }),
727 ],
728 }
729 },
730 'journal_entries_after_closing': {
731 'session_journal_entry': {
732 'line_ids': [
733 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 50, 'credit': 0, 'reconciled': True},
734 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 50, 'reconciled': True},
735 ],
736 },
737 'cash_statement': [],
738 'bank_payments': [
739 ((50, ), {
740 'line_ids': [
741 {'account_id': self.bank_split_pm1.outstanding_account_id.id, 'partner_id': self.customer.id, 'debit': 50, 'credit': 0, 'reconciled': False},
742 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 50, 'reconciled': True},
743 ]
744 })
745 ],
746 },
747 })
748
749 def test_21b(self):
750 self._run_test({
751 'payment_methods': self.cash_split_pm1 | self.pay_later_pm,
752 'orders': [
753 {'pos_order_lines_ui_args': [(self.product100, 1)], 'payments': [(self.cash_split_pm1, 50), (self.pay_later_pm, 50)], 'customer': self.customer, 'is_invoiced': True, 'uuid': '00100-010-0001'},
754 ],
755 'journal_entries_before_closing': {
756 '00100-010-0001': {
757 'invoice': {
758 'line_ids': [
759 {'account_id': self.sales_account.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 100, 'reconciled': False, 'amount_residual': 0},
760 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 100, 'credit': 0, 'reconciled': False, 'partially_reconciled': True, 'amount_residual': 50},
761 ]
762 },
763 'payments': [
764 ((self.cash_split_pm1, 50), {
765 'line_ids': [
766 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 50, 'reconciled': True, 'partially_reconciled': True},
767 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 50, 'credit': 0, 'reconciled': False},
768 ]
769 }),
770 ],
771 }
772 },
773 'journal_entries_after_closing': {
774 'session_journal_entry': {
775 'line_ids': [
776 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 50, 'credit': 0, 'reconciled': True},
777 {'account_id': self.pos_receivable_account.id, 'partner_id': False, 'debit': 0, 'credit': 50, 'reconciled': True},
778 ],
779 },
780 'cash_statement': [
781 ((50, ), {
782 'line_ids': [
783 {'account_id': self.cash_split_pm1.journal_id.default_account_id.id, 'partner_id': self.customer.id, 'debit': 50, 'credit': 0, 'reconciled': False},
784 {'account_id': self.c1_receivable.id, 'partner_id': self.customer.id, 'debit': 0, 'credit': 50, 'reconciled': True},
785 ]
786 })
787 ],
788 'bank_payments': [],
789 },
790 })