[IMP] pos_loyalty: add a loyalty resume at the end of the receipt
authorFrederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com>
Tue, 4 Nov 2014 14:56:12 +0000 (15:56 +0100)
committerFrédéric van der Essen <fvdessen@gmail.com>
Wed, 26 Nov 2014 10:40:22 +0000 (11:40 +0100)
addons/point_of_sale/static/src/xml/pos.xml
addons/pos_loyalty/static/src/js/loyalty.js
addons/pos_loyalty/static/src/xml/loyalty.xml

index 8987c51..99e37f3 100644 (file)
 
             <!-- Orderlines -->
 
-            <div line-ratio='0.6'>
+            <div class='orderlines' line-ratio='0.6'>
                 <t t-foreach='receipt.orderlines' t-as='line'>
                     <t t-set='simple' t-value='line.discount === 0 and line.unit_name === "Unit(s)" and line.quantity === 1' />
                     <t t-if='simple'>
             <!-- Total -->
 
             <line><right>--------</right></line>
-            <line size='double-height'>
+            <line class='total' size='double-height'>
                 <left><pre>        TOTAL</pre></left>
                 <right><value><t t-esc='receipt.total_with_tax' /></value></right>
             </line>
                 </t>
             </t>
 
+            <div class='before-footer' />
+
             <!-- Footer -->
             <t t-if='receipt.footer_xml'>
                 <t t-raw='receipt.footer_xml' />
                 <br/>
             </t>
 
+            <div class='after-footer' />
+
             <br/>
             <div font='b'>
                 <div><t t-esc='receipt.name' /></div>
index 7c46e29..be2757e 100644 (file)
@@ -294,7 +294,16 @@ openerp.pos_loyalty = function(instance){
         },
         export_for_printing: function(){
             var json = _super.prototype.export_for_printing.apply(this,arguments);
-            json.loyalty_points = this.get_new_points();
+            if (this.pos.loyalty && this.get_client()) {
+                json.loyalty = {
+                    rounding:     this.pos.loyalty.rounding || 1,
+                    name:         this.pos.loyalty.name,
+                    client:       this.get_client().name,
+                    points_won  : this.get_won_points(),
+                    points_spent: this.get_spent_points(),
+                    points_total: this.get_new_total_points(), 
+                };
+            }
             return json;
         },
         export_as_JSON: function(){
index 77f7047..988096d 100644 (file)
         </t>
     </t>
 
+    <t t-extend="XmlReceipt">
+        <t t-jquery='.before-footer' t-operation='append'>
+            <t t-if='receipt.loyalty'>
+                <div class='loyalty' value-decimals='2' value-autoint='on'>
+                    <div>--------------------------------</div>
+                    <br/>
+                    <div size='double-height'><t t-esc='receipt.loyalty.name'/></div>
+                    <br />
+                    <div><t t-esc='receipt.loyalty.client' /></div>
+                    <br/>
+                    <t t-if='receipt.loyalty.points_won'>
+                        <line><left>Points Won</left><right><value><t t-esc='receipt.loyalty.points_won' /></value></right></line>
+                    </t>
+                    <t t-if='receipt.loyalty.points_spent'>
+                        <line><left>Points Spent</left><right><value><t t-esc='receipt.loyalty.points_spent' /></value></right></line>
+                    </t>
+                    <t t-if='receipt.loyalty.points_total'>
+                        <line><left>Total Points</left><right><value><t t-esc='receipt.loyalty.points_total' /></value></right></line>
+                    </t>
+                    <br />
+                </div>
+            </t>
+        </t>
+    </t>
+
     <t t-extend='ClientDetails'>
         <t t-jquery='.client-details-right' t-operation='prepend'>
             <div class='client-detail'>