77 lines
2.2 KiB
Awk
77 lines
2.2 KiB
Awk
# printrun.awk
|
|
#
|
|
# calculate cost of a fanzine printrun
|
|
#
|
|
# usage:
|
|
#
|
|
# awk -f printrun.awk verteiler
|
|
#
|
|
# verteiler:
|
|
#
|
|
# csv file with info on subscriptions.
|
|
#
|
|
# format:
|
|
# best, beleg, gezahlt, verschickt, anschrift
|
|
#
|
|
# with best: zines ordered
|
|
# beleg: free zines because of submission
|
|
# gezahlt: this much has been payed
|
|
# verschickt: 0 = nothing sent yet, n = this many zines have been sent
|
|
# anschrift: postal address of subscriber
|
|
#
|
|
BEGIN {
|
|
FS=", "
|
|
bestell=0
|
|
beleg=0
|
|
zahlungen=0
|
|
# get data from file printrun
|
|
while ( getline <"printrun" ) {
|
|
split($0,a,": ")
|
|
if (a[1] == "auflage")
|
|
auflage=a[2]
|
|
else if (a[1] == "versand")
|
|
heftversand=a[2]
|
|
else if (a[1] == "druck")
|
|
druck=a[2]
|
|
else if (a[1] == "preis")
|
|
preis=a[2]
|
|
}
|
|
}
|
|
!/#.*/{
|
|
bestell=bestell+$1
|
|
beleg=beleg+$2
|
|
zahlungen=zahlungen+$3
|
|
if ( $1 !=0 && $3 > 0 ) {
|
|
porto=porto+($3 - ($1 * preis))
|
|
hefte=hefte+($1 * preis)
|
|
}
|
|
if ( $2 != 0 ) {
|
|
belegversand=$2*heftversand
|
|
}
|
|
if ( $1 != 0 || $2 != 0) {
|
|
printf "%-30.30s\tBestellungen: %3.i\n", $5, $1
|
|
printf "%-30.30s\tBelegexemplare: %3.i\n", $6, $2
|
|
printf "%-30.30s\tVersandt: %3.i\n", $7, $1+$2
|
|
printf "%-30.30s\tBezahlt: %5.2f €\n\n", $8, $3
|
|
}
|
|
}
|
|
END {
|
|
versand=porto+belegversand
|
|
heftkosten=(druck+beleg*belegvers)/(auflage-beleg)
|
|
printf "-----------------------------------------------------\n"
|
|
printf "Auflage: \t%i\tBelegexemplare:\t%i\n", auflage, beleg
|
|
printf "Bestellungen: \t%i\tRest: \t%i\n", bestell, auflage-(beleg+bestell)
|
|
printf "-----------------------------------------------------\n"
|
|
printf "Einzelpreis: %7.2f €\n", preis
|
|
printf "Heftkosten: %7.2f €\n", heftkosten
|
|
printf "Differenz: %7.2f €\n", preis-heftkosten
|
|
printf "-----------------------------------------------------\n"
|
|
printf "Einnahmen:\n"
|
|
printf "\tHeftpreis:\t%7.2f €\n", hefte
|
|
printf "\tPorto: \t%7.2f €\t%7.2f €\n\n", porto, hefte+porto
|
|
printf "Ausgaben:\n"
|
|
printf "\tDruckkosten:\t%7.2f €\n", druck
|
|
printf "\tVersand: \t%7.2f €\t%7.2f €\n\n", versand, druck+versand
|
|
printf "Ergebnis:\t\t\t\t%7.2f €\n", (hefte+porto)-(druck+versand)
|
|
}
|