Browse Source

[ADD] money format in credit payment

Gogs 7 years ago
parent
commit
47af5a5f85

+ 2 - 4
models/account_payment_term.py

@@ -8,9 +8,7 @@ class AccountPaymentTerm(models.Model):
         domain = [('active', '=', True)]
         terms = []
 
-        for term in self.env['account.payment.term'].search(domain):
-            print term.name
-
+    for term in self.env['account.payment.term'].search(domain):
             lines = []
 
             for line in term.line_ids:
@@ -28,4 +26,4 @@ class AccountPaymentTerm(models.Model):
                 'lines': lines
             })
 
-        return terms
+        return terms

+ 4 - 1
src/components/payment/cash/PaymentAmount.vue

@@ -26,7 +26,7 @@
                 },
                 set(value) {
                     value = accounting.unformat(value, ',')
-                    
+
                     this.changeAmountPaid(value)
                     this.calculateResidual()
                 }
@@ -55,6 +55,9 @@
             return {
                 residual: 0
             }
+        },
+        mounted() {
+            this.changeAmountPaid(0)
         }
     }
 </script>

+ 26 - 6
src/components/payment/credit/PaymentCreditAmount.vue

@@ -5,7 +5,7 @@
             hr
         .payment-amount-item
             label.payment-label Monto entregado
-            input.payment-input
+            input.payment-input(:value="paid" v-model="paid" autofocus)
         .payment-credit-form-separator
             h3 Pagos Pendientes
             hr
@@ -18,16 +18,36 @@
 </template>
 
 <script>
-    import { mapGetters } from 'vuex'
+    import { mapGetters, mapActions } from 'vuex'
 
     export default {
-        computed: mapGetters([
-            'total'
-        ]),
+        computed: {
+            paid: {
+                get() {
+                    return accounting.formatMoney(this.amountPaid, this.currencySymbol, 0, '.', ',')
+                },
+                set(value) {
+                    value = accounting.unformat(value, ',')
+
+                    this.changeAmountPaid(value)
+                }
+            },
+            ...mapGetters([
+                'total',
+                'currencySymbol',
+                'amountPaid'
+            ])
+        },
         methods: {
             formatTotal() {
                 return accounting.formatMoney(this.total, this.currencySymbol, 0, '.', ',')
-            }
+            },
+            ...mapActions([
+                'changeAmountPaid'
+            ])
+        },
+        mounted() {
+            this.changeAmountPaid(0)
         }
     }
 </script>