Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Rounding up in Simplified field notation

New Here ,
Oct 16, 2019 Oct 16, 2019

Okay so I'm doing a Simplified Field Notaion with the equation being "NumberofIndividuals*7*NumberofDaysofRations/24". This worked fine until I realized it wasnt rounding up. How can I make my total round up? Do I have to use the Custom calculation script?

2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Oct 17, 2019 Oct 17, 2019

Yes, you have to use a script for that. Try this:

 

var v1 = Number(this.getField("NumberofIndividuals").valueAsString);
var v2 = Number(this.getField("NumberofDaysofRations").valueAsString);
event.value = Math.ceil(v1*7*v2/24);

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 16, 2019 Oct 16, 2019

Please post the name of the program you use so a Moderator may move this message to that forum

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 16, 2019 Oct 16, 2019

My apologies! I'm using Adobe Acrobat DC.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 16, 2019 Oct 16, 2019

Moving to Acrobat.

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 16, 2019 Oct 16, 2019

What number format does you use?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 17, 2019 Oct 17, 2019

Yes, you have to use a script for that. Try this:

 

var v1 = Number(this.getField("NumberofIndividuals").valueAsString);
var v2 = Number(this.getField("NumberofDaysofRations").valueAsString);
event.value = Math.ceil(v1*7*v2/24);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 17, 2019 Oct 17, 2019
It worked! I truly envy your knowledge. Thank you so much.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 20, 2019 Oct 20, 2019
LATEST


Hi,

 

I wanted to share with the solution above  that you may also want to consider in your equation the Unit of Issue for the type of individual ration to be consumed.

 

It looks like you were kind of struggling with the rounding because the type of ration has to be rounded up when you place an order to your supplier, correct?

 

A box cannot be broken just to deliver to your site the exact total number of individual meals to be consumed and therefore it has to be ordered in bulk?

 

If that is correct, then the same would be true if you were ordering by pallets, in which case, you will have to consider the total boxes per pallet; and a pallet cannot be broken to match up the exact amount of individual meals with your headcount (it must be rounded up by adding individual boxes instead in addition to your pallet(s).

 

So, I assume that 24 is the number of individual meals that are supplied per box for that particular meal type?

If this is the case then great nothing else needs to be done in your equation.

 

But let's say, for example, that you need to feed up to 50 individuals up to 3 consecutive days with breakfast, lunch, and dinner meals; with the first day meal beginning with a breakfast and the last meal day ending also with a breakfast meal at the beginning of the third consumption day.

 

Then your variables should or could be expressed in the following manner:

total meals per one consumption day ( for breakfast , lunch and diner altogether) equals 3 meals per day

total number of individuals to be fed = 50
total consumption days = 3

 

You would then have to multiply 50 * 7 (in which 7 is the total meals that are forecast to be consumed during that 3 day ration cycle) which equals 350.

 

To get the total number of boxes you have to divide (in this example) 350 / 24 (individual meals per box) which equals to 14.58333333;  and we already know we cannot break a box so we round it up to 15 boxes.

 

In my form, however,  I ran into a similar issue but here is where it got tricky. The ration that I needed to order was issued by container, not per box, not per crate, not per case, not per carton nor dozens per flask, for example.

 

So using the same example above, I had to figure out the how to round up my totals when the quantity of issue for my rations was 18 individual meals per container.

 

If you get 18 individual meals per container this equation  would or could look like this:

(50 total headcount * 7 total meals ) divided by 18 individual meals per container = 19.4444 and we have to round it up to 20 containers of course and multpiply again by 18.

 

That is simply because at the warehouse level, my supplier won't calculate the totals as we did if the rations were issued per box

 

The warehouse would say instead that you will get 360 meals (keeping in mind that we are not supposed to break whole pallets,  and it is easier for the warehouse personnel to keep accountability of the issued rations due to the way that these containers are palletized).

 

If those rations come in 16 containers per pallet (of 18 individual meals per container) they have to multiply 18*16 which equals to 288 individual meals per pallet.

 

Moreover, when it comes to the total amount of money that was authorized for you to spend, then the real value that we need to use is 19.4444 which if you multiply by 18 equals to 349.9992. We have to round it up but taking into accoount that  the  warehouse don't use the fractional part of the total number  of rations to be issued in bulk; they will issue out to you 360 individual meals instead of 350 ....   again this is important to keep in mind if you are THAT GUY managing these type of accounts. 

 

They are basically adding one more container, but in javascript all of this becomes annoyingly funny to figure out.

 

So I was able to work around this situation, for which this particular Unit of Issue for this ration had to be expressed in my PDF forms like this :

 

((total headcount * total meals) / 18)*18 =

((50 * 7 )/18)*18
= (350/18)*18
= 19.4444*18
= 349.92  <<<-------rounding up to 350 does not work in this case when the unit of issue of 18 meals per container  is taken into account

 

The custom calc script would look like this :

var s = 18
var t = 18
var v = this.getField("TotalMeals").valueAsString;
var x = this.getField("TotalHeadcount").valueAsString;
event.value = (Math.ceil(x*v)/s)*t;

 

You have to round up first this part ------>>>>  (Math.ceil(x*v)/s)  <<<---------  and then multiply whatever rounded total value by 18 again to get the correct quantity that the warehouse will issue out to your pickup guy(s).

 

OR (in the long way),

var s = 18
var t = 18
event.value = (Math.ceil(((this.getField("TotalMeals").valueAsString)*(this.getField("TotalHeadcount").valueAsString))/s))*t;

 

NOTE: On the pickup days , I also want to be personnally present during loadup procedures and re-verify the warehouse picklists against my original approved documents; is never a good idea to just send  a driver up to a warehouse  to pickup your rations and sign a picklist worth  thousands of dollars in rations on your behalf (and probably without even inspecting the packaging and expiration dates in those boxes).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines