Procedura-GetNewLastPaymentPeriod

Parametry:

NázevPopisDatový typ
OldClosingPeriodChar(10)
NewClosingPeriodChar(10)
OldLastPaymentPeriodChar(10)
NewLastPaymentPeriodChar(10)

Návratové hodnoty:

NázevPopisDatový typ
LastPaymentPeriodChar(10)

Tělo:

BEGIN
  if (((OldClosingPeriod <> NewClosingPeriod) or
    (OldClosingPeriod is Null and NewClosingPeriod is Not Null) or
    (OldClosingPeriod is Not Null and NewClosingPeriod is Null))
    and
    ((OldLastPaymentPeriod <> NewLastPaymentPeriod) or
    (OldLastPaymentPeriod is Null and NewLastPaymentPeriod is Not Null) or
    (OldLastPaymentPeriod is Not Null and NewLastPaymentPeriod is Null))) then
    exception ErrDoubleChangeNotPossible;
  LastPaymentPeriod = NewLastPaymentPeriod;
  if ((OldClosingPeriod = NewClosingPeriod) or
    (OldClosingPeriod is Null and NewClosingPeriod is Null)) then begin
    if (OldLastPaymentPeriod is Not Null) then begin
      mAction = 0;
      if (OldClosingPeriod = OldLastPaymentPeriod) then
        begin
          /* Pokud se obdobi uzaverky a puvodni hodnoty obdobi posledni platby */
          /* Musim testnout zda je období platby vetsi nez posledni obdobi platby */
          select SequenceNumber from Periods where ID = :OldLastPaymentPeriod
            into mOldSN;
          if (OldLastPaymentPeriod = NewLastPaymentPeriod) then
            mAction = 1;
          else
            begin
              select SequenceNumber from Periods where ID = :NewLastPaymentPeriod
                into mNewSN;
              if (mOldSN >= mNewSN) then
                mAction = 1;
            end
          if (mAction = 1) then begin
            mOldSN = mOldSN + 1;
            select ID from Periods where SequenceNumber = :mOldSN
              into LastPaymentPeriod;
          end
        end
      else
        begin
          if ((OldLastPaymentPeriod = NewLastPaymentPeriod) or
            (OldLastPaymentPeriod is Null and NewLastPaymentPeriod is Null)) then
            mAction = 1;
          else
            begin
              select SequenceNumber from Periods where ID = :OldLastPaymentPeriod
                into mOldSN;
              select SequenceNumber from Periods where ID = :NewLastPaymentPeriod
                into mNewSN;
              if (mOldSN >= mNewSN) then
                mAction = 1;
            end
          if (mAction = 1) then
            LastPaymentPeriod = OldLastPaymentPeriod;
        end
    end
  end
END;

Generated by ABRA Software a.s. 27.10.2021 16:34:15