Permalink
Browse files

Merge pull request #2328 from ekylibre/debug/payment-delay

Debug/payment delay
  • Loading branch information...
Aquaj committed Oct 30, 2018
2 parents 240fb0d + 9f952d5 commit 7901264a782777ceb4273fd4f2a24a648f21ce82
View
@@ -13,7 +13,7 @@ gem 'activerecord-postgis-adapter', '>= 3.0.0'
gem 'pg', '~> 0.20.0' # Needed for some tasks
# Multi-tenancy
gem 'apartment', '>= 1.2.0', '< 2.0'
gem 'apartment', github:'influitive/apartment', branch: 'development'
gem 'apartment-sidekiq'
# Ruby syntax extensions
View
@@ -1,3 +1,14 @@
GIT
remote: git://github.com/influitive/apartment.git
revision: a4332c3222210b11f5e8c27fa4c1a18b492e9629
branch: development
specs:
apartment (2.2.0)
activerecord (>= 3.1.2, < 6.0)
parallel (>= 0.7.1)
public_suffix (>= 2)
rack (>= 1.3.6)
GEM
remote: https://rubygems.org/
specs:
@@ -57,9 +68,6 @@ GEM
gyoku (>= 0.4.0)
nokogiri
ansi (1.5.0)
apartment (1.2.0)
activerecord (>= 3.1.2, < 6.0)
rack (>= 1.3.6)
apartment-sidekiq (1.2.0)
apartment (>= 1.0)
sidekiq (>= 2.11)
@@ -579,7 +587,7 @@ DEPENDENCIES
activerecord-postgis-adapter (>= 3.0.0)
acts_as_list
agric (~> 3.0)
apartment (>= 1.2.0, < 2.0)
apartment!
apartment-sidekiq
awesome_nested_set (~> 3.1.1)
beardley (~> 1.3)
@@ -698,4 +706,4 @@ RUBY VERSION
ruby 2.4.3p205
BUNDLED WITH
1.16.4
1.16.6
View
@@ -148,11 +148,7 @@ class Purchase < Ekylibre::Record::Base
if payment_delay.blank? && supplier && supplier.supplier_payment_delay
self.payment_delay = supplier.supplier_payment_delay
end
self.payment_at = if payment_delay.blank?
invoiced_at || self.planned_at
else
Delay.new(payment_delay).compute(invoiced_at || self.planned_at)
end
self.pretax_amount = items.sum(:pretax_amount)
self.amount = items.sum(:amount)
end
@@ -163,6 +159,14 @@ class Purchase < Ekylibre::Record::Base
end
end
after_validation do
self.payment_at = if payment_delay.blank?
invoiced_at || self.planned_at
elsif errors[:payment_delay].none?
Delay.new(payment_delay).compute(invoiced_at || self.planned_at)
end
end
after_update do
affair.update_attributes(third_id: third.id) if affair && affair.deals.count == 1
affair.reload_gaps if affair
@@ -9,7 +9,7 @@
= f.association :nature, as: :hidden
= f.input :reference_number
= f.input :invoiced_at
= f.input :payment_delay
= f.input :payment_delay, placeholder: :payment_delay_placeholder.tl
= f.input :tax_payability, as: :radio_buttons
= f.referenced_association :responsible, source: :employees, new: { employed: 1 }
= f.input :description
@@ -907,6 +907,8 @@ eng:
one: "%{count} error prohibited this %{model} from being saved"
other: "%{count} errors prohibited this %{model} from being saved"
front-end:
bank_reconciliation:
remove: "Remove"
leaflet:
draw:
handlers:
@@ -1671,6 +1673,7 @@ eng:
payment_amount: "Amount of payment" #?
payment_at: "Payment on" #?
payment_conditions: "Payment conditions"
payment_delay_placeholder: "eom, 5 days before"
payment_mode: "Payment mode" #?
payments: "Payments"
payments_count: "Payments count"
@@ -2511,4 +2514,4 @@ eng:
backend/products: "%{work_number} %{name} (%{number})"
backend/purchase_payments: "%{number}. %{mode_name} to %{payee_full_name} of %{amount} %{currency}"
backend/trackings: "%{serial} ‒ %{name} ‒ %{producer_full_name}"
backend/users: "%{first_name} %{last_name}"
backend/users: "%{first_name} %{last_name}"
@@ -190,6 +190,8 @@ eng:
unvalid_amounts: "The journal entry must be filled either debit or credit but not at the same time."
outgoing_parcel_item:
greater_than_undelivered_quantity: "The quantity of %{product} to deliver is greater than the available quantity (%{maximum}%{unit})"
purchase:
payment_delay_custom_validation_message: "Accepted formats : %{values}"
purchase_item:
building_can_not_receive_product: "The building %{building} can not receive %{product}, it already contains %{contained_product}."
serial_already_used_with_an_other_product: "%{attribute} has been already used for an other product of the same supplier"
@@ -1962,4 +1964,4 @@ eng:
invitation:
pending: "Pending invitation"
registration:
pending: "Pending approval"
pending: "Pending approval"
@@ -744,6 +744,8 @@ fra:
one: "%{count} erreur a empêché l’enregistrement (%{model})"
other: "%{count} erreurs ont empêché l’enregistrement (%{model})"
front-end:
bank_reconciliation:
remove: "Effacer"
leaflet:
draw:
handlers:
@@ -1779,6 +1781,7 @@ fra:
payment_amount: "Montant de l’encaissement"
payment_at: "Payé le"
payment_conditions: "Conditions de règlement"
payment_delay_placeholder: "fdm, 5 jours avant"
payment_label: "%{number}. %{amount} (%{usable_amount} restants) du %{date} par %{mode} de %{entity}" #?
payment_mode: "Mode d’encaissement"
payments: "Règlements"
@@ -2853,4 +2856,4 @@ fra:
backend/products: "%{work_number} %{name} (%{number}) - %{container_name}"
backend/purchase_payments: "%{number}. %{mode_name} pour %{payee_full_name} de %{amount} %{currency}"
backend/trackings: "%{serial} ‒ %{name} ‒ %{producer_full_name}"
backend/users: "%{first_name} %{last_name}"
backend/users: "%{first_name} %{last_name}"
@@ -326,6 +326,8 @@ fra:
unvalid_amounts: "L’écriture doit être renseignée soit au débit, soit au crédit mais pas les deux en même temps."
outgoing_parcel_item:
greater_than_undelivered_quantity: "La quantité de produit %{product} à livrer dépasse la quantité non livrée (%{maximum}%{unit})"
purchase:
payment_delay_custom_validation_message: "Formats acceptés : %{values}"
purchase_item:
building_can_not_receive_product: "Le réservoir %{building} ne peut pas recevoir le produit %{product}, il contient déjà le produit %{contained_product}."
serial_already_used_with_an_other_product: "%{attribute} a déjà été utilisé pour un autre type de produit du même fournisseur"
@@ -2219,4 +2221,4 @@ fra:
invitation:
pending: "Invitation en attente"
registration:
pending: "Confirmation en attente"
pending: "Confirmation en attente"
Oops, something went wrong.

0 comments on commit 7901264

Please sign in to comment.