2 In order to test the Point of Sale in module, I will do a full flow from the sale to the payment and invoicing.
3 I will use two products, one with price including a 10% tax, the other one with 5% tax excluded from the price.
5 I create a VAT tax of 10%, included in the public price
7 !record {model: account.tax, id: account_tax_10_incl}:
11 account_paid_id: account.iva
12 account_collected_id: account.iva
15 I assign this 10 percent tax on the PC1 product as a sale tax
17 !record {model: product.product, id: product.product_product_pc1}:
18 taxes_id: [account_tax_10_incl]
20 I create a VAT tax of 5%, which is added to the public price
22 !record {model: account.tax, id: account_tax_05_incl}:
23 name: VAT 05 perc Excl
26 account_paid_id: account.iva
27 account_collected_id: account.iva
30 I will create a second VAT tax of 5% but this time for a child company, to
31 ensure that only product taxes of the current session's company are considered
32 (this tax should be ignore when computing order's taxes in following tests)
34 !record {model: account.tax, id: account_tax_05_incl_chicago}:
35 name: VAT 05 perc Excl (US)
38 account_paid_id: account.iva
39 account_collected_id: account.iva
41 company_id: stock.res_company_1
43 I assign those 5 percent taxes on the PC2 product as a sale taxes
45 !record {model: product.product, id: product.product_product_pc2}:
46 taxes_id: [account_tax_05_incl, account_tax_05_incl_chicago]
48 I create a PoS order with 2 units of PC1 at 450 EUR (Tax Incl) and 3 units of PC2 at 300 EUR. (Tax Excl)
50 !record {model: pos.order, id: pos_order_pos0}:
51 company_id: base.main_company
54 product_id: product.product_product_pc1
59 product_id: product.product_product_pc2
64 I check that the total of the order is equal to 450*2 + 300*3*1.05 and the tax of the order is equal to 900 -(450 * 2 / 1.1) + 300*0.05*3
66 !python {model: pos.order}: |
67 order = self.browse(cr, uid, ref('pos_order_pos0'))
68 assert(abs(order.amount_total - (450*2 + 300*3*1.05)) < 0.01), "The order has a wrong amount, tax included"
69 assert(abs(order.amount_tax - (900-(450*2/1.1) + 300*0.05*3)) < 0.01), "The order has a wrong tax amount"
71 I want to add a global discount of 5 percent using the wizard
73 !record {model: pos.discount, id: pos_discount_0}:
76 I click the apply button to set the discount on all lines
78 !python {model: pos.discount}: |
79 self.apply_discount(cr, uid, [ref("pos_discount_0")], {"active_model": "pos.order",
80 "active_ids": [ref("pos_order_pos0")], "active_id": ref("pos_order_pos0"), })
82 I check that the total of the order is now equal to (450*2 + 300*3*1.05)*0.95
84 !python {model: pos.order}: |
85 order = self.browse(cr, uid, ref('pos_order_pos0'))
86 assert(abs(order.amount_total - (450*2 + 300*3*1.05)*0.95) < 0.01), "The order has a wrong total including tax and discounts"
88 I click on the "Make Payment" wizard to pay the PoS order with a partial amount of 100.0 EUR
90 !record {model: pos.make.payment, id: pos_make_payment_0, context: '{"active_id": ref("pos_order_pos0"), "active_ids": [ref("pos_order_pos0")]}' }:
93 I click on the validate button to register the payment.
95 !python {model: pos.make.payment}: |
96 self.check(cr, uid, [ref('pos_make_payment_0')], context={'active_id': ref('pos_order_pos0'), 'lang':'en_US', 'active_model': 'pos.order', 'tz': False, 'active_ids': [ref('pos_order_pos0')]} )
98 I check that the order is not marked as paid yet
100 !assert {model: pos.order, id: pos_order_pos0}:
103 On the second payment proposition, I check that it proposes me the remaining balance which is 1790.0 EUR
105 !python {model: pos.make.payment}: |
106 defs = self.default_get(cr, uid, ['amount'], {'active_id': ref('pos_order_pos0')})
107 assert abs(defs['amount'] - ((450*2 + 300*3*1.05)*0.95-100.0)) < 0.01, "The remaining balance is incorrect"
109 I pay the remaining balance.
111 !record {model: pos.make.payment, id: pos_make_payment_1, context: '{"active_id": ref("pos_order_pos0"), "active_ids": [ref("pos_order_pos0")]}' }:
113 (450*2 + 300*3*1.05)*0.95-100.0
115 I click on the validate button to register the payment.
117 !python {model: pos.make.payment}: |
118 self.check(cr, uid, [ref('pos_make_payment_1')], context={'active_id': ref('pos_order_pos0')} )
120 I check that the order is marked as paid
122 !assert {model: pos.order, id: pos_order_pos0}:
125 I generate the journal entries
127 !python {model: pos.order}: |
128 self.create_account_move(cr, uid, [ref('pos_order_pos0')], {})
130 I test that the generated journal entry is attached to the PoS order
132 !assert {model: pos.order, id: pos_order_pos0}: