Reverse engineering a duty rate when dealing with small values

  • I need to compute the Duty Rate on an item by dividing the Duty Paid by the Value of the goods.  
    and this code works:

  • CASE when [VALUE] =0 THEN 0 ELSE Round(CAST([Duty] AS float) / CAST([Value] AS float),3) END as [Duty Rate]
  • But, if the value is low, then i get incorrect duty rates . . .

    HTS_NumDuty RateVALUEDUTY
    39235000000.0550.910.05
    39235000000.0492.240.11
    39235000000.0462.40.11
    39235000000.0494.280.21
    39235000000.05212.350.64
    .053 is corrrect0.05390.294.77
    .053 is corrrect0.05396.745.14

    Is there a different SQL i can use to get those first 6 rows to come out as .053  ???

    thanks

  • I don't believe there is, since the value is rounded up.  You can calc the rate that would produce the rounded-up amount, but I can't see how  you would ever know if/how much the final duty amount reflected rounding.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • thanks, but do i HAVE TO round?????

  • All taxing authorities I know of at least allow rounding of tax amounts, and afaik all businesses do it.  After all, it's ultimately extra money to them to charge more tax.

    With a rate like 0.053, it's obviously the result will not always be an even penny, in which case it gets rounded up.  Heaven knows the govt can't give up all those pennies!

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Agreed . . . their concern is that if it isnt ".053" on a dollar part, why would it be it be ".053" on a million dollar part . . . 
    We do have tables that tell us what the actual rate is/was . . . but we are going back 5 years, and those duty rates can change twice a year . . . . and matching up the correct rate to the actual entry date is a nightmare.

    THANKS, I can consider this SOLVED . . .

  • jeffshelix - Friday, March 23, 2018 1:49 PM

    Agreed . . . their concern is that if it isnt ".053" on a dollar part, why would it be it be ".053" on a million dollar part . . . 
    We do have tables that tell us what the actual rate is/was . . . but we are going back 5 years, and those duty rates can change twice a year . . . . and matching up the correct rate to the actual entry date is a nightmare.

    THANKS, I can consider this SOLVED . . .

    Yeah, that's no easy task.  Unfortunately, the best you could possibly do is AVERAGE a large number of computations, and your "computed rate" would "improve " over time, as it converges on the actual rate.  Better to have someone that maintains a table with rates and effective dates, simplifying the task of finding the right rate, but that's not always practical.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • Viewing 6 posts - 1 through 5 (of 5 total)

    You must be logged in to reply to this topic. Login to reply