<commit_before># = Informations
#
# == License
#
# Ekylibre - Simple agricultural ERP
# Copyright (C) 2008-2009 <NAME>, <NAME>
# Copyright (C) 2010-2012 <NAME>
# Copyright (C) 2012-2017 <NAME>, <NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see http://www.gnu.org/licenses.
#
# == Table: parcel_item_storings
#
#  created_at     :datetime         not null
#  creator_id     :integer
#  id             :integer          not null, primary key
#  lock_version   :integer          default(0), not null
#  parcel_item_id :integer          not null
#  quantity       :integer
#  storage_id     :integer          not null
#  updated_at     :datetime         not null
#  updater_id     :integer
#
class ParcelItemStoring < Ekylibre::Record::Base

  belongs_to :parcel_item, inverse_of: :storings
  belongs_to :storage, class_name: 'Product'

  # [VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`.
  validates :quantity, numericality: { only_integer: true, greater_than: -2_147_483_649, less_than: 2_147_483_648 }, allow_blank: true
  validates :parcel_item, :storage, presence: true
  # ]VALIDATORS]
  validates :quantity, presence: true
end<commit_msg>For a merchandise, the total quantity is calculated with the addition of its storage zone quantity<commit_after># = Informations
#
# == License
#
# Ekylibre - Simple agricultural ERP
# Copyright (C) 2008-2009 <NAME>, <NAME>
# Copyright (C) 2010-2012 <NAME>
# Copyright (C) 2012-2017 <NAME>, <NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see http://www.gnu.org/licenses.
#
# == Table: parcel_item_storings
#
#  created_at     :datetime         not null
#  creator_id     :integer
#  id             :integer          not null, primary key
#  lock_version   :integer          default(0), not null
#  parcel_item_id :integer          not null
#  quantity       :integer
#  storage_id     :integer          not null
#  updated_at     :datetime         not null
#  updater_id     :integer
#
class ParcelItemStoring < Ekylibre::Record::Base

  belongs_to :parcel_item, inverse_of: :storings
  belongs_to :storage, class_name: 'Product'

  # [VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`.
  validates :quantity, numericality: { only_integer: true, greater_than: -2_147_483_649, less_than: 2_147_483_648 }, allow_blank: true
  validates :parcel_item, :storage, presence: true
  # ]VALIDATORS]
  validates :quantity, presence: true

  after_create do 
  	population = parcel_item.population
  	population += self.quantity
	parcel_item.update_attributes(population: population)
  end

  after_update do
  	population = parcel_item.population
  	population -= self.quantity_was
  	population += self.quantity
	parcel_item.update_attributes(population: population)
  end

  after_destroy do
	population = parcel_item.population
  	population -= self.quantity_was
	parcel_item.update_attributes(population: population)
  end
end
{'fraction_non_alphanumeric': 0.07789317507418397, 'fraction_numerical': 0.02274975272007913, 'mean_word_length': 3.7365339578454333, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7567844', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1167, 'n_words': 439}