View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001141 | Основные фонды и МБП | General | public | 2017-08-09 14:26 | 2017-08-09 14:26 |
Reporter | ruslan | Assigned To | |||
Priority | urgent | Severity | crash | Reproducibility | always |
Status | new | Resolution | open | ||
Summary | 0001141: -ОФ и МБП при расчете амортизации/исноса линейным методом по сроку использования не учитывает нач. износ | ||||
Description | Я разобрался с процедурой расчета там были несколько ошибок я их пометил и исправил, проверь пожалуйста и внеси в эталонную базу - пример я тебе в базе сделаю для проверки. | ||||
Additional Information | create procedure MAINMEAN_CLCAM2 ( MAINID integer, GRPTYP integer, MID integer) returns ( BPRICE double precision, AMNORM double precision, ASUMMA double precision, ASUMMA1 double precision, OLDBSUMMA double precision, USE_PERIOD integer, M1 integer, M2 integer, OLDTYP integer, BMDATE timestamp, EMDATE timestamp, BPDATE date, EPDATE date, LPRICE double precision, CSUMMA double precision, OLDPERIOD integer) as -- расчет амортизации/износа линейным методом (по сроку использования) declare variable GRPID integer; declare variable INPDATE date; declare variable OUTDATE date; declare variable AMCLOSED integer; declare variable AMCLOSED1 integer; declare variable AMTYP integer; declare variable MULT double precision; declare variable PERIOD integer; declare variable ADATE date; declare variable AY integer; declare variable AM integer; declare variable AD integer; declare variable BAMSUMMA double precision; declare variable AMSUM double precision; declare variable OLDGRPTYP integer; declare variable SLVID integer; declare variable TYP integer; declare variable SID integer; declare variable INPDATE1 timestamp; declare variable PPERIOD integer; begin bPrice = 0.0; aSumma = 0.0; OldBSumma = Null; Select Dat_, Period from MainAmMst where ID=:MID into :aDate, :Period; pPeriod = :Period; if (:aDate is Null) then begin suspend; exit; end Typ = 2; if (:GrpTyp=0) then begin -- амортизация OldTyp = Null; select first 1 S.ID, S.Typ, S.Price, S.Summa, M1.Period From MainMean M join MainAmSlv s ON s.mainmeanid=M.ID join MainAmMst M1 on M1.ID=S.MstID where M.ID=:MainID and M1.GrpTyp=0 order by S.ID desc into :SID, :OldTyp, :OldBSumma, :aSumma1, :OldPeriod; -- предыдуший метод расчета / балансовая стоимость if (:OldTyp is not Null and :OldTyp <> :Typ) then begin if (:OldTyp=0) then begin select CoalEsce(Sum(S.Summa),0.0) from MainMean M join MainAmSlv S on S.MainMeanID=M.ID join MainAmMst M1 on M1.ID=S.MstID where M.ID=:MainID and M1.GrpTyp=0 and S.ID <= :SID into :aSumma1; select CoalEsce(M.asumma, 0.0) from MainMean M where M.ID=:MainID into :bamsumma; OldBSumma = :OldBSumma - :aSumma1 - :bAmSumma; end if (:OldTyp=1) then begin select first 1 S.PRICE, S.Summa from MainMean M join MainAmSlv s ON s.mainmeanid=M.ID join MainAmMst M1 on M1.ID=S.MstID where M.ID=:MainID and M1.GrpTyp=0 order by S.ID desc into :OldBSumma, :aSumma1; OldBSumma = :OldBSumma - :aSumma1; end end else begin select first 1 S.PRICE, S.Summa from MainMean M join MainAmSlv s ON s.mainmeanid=M.ID join MainAmMst M1 on M1.ID=S.MstID where M.ID=:MainID and M1.GrpTyp=0 order by S.ID desc into :OldBSumma, :aSumma1; OldBSumma = :OldBSumma - :aSumma1; end select M.Price, M.GroupID, M.DAT_, M.Out_Date, M.AmClosed, M.AmClosed1, G.Typ, G.Mult, G.AmNorm, M.aSumma, M.Use_Period, M.Inp_Date, coalesce(M.LPrice,0.0) from MainMean M join MainGrp G on G.ID=M.GroupID where M.ID = :MainID into :bPrice, :GrpID, :InpDate, :OutDate, :AmClosed, :AmClosed1, :AmTyp, :Mult,:AmNorm, :bAmSumma, :Use_Period, :InpDate1, :LPRICE; end if (:GrpTyp=1) then begin-- износ OldTyp = Null; select first 1 S.ID, S.Typ, S.Price, S.Summa, M1.Period From MainMean M join MainAmSlv s ON s.mainmeanid=M.ID join MainAmMst M1 on M1.ID=S.MstID where M.ID=:MainID and M1.GrpTyp=1 order by S.ID desc into :SID, :OldTyp, :OldBSumma, :aSumma1, :OldPeriod; -- предыдуший метод расчета / балансовая стоимость if (:OldTyp is not Null and :OldTyp <> :Typ) then begin -- метод расчета меняется if (:OldTyp=0) then begin select CoalEsce(Sum(S.Summa),0.0) from MainMean M join MainAmSlv S on S.MainMeanID=M.ID join MainAmMst M1 on M1.ID=S.MstID where M.ID=:MainID and M1.GrpTyp=1 and S.ID <= :SID into :aSumma1; select CoalEsce(M.asumma1, 0.0) from MainMean M where M.ID=:MainID into :bamsumma; OldBSumma = :OldBSumma - :aSumma1 - :bamsumma; end if (:OldTyp = 1) then begin select first 1 S.PRICE, S.Summa from MainMean M join MainAmSlv s ON s.mainmeanid=M.ID join MainAmMst M1 on M1.ID=S.MstID where M.ID=:MainID and M1.GrpTyp=1 order by S.ID desc into :OldBSumma, :aSumma1; OldBSumma = :OldBSumma - :aSumma1; end end else begin -- метод расчета не меняется select first 1 S.PRICE, S.Summa from MainMean M join MainAmSlv s ON s.mainmeanid=M.ID join MainAmMst M1 on M1.ID=S.MstID where M.ID=:MainID and M1.GrpTyp=1 order by S.ID desc into :OldBSumma, :aSumma1; OldBSumma = :OldBSumma - :aSumma1; end select M.Price, M.GroupID1, M.DAT_, M.Out_Date, M.AmClosed, M.AmClosed1, G.Typ, G.Mult, G.AmNorm, M.aSumma1, M.Use_Period, M.Inp_Date, coalesce(M.LPrice,0.0) from MainMean M join MainGrp G on G.ID=M.GroupID1 where M.ID = :MainID into :bPrice, :GrpID, :InpDate, :OutDate, :AmClosed, :AmClosed1, :AmTyp, :Mult,:AmNorm, :bAmSumma, :Use_Period, :InpDate1, :LPRICE; -- начальная амортизация/износ end if (:bAmSumma is Null) then bAmSumma = 0.0; -- начало периода - bpDate if (oldperiod is null) then OldPeriod = :period; if (:OldPeriod=0) then begin -- месяц Select xDate from f_MonthFirstDay(:aDate) into :bpDate; Select xDate from f_MonthLastDay(:aDate) into :epDate; end if (:OldPeriod=1) then begin -- квартал Select xDate from f_Quarter_Beg(:aDate) into :bpDate; Select xDate from f_Quarter_End(:aDate) into :epDate; end if (:OldPeriod=2) then begin -- год execute procedure f_DecodeDate(:aDate) returning_values (:aY, :aM, :aD); Select Result from f_EncodeDate(:aY,1,1) into :bpDate; Select Result from f_EncodeDate(:aY,12,31) into :epDate; end if ( (:GrpID is Null) or (:InpDate >= :bpDate) or (:AmTyp <> 2) ) then begin -- нет такого ОС или группа не задана -- ОС еще не введено в экспл. -- не линейная амортизация bPrice = 0.0; suspend; exit; end if (:OutDate is not Null and :OutDate < :bpDate and ((:AmClosed=0 and :GrpTyp=0) or (:AmClosed1=0 and :GrpTyp=1)))then begin -- ОС списано и не начислять аморт. после выбытия bPrice = 0.0; suspend; exit; end select first 1 M1.DAT_ from MainMean M join MainAmSlv s ON s.mainmeanid=M.ID join MainAmMst M1 on M1.ID=S.MstID where M.ID=:MainID and M1.GrpTyp=:GrpTyp and M1.ID < :MID order by M1.ID desc into :emDate; cSumma = 0.0; --emDate = bpDate - 1.0; if (:emDate is not Null) then begin -- ранее производилось начисление, были ли изменения стоимости if (:OldPeriod=0) then begin Select xDate from f_MonthFirstDay(:emDate) into :bmDate; end if (:OldPeriod=1) then begin Select xDate from f_Quarter_Beg(:emDate) into :bmDate; end if (:OldPeriod=2) then begin execute procedure f_DecodeDate(:emDate) returning_values (:aY, :aM, :aD); Select Result from f_EncodeDate(:aY,1,1) into :bmDate; end if (:GrpTyp=0) then begin select CoalEsce(Sum(Summa), 0.0) from MainPrice where MainID = :MainID and DAT_ >= :bmDate and DAT_ <= :emDate and (EXCL0 is Null or Excl0=0) and Bin_And(CoalEsce(System_Flag, 0), 1) = 0 into :cSumma; select :cSumma + CoalEsce(Sum(Summa), 0.0) from MainPrice where MainID = :MainID and DAT_ >= :bpDate and DAT_ <= :epDate and (EXCL0 is Null or Excl0=0) and Bin_And(CoalEsce(System_Flag, 0), 1) <> 0 into :cSumma; end if (:GrpTyp=1) then begin select CoalEsce(Sum(Summa), 0.0) from MainPrice where MainID = :MainID and DAT_ >= :bmDate and DAT_ <= :emDate and (EXCL1 is Null or Excl1=0) and Bin_And(CoalEsce(System_Flag, 0), 1) = 0 into :cSumma; select :cSumma + CoalEsce(Sum(Summa), 0.0) from MainPrice where MainID = :MainID and DAT_ >= :bpDate and DAT_ <= :epDate and (EXCL1 is Null or Excl1=0) and Bin_And(CoalEsce(System_Flag, 0), 1) <> 0 into :cSumma; end end if (:emDate is Null) then begin -- ранее амортизация / износ не начислялись -- начальная амортизация / износ emDate = bpDate - 1.0; --исправил - перенес if (:GrpTyp=0) then begin -- изменение стоимости select CoalEsce(Sum(Summa), 0.0) from MainPrice where MainID = :MainID and DAT_ < :aDate and (Excl0 is Null or Excl0=0) -- не исключено из начисления амортизации and Bin_And(CoalEsce(System_Flag, 0), 1) = 0 into :cSumma; select :cSumma + CoalEsce(Sum(Summa), 0.0) from MainPrice where MainID = :MainID and DAT_ >= :bpDate and DAT_ <= :epDate and (Excl0 is Null or Excl0=0) and Bin_And(CoalEsce(System_Flag, 0), 1) <> 0 into :cSumma; end if (:GrpTyp=1) then begin -- изменение стоимости select CoalEsce(Sum(Summa), 0.0) from MainPrice where MainID = :MainID and DAT_ < :aDate and (Excl1 is Null or Excl1=0) -- не исключено из начисления износа and Bin_And(CoalEsce(System_Flag, 0), 1) = 0 into :cSumma; select :cSumma + CoalEsce(Sum(Summa), 0.0) from MainPrice where MainID = :MainID and DAT_ >= :bpDate and DAT_ <= :epDate and (Excl1 is Null or Excl1=0) -- не исключено из начисления износа and Bin_And(CoalEsce(System_Flag, 0), 1) <> 0 into :cSumma; end --cSumma = 187.12; убрал зачем-то явное присвоение --bPrice = :bPrice - :bAmSumma; end bPrice = :bPrice - :bAmSumma; --перенес из за end иначе не брало начальнизнос у ОФ, которые амортизировались if (:cSumma is Null) then cSumma = 0.0; if (:OldBSumma is not Null) then bPrice = :OldBSumma; bPrice = :bPrice + :cSumma; -- кол-во месяцев эксплуатации if (:InpDate1 is not Null) then begin select Count_months from f_Count_Months (:InpDate1, :bpDate-1.0) into :M1; end else begin select Count_months from f_Count_Months (:InpDate, :bpDate-1.0) into :M1; end M1 = :M1-1; -- остоток месяцев эксплуатации M2 = :Use_Period - :M1; aSumma = 0.0; if (:M2 <= 0) then -- срок использования исчерпан bPrice = 0.0; if (:bPrice < 0.0) then bPrice = 0.0; if (Abs(:bPrice) < 0.005) then bPrice=0.0; if (:M2 > 0) then begin if (:Period=0) then begin -- месяц aSumma = (:bPrice - :lPrice) / :M2; end if (:Period=1) then begin -- квартал aSumma = (:bPrice - :lPrice) / :M2 * 3; end end if (:aSumma > :bPrice) then aSumma = :bPrice; if (:AmSum is Null) then AmSum = 0.0; if (:aSumma > :bPrice) then begin aSumma = :bPrice; end Suspend; end | ||||
Tags | No tags attached. | ||||
Date Modified | Username | Field | Change |
---|---|---|---|
2017-08-09 14:26 | ruslan | New Issue |