[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Calculation
From: |
Silvio Siefke |
Subject: |
Re: Calculation |
Date: |
Sun, 20 Jun 2021 18:35:39 +0200 |
On Sun, 20 Jun 2021 09:50:47 -0400
Greg Wooledge <greg@wooledge.org> wrote:
> "$i"*0.04*1.8
> This will be expanded as a glob, if possible, and if shell options have
I think only the $i need to be in double quotes. Is now changed.
I wanted to recalculate my construction sites, the prices are
increasing and I want to know if I still have enough buffer. Normal I use
libreoffice calc for this but in 100 Sites is to much. So I had idea
with Shell Scripts. For my daily routines and managing it helps
me much.
At end I use a script for the job. The size of the construction sites
are loaded in an array. With the sizes, the materials are calculated
and at the end calculated together and also calculated on the square
meter. All results are written to a CSV file.
The Script:
size.txt
90.25
50.58
59.74
12.80
10.80
98.58
15.60
39.36
20.15
825.69
1080.96
2087.69
5074.80
#STARTSCRIPT#
# the size read in to an array
readarray -t size < /home/siefke/Downloads/size.txt
# loop goes over the array and start calculate
for i in "${size[@]}"; do
# deciamal numbers round up to single number
round_days=$(concalc "$i"/150 | awk '{print
($0-int($0)<0.499)?int($0):int($0)+1}')
round_sand=$(concalc "$i*0.04*1,8" | awk '{print
($0-int($0)<0.499)?int($0):int($0)+1}')
round_cement=$(concalc "$i*0.04*15" | awk '{print
($0-int($0)<0.499)?int($0):int($0)+1}')
round_adhesive_bridge=$(concalc "$i*1.5/25" | awk '{print
($0-int($0)<0.499)?int($0):int($0)+1}')
round_edgestripes=$(concalc "$i*1.5/50" | awk '{print
($0-int($0)<0.499)?int($0):int($0)+1}')
# Salary per day
if [[ "$round_days" = 0 ]]; then
salary=$(concalc 1*8*100)
else
salary=$(concalc "$round_days*8*100")
fi
# single numbers from round_* variables count with price
sand=$(concalc "$round_sand*25")
cement=$(concalc "$round_cement*2.00")
adhesive_bridge=$(concalc "$round_adhesive_bridge*17.50")
edgestripes=$(concalc "$round_edgestripes*9.90")
# total sum of all (sand, cement, adhesive, edgestrip and salary)
total_amount=$(concalc
"$sand"+"$cement"+"$adhesive_bridge"+"$edgestripes"+"$salary")
# only material without cement because cement buy at other company with other
condition.
material_costs=$(concalc "$sand"+"$edgestripes")
# subcontractor
subcontractor=$(concalc "$i"*6)
# Special condition best would be if can here sum - 13% but found not a way.
kor=$(concalc "$adhesive_bridge+$cement")
# Endpreis pro m²
sqmprice=$(concalc "$total_amount"/"$i")
# GuV
totalwinlost=$(concalc
"$total_amount"-"$material_costs"-"$kor"-"$subcontractor")
# Daten werden in ein CSV geschrieben
write_csv "$i" "$total_amount" "$material_costs" "$kor" "$subcontractor"
"$sqmprice" "$totalwinlost" "$surcharge"
done
#ENDSCRIPT#
My goal:
round_days=$(concalc "$i"/150 | awk '{print
($0-int($0)<0.499)?int($0):int($0)+1}')
round_sand=$(concalc "$i*0.04*1,8" | awk '{print
($0-int($0)<0.499)?int($0):int($0)+1}')
sand=$(concalc "$round_sand*25")
cement=$(concalc "$round_cement*2.00")
This 4 variables for example can make in two variables. In Libreoffice for I
use the follow formula:
Sand: =ROUNDUP(90,25*0,04*1,8)*25
Cement: =ROUNDUP(90,25*0,04*15)*2
It would be also great if work percent calculation:
Cement: =ROUNDUP(90,25*0,04*15)*2*100/113
At end nothing more as
sqm*Thick*bag=result and result*price of bag
90.25*0.04*15=54.15
We round up 54.15 to 55x2=110.00 (95,70 exclude 13% = purchase price cement for
the first array)
Im sorry when can not really professionell explain, I like shell because
take much routines from me so I try to do this with it. It's also part
of understanding.
AWK mean to me a big tool but some recipes I find in net really not
easy to understand.
Thank you
Silvio
pgpcqwkAxUAdk.pgp
Description: PGP signature