From c275389288c4c98076581706d8801ea7e983921f Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Mon, 13 Apr 2020 11:43:32 +0200 Subject: [PATCH] suite --- .../admin/p_payments_controller.rb | 2 +- app/models/price_line.rb | 28 +++++++++++++++++++ app/views/admin/p_products/_form.html.haml | 4 +-- .../price_documents/_price_document.html.haml | 2 +- .../admin/price_documents/print.html.haml | 11 ++++++-- app/views/admin/price_lines/_form.html.haml | 8 +++--- app/views/layouts/admin.html.haml | 2 +- pdf.js | 2 +- 8 files changed, 46 insertions(+), 13 deletions(-) diff --git a/app/controllers/admin/p_payments_controller.rb b/app/controllers/admin/p_payments_controller.rb index 71b1213..7489c31 100644 --- a/app/controllers/admin/p_payments_controller.rb +++ b/app/controllers/admin/p_payments_controller.rb @@ -86,7 +86,7 @@ class Admin::PPaymentsController < ApplicationController def index @p_payments = PPayment.includes(:p_payment_type) - + @p_payments = @p_payments.where(:paid => true) params[:p_payment_type_ids] = params[:p_payment_type_ids] || [] @p_payments = @p_payments.where(:p_payment_type_id => params[:p_payment_type_ids]) if params[:p_payment_type_ids].size > 0 diff --git a/app/models/price_line.rb b/app/models/price_line.rb index b46babc..53f0dad 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -12,6 +12,34 @@ class PriceLine < ApplicationRecord acts_as_caching :fields => [:ship_price_ht, :caution, :credits, :permis_b, :stage_remorque, :permis_remorque, :carburant, :carburant_type, :carburant_price, :carburant_mention, :carburant_reservoir, :age_min, :cg, :accessoire, :sale_account, :p_product_cat_id, :weight_u, :weight_tot, :accounting_zone_id, :accounting_zone_name, :tva_account_id, :tva_account_value, :ref, :title, :description, :price_u_ht, :price_u_tva, :price_u_ttc, :tot_line_ht, :tot_line_tva, :tot_line_ttc, :tot_discount_ht, :tot_discount_tva, :tot_discount_ttc, :tot_amount_ht, :tot_amount_tva, :tot_amount_ttc, :discount_market_percent, :discount_qte_percent, :discount_delay_percent, :discount_enrobage_percent, :discount_ecole_percent, :discount_comptant_percent, :product_remise_enrobage_ok, :uv, :p_product_specific_customer_id] + def ca_carburant + if self.ct_carburant? + self.ct_carburant + elsif self.p_product_ref and self.p_product_ref.p_product + self.p_product_ref.p_product.carburant + + end + end + + def ca_carburant_type + if self.ct_carburant_type? + self.ct_carburant_type + elsif self.p_product_ref and self.p_product_ref.p_product + self.p_product_ref.p_product.carburant_type + + end + end + + def ca_carburant_price + if self.ct_carburant_price? + self.ct_carburant_price + elsif self.p_product_ref and self.p_product_ref.p_product + self.p_product_ref.p_product.carburant_price + + end + end + + def ca_caution if self.ct_caution? diff --git a/app/views/admin/p_products/_form.html.haml b/app/views/admin/p_products/_form.html.haml index 7407f51..03b06ad 100755 --- a/app/views/admin/p_products/_form.html.haml +++ b/app/views/admin/p_products/_form.html.haml @@ -91,8 +91,8 @@ = f.input :price_we_ht, :label => "Prix WE HT :" = f.input :price_min_ht, :label => "Prix sacrifié :" = f.input :serial_no, :label => "Numéro de série :" - = f.input :buy_at, :label => "Date d'achat :" - = f.input :producted_at, :label => "Date de production :" + = f.input :buy_at, :label => "Date d'achat :", :as => :date + = f.input :producted_at, :label => "Date de production :", :as => :date = f.input :permis_b, :label => "Permis B nécessaire ?" = f.input :stage_remorque, :label => "Stage remorque nécessaire :" = f.input :permis_remorque, :label => "Permis remorque nécessaire :" diff --git a/app/views/admin/price_documents/_price_document.html.haml b/app/views/admin/price_documents/_price_document.html.haml index 14c6e0c..3355489 100644 --- a/app/views/admin/price_documents/_price_document.html.haml +++ b/app/views/admin/price_documents/_price_document.html.haml @@ -48,7 +48,7 @@ = link_to i(:"check-circle-o"), generate_number_admin_price_document_path(price_document), data: { confirm: 'Voulez-vous vraiment valider cette facture et générer son numéro ? ' } -else - = link_to i(:"credit-card"), paid_by_ogone_admin_price_document_path(price_document.token), :remote => false, :target => "_blank" if price_document.to_paid_ttc > 0.0 + = link_to i(:"credit-card"), paid_by_ogone_admin_price_document_path(price_document.token), :remote => false, :target => "_blank" if price_document.to_paid_ttc > 0.0 and price_document.price_document_type_id == 1 =# link_to i(:eye), admin_price_document_path(price_document), :remote => true diff --git a/app/views/admin/price_documents/print.html.haml b/app/views/admin/price_documents/print.html.haml index 927b12a..d436eef 100644 --- a/app/views/admin/price_documents/print.html.haml +++ b/app/views/admin/price_documents/print.html.haml @@ -5,7 +5,7 @@ body{ font-size:12px; font-family:arial, sans-serif; - + -webkit-font-smoothin:antialiased; .table{ border-collapse:collapse; font-family:arial, sans-serif; @@ -211,8 +211,13 @@ =l price_line.return_at, :format => :short_date if price_line.return_at - %br - Carburant : livrée réservoir plein, rendu plein, remise à niveau GNR 1,20€ HT / litres (1,44€ TTC) + -if price_line.carburant + %br + Carburant : livrée réservoir plein, rendu plein, remise à niveau : + =price_line.carburant_type + =number_to_currency price_line.carburant_price + HT / litres + ="(#{number_to_currency(price_line.carburant_price*(price_line.tva_account_value/100+1))} TTC)" %br %br diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index 6c5034a..4909549 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -9,11 +9,7 @@ =ic :arrows %td - = form.input :ct_title, :label => "Désignation personnalisée :" - = form.input :ct_description, :label => "Description personnalisée :", :input_html => {:style => "height:70px;"} - - %td{:style => "width:300px"} %label Produit : %input.p_product_ref_autocomplete_input.form-control{:type => "text", :value => ("#{form.object.p_product_ref.ref} #{form.object.p_product_ref.cc_name}" if form.object.p_product_ref)} @@ -91,6 +87,10 @@ } ); + + = form.input :ct_title, :label => "Désignation personnalisée :" + = form.input :ct_description, :label => "Description personnalisée :", :input_html => {:style => "height:70px;"} + diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 8342e2d..bdeba5d 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -53,7 +53,7 @@ =ic :"cubes" Produits .element - =link_to admin_price_documents_path do + =link_to admin_price_documents_path("price_document_type_ids[]" => 1) do .cat#big_cat_documents =ic :"file-text-o" Documents diff --git a/pdf.js b/pdf.js index 9b9ade7..09fd83b 100644 --- a/pdf.js +++ b/pdf.js @@ -5,7 +5,7 @@ const puppeteer = require('puppeteer'); const createPdf = async() => { let browser; try { - browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox', '--font-render-hinting=medium']}); + browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox', '--font-render-hinting=none', '--disable-gpu']}); const page = await browser.newPage(); //await page.setViewport({width: 794, height: 1122, deviceScaleFactor: 1}); await page.goto(process.argv[2], {timeout: 3000, waitUntil: 'networkidle2'});