Index: KPRIJS.mac.rou =================================================================== diff -u -r49060 -r49398 --- KPRIJS.mac.rou (.../KPRIJS.mac.rou) (revision 49060) +++ KPRIJS.mac.rou (.../KPRIJS.mac.rou) (revision 49398) @@ -92,56 +92,65 @@ Set BusinessType = Klant.GeefBusinessType() Do KKORTING, CALC - // VHIP907: Verkoopprijzen - // VHIP907->MVI: voorlopig laat ik alles invullen in fase 2a en overschrijf ik enkel de waarden die ax teruggeeft - - If $$IsAX(KLNr,PRNr) { - Set CacheMinuten = $ListGet($Get(^AXPrijsCache(KLNr,PRNr,$S($G(SimPPL):SimPPL,1:"*"),$S($G(Aantal):Aantal,1:"*"))),1) - - If (($$GeefMinuten($Horolog)-600) < CacheMinuten) { - Set lb=^AXPrijsCache(KLNr,PRNr,$S($G(SimPPL):SimPPL,1:"*"),$S($G(Aantal):Aantal,1:"*")) - Set VkpEURAX=$LIST(lb,2) - Set LijstEURAX=$LI(lb,3) - Set PriceUnit=$LI(lb,4) - Set InclBTW=$LI(lb,5) - } Else { - Try - { - New SalesPriceService, Result - Set SalesPriceService = ##class(AXimpl.Admin.VKP.SalesPriceService).%New() - #Dim Result as AXif.Dynamics.SalesPriceIn.MessageParts.ADUSalesPriceLineOutputDC - Set Result = SalesPriceService.GeefPrijs(KLNr, PRNr, $S($G(SimPPL):SimPPL,1:""),.Aantal) - Set VkpEURAX = Result.Price - Set LijstEURAX = Result.GrossPrice - Set PriceUnit=+Result.PriceUnit - Set InclBTW=SalesPriceService.PrijzenInclBTW() - Set ^AXPrijsCache(KLNr,PRNr,$S($G(SimPPL):SimPPL,1:"*"),$S($G(Aantal):Aantal,1:"*"))=$LB($$GeefMinuten($H),VkpEURAX,LijstEURAX,PriceUnit,InclBTW) - } Catch { - Set (VkpEURAX,LijstEURAX)=99999 - Set PriceUnit=1 - Set InclBTW=0 - #dim Exception As TECH.Exceptions.Exception = ##class(TECH.ExceptionHandler).Catch() - do ##class(vhLib.Logger).LogExceptie(Exception) + If $$IsAX(KLNr, PRNr) { + new LegacyKPRIJS, SimPplVoorAxPrijsCache, AantalVoorAxPrijsCache, Minuten + new AxPrijsCache, AxPrijsCacheRepository, AxKlantId, SalesPriceService, Result + + #dim LegacyKPRIJS As BL.Legacy.KPRIJS = ##class(BL.Legacy.KPRIJS).%New() + #dim SimPplVoorAxPrijsCache As %String = LegacyKPRIJS.GeefWaardeVoorAxPrijsCache(.SimPPL, "*") + #dim AantalVoorAxPrijsCache As %String = LegacyKPRIJS.GeefWaardeVoorAxPrijsCache(.Aantal, "*") + #dim Minuten As %Integer = LegacyKPRIJS.GeefMinuten() + + #dim AxPrijsCacheRepository As BL.Legacy.KPRIJS.AxPrijsCacheRepository = ##class(BL.Legacy.KPRIJS.AxPrijsCacheRepository).%New() + #dim AxPrijsCache As BL.Legacy.KPRIJS.AxPrijsCache = AxPrijsCacheRepository.GeefAxPrijsCache(KLNr, PRNr, SimPplVoorAxPrijsCache, AantalVoorAxPrijsCache) + #dim AxKlantId As %String = ##class(AXimpl.Utils.KlantIdConverter).%New().ConvertToAx(KlantID, ##class(DOM.common.enu.Personality).VanHoecke()) + #dim SalesPriceService As AXimpl.Admin.VKP.SalesPriceService = ##class(AXimpl.Admin.VKP.SalesPriceService).%New() + #dim Result As AXif.Dynamics.SalesPriceIn.MessageParts.ADUSalesPriceHeaderOutputDC = SalesPriceService.GeefPrijs(AxKlantId, PRNr, LegacyKPRIJS.GeefWaardeVoorAxPrijsCache(.SimPPL)) + + If ((Minuten - 600) > AxPrijsCache.Minuten) { + Try { + new ResultLine + + #dim ResultLine As AXif.Dynamics.SalesPriceIn.MessageParts.ADUSalesPriceLineOutputDC = Result.Lines.GetAt(1) + + Set AxPrijsCache.AxVerkoopPrijsEuro = ResultLine.Price + Set AxPrijsCache.AxLijstPrijsEuro = ResultLine.GrossPrice + Set AxPrijsCache.PrijsEenheid = +ResultLine.PriceUnit + Set AxPrijsCache.InclusiefBtw = Result.InclVAT + + Do AxPrijsCacheRepository.BewaarAxPrijsCache(AxPrijsCache, Minuten) + } Catch { + New Exception + + Set AxPrijsCache.AxVerkoopPrijsEuro = 99999 + Set AxPrijsCache.AxLijstPrijsEuro = 99999 + Set AxPrijsCache.PrijsEenheid = 1 + Set AxPrijsCache.InclusiefBtw = $$$False + + #dim Exception As TECH.Exceptions.Exception = ##class(TECH.ExceptionHandler).Catch() + + Do ##class(vhLib.Logger).LogExceptie(Exception) + } + } + + If ((AxPrijsCache.AxVerkoopPrijsEuro > 0) && $$$Not(AxPrijsCache.AxVerkoopPrijsEuro = 99999)) { + Set VkpEUR = AxPrijsCache.AxVerkoopPrijsEuro + Set LijstEUR = AxPrijsCache.AxLijstPrijsEuro + + If (AxPrijsCache.InclusiefBtw) { + Set VkpEUR = +$Justify(VkpEUR / 1.21, 0, 10) } - } - - If (VkpEURAX>0)&&(VkpEURAX'=99999) - { - Set VkpEUR=VkpEURAX - Set LijstEUR=LijstEURAX - If InclBTW - { - Set VkpEUR=+$J(VkpEUR/1.21,0,10) - } + Set VkpPr = VkpEUR Set LijstPr = LijstEUR - If PriceUnit>1 - { - Set VkpEUR=VkpEUR/PriceUnit - Set LijstEUR=LijstEUR/PriceUnit + + If (AxPrijsCache.PrijsEenheid > 1) { + Set VkpEUR = VkpEUR / AxPrijsCache.PrijsEenheid + Set LijstEUR = LijstEUR / AxPrijsCache.PrijsEenheid } - Set GrOrde=$Case(PriceUnit,100:"H",:"E") - Set GrOrdNum=$Case(GrOrde,"H":100,:1) + + Set GrOrde = $Case(AxPrijsCache.PrijsEenheid, 100:"H", :"E") + Set GrOrdNum = $Case(GrOrde, "H":100, :1) Set Korting2=0 If +LijstEUR=0 {