<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: debt_transfers
#
#  accounted_at            :datetime
#  affair_id               :integer          not null
#  amount                  :decimal(19, 4)   default(0.0)
#  created_at              :datetime         not null
#  creator_id              :integer
#  currency                :string           not null
#  debt_transfer_affair_id :integer          not null
#  id                      :integer          not null, primary key
#  journal_entry_id        :integer
#  lock_version            :integer          default(0), not null
#  nature                  :string           not null
#  number                  :string
#  updated_at              :datetime         not null
#  updater_id              :integer
#

# Debt transfers permit to include sales in purchase affairs and vice versa.
# The model works in pair. One record for the debit and one record for the
# credit.
# Mirroring on credit record is managed by model, but some errors can happen
# if the coder don't check everything. The destruction process is fragile.
class DebtTransfer < Ekylibre::Record::Base
  enumerize :nature, in: %i[sale_regularization purchase_regularization], predicates: true

  belongs_to :journal_entry, class_name: 'JournalEntry', dependent: :destroy
  belongs_to :affair, class_name: 'Affair', inverse_of: :debt_transfers
  belongs_to :debt_transfer_affair, class_name: 'Affair', inverse_of: :debt_regularizations

  # [VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`.
  validates :accounted_at, timeliness: { on_or_after: -> { Time.new(1, 1, 1).in_time_zone }, on_or_before: -> { Time.zone.now + 50.years } }, allow_blank: true
  validates :amount, numericality: { greater_than: -1_000_000_000_000_000, less_than: 1_000_000_000_000_000 }, allow_blank: true
  validates :currency, presence: true, length: { maximum: 500 }
  validates :affair, :debt_transfer_affair, :nature, presence: true
  validates :number, length: { maximum: 500 }, allow_blank: true
  # ]VALIDATORS]
  validates :debt_transfer_affair_id, uniqueness: { scope: :affair_id }<commit_msg>add constraint to debt-transfer id not null<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: debt_transfers
#
#  accounted_at            :datetime
#  affair_id               :integer          not null
#  amount                  :decimal(19, 4)   default(0.0)
#  created_at              :datetime         not null
#  creator_id              :integer
#  currency                :string           not null
#  debt_transfer_affair_id :integer          not null
#  id                      :integer          not null, primary key
#  journal_entry_id        :integer
#  lock_version            :integer          default(0), not null
#  nature                  :string           not null
#  number                  :string
#  updated_at              :datetime         not null
#  updater_id              :integer
#

# Debt transfers permit to include sales in purchase affairs and vice versa.
# The model works in pair. One record for the debit and one record for the
# credit.
# Mirroring on credit record is managed by model, but some errors can happen
# if the coder don't check everything. The destruction process is fragile.
class DebtTransfer < Ekylibre::Record::Base
  enumerize :nature, in: %i[sale_regularization purchase_regularization], predicates: true

  belongs_to :journal_entry, class_name: 'JournalEntry', dependent: :destroy
  belongs_to :affair, class_name: 'Affair', inverse_of: :debt_transfers
  belongs_to :debt_transfer_affair, class_name: 'Affair', inverse_of: :debt_regularizations

  # [VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`.
  validates :accounted_at, timeliness: { on_or_after: -> { Time.new(1, 1, 1).in_time_zone }, on_or_before: -> { Time.zone.now + 50.years } }, allow_blank: true
  validates :amount, numericality: { greater_than: -1_000_000_000_000_000, less_than: 1_000_000_000_000_000 }, allow_blank: true
  validates :currency, presence: true, length: { maximum: 500 }
  validates :affair, :debt_transfer_affair, :nature, presence: true
  validates :number, length: { maximum: 500 }, allow_blank: true
  # ]VALIDATORS]
  validates :debt_transfer_affair_id, presence: true
  validates :debt_transfer_affair_id, uniqueness: { scope: :affair_id }
{'fraction_non_alphanumeric': 0.08188711036225779, 'fraction_numerical': 0.02493681550126369, 'mean_word_length': 3.1744022503516174, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '5256908', 'n_tokens_mistral': 1833, 'n_tokens_neox': 1685, 'n_words': 626}