mirror of
https://github.com/LastExceed/spacermake.git
synced 2025-04-20 18:26:31 +02:00
account for power_sense
and divider
This commit is contained in:
parent
cd23f8ef19
commit
c7718b6378
@ -21,7 +21,7 @@ pub struct UserData {
|
|||||||
pub struct MachineData {
|
pub struct MachineData {
|
||||||
id: Option<i32>,
|
id: Option<i32>,
|
||||||
to_be_used: bool,
|
to_be_used: bool,
|
||||||
power_sense: bool,
|
power_sense: bool, //1 = runtime, 0 = booked time
|
||||||
divider: i32
|
divider: i32
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,16 +84,33 @@ pub fn billinglog(machine: &str, booking: &Booking) -> io::Result<()> {
|
|||||||
booking.user.to_string()
|
booking.user.to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
let artikel_id =
|
let machine_data = &DATA_MACHINES
|
||||||
if let Some(machine_data) = &DATA_MACHINES.get(&machine.to_string()) {
|
.get(&machine.to_string())
|
||||||
|
.unwrap_or(&MachineData {
|
||||||
|
id: None,
|
||||||
|
to_be_used: true,
|
||||||
|
power_sense: true,
|
||||||
|
divider: 1
|
||||||
|
});
|
||||||
|
|
||||||
if !machine_data.to_be_used { return Ok(()); }
|
if !machine_data.to_be_used { return Ok(()); }
|
||||||
machine_data
|
|
||||||
|
let artikel_id = machine_data
|
||||||
.id
|
.id
|
||||||
.map(|i| i.to_string())
|
.map(|i| i.to_string())
|
||||||
.unwrap_or(machine.to_string())
|
.unwrap_or(machine.to_string());
|
||||||
|
|
||||||
|
let anzahl =
|
||||||
|
if machine_data.power_sense {
|
||||||
|
booking.total_runtime()
|
||||||
} else {
|
} else {
|
||||||
machine.to_string()
|
booking.creation_instant.elapsed()
|
||||||
};
|
}
|
||||||
|
.as_secs_f32()
|
||||||
|
.div(60.0)
|
||||||
|
.div(machine_data.divider as f32)
|
||||||
|
.ceil()
|
||||||
|
as _;
|
||||||
|
|
||||||
let bill = BillingRecord {
|
let bill = BillingRecord {
|
||||||
user_id,
|
user_id,
|
||||||
@ -103,12 +120,7 @@ pub fn billinglog(machine: &str, booking: &Booking) -> io::Result<()> {
|
|||||||
positionsdetails: Local::now()
|
positionsdetails: Local::now()
|
||||||
.format("%Y-%m-%d")
|
.format("%Y-%m-%d")
|
||||||
.to_string(),
|
.to_string(),
|
||||||
anzahl: booking
|
anzahl,
|
||||||
.total_runtime()
|
|
||||||
.as_secs_f32()
|
|
||||||
.div(60.0)
|
|
||||||
.ceil()
|
|
||||||
as _,
|
|
||||||
rechnungstyp: 0,
|
rechnungstyp: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user