quickbooks_types/models/employee.rs
1use chrono::NaiveDate;
2use serde::{Deserialize, Serialize};
3use serde_with::skip_serializing_none;
4
5use super::common::{Addr, Email, MetaData, PhoneNumber};
6#[cfg(feature = "builder")]
7use crate::error::QBTypeError;
8use crate::{QBCreatable, QBFullUpdatable, QBItem};
9
10#[skip_serializing_none]
11#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
12#[serde(rename_all = "PascalCase", default)]
13#[cfg_attr(
14 feature = "builder",
15 derive(Builder),
16 builder(default, build_fn(error = "QBTypeError"), setter(into, strip_option))
17)]
18/// Employee
19///
20/// Represents an internal staff member or contractor tracked for payroll, time entry,
21/// or billable activities in `QuickBooks` Online.
22///
23/// Creation requirements:
24/// - `QBCreatable::can_create()` returns true when either `given_name` or `family_name` is present.
25///
26/// API reference:
27/// <https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/employee>
28pub struct Employee {
29 /// The unique ID of the entity
30 pub id: Option<String>,
31 /// The unique sync token of the entity, used for concurrency control
32 pub sync_token: Option<String>,
33 /// Metadata about the entity
34 #[serde(skip_serializing)]
35 pub meta_data: Option<MetaData>,
36 /// Primary address information for the employee
37 pub primary_addr: Option<Addr>,
38 /// Primary email address for the employee
39 pub primary_email_addr: Option<Email>,
40 /// Display name of the employee
41 pub display_name: Option<String>,
42 /// Title or position of the employee
43 pub title: Option<String>,
44 /// Indicates if the employee's time can be billed to customers
45 pub billable_time: Option<bool>,
46 /// The employee's first name
47 pub given_name: Option<String>,
48 /// The employee's birth date
49 pub birth_date: Option<NaiveDate>,
50 /// The employee's middle name
51 pub middle_name: Option<String>,
52 /// The employee's Social Security Number
53 pub ssn: Option<String>,
54 /// Primary phone number for the employee
55 pub primary_phone: Option<PhoneNumber>,
56 /// Indicates if the employee is active
57 pub active: Option<bool>,
58 /// Date when the employee was released from employment
59 pub released_date: Option<NaiveDate>,
60 /// The employee's cost rate per hour
61 pub cost_rate: Option<f64>,
62 /// Mobile phone number for the employee
63 pub mobile: Option<PhoneNumber>,
64 /// The employee's gender
65 pub gender: Option<String>,
66 /// Date when the employee was hired
67 pub hired_date: Option<NaiveDate>,
68 /// The rate at which the employee's time is billed to customers
69 pub bill_rate: Option<f64>,
70 /// Indicates if the employee is an organization rather than an individual
71 pub organization: Option<bool>,
72 /// The employee's name suffix (e.g. Jr, Sr, III)
73 pub suffix: Option<String>,
74 /// The employee's last name
75 pub family_name: Option<String>,
76 /// The employee's name as it should appear on checks
77 pub print_on_check_name: Option<String>,
78 /// The employee's identification number within the company
79 pub employee_number: Option<String>,
80 /// Identity provider pseudonym for the employee
81 #[serde(rename = "V4IDPseudonym")]
82 pub v4id_pseudonym: Option<String>,
83}
84
85impl QBCreatable for Employee {
86 fn can_create(&self) -> bool {
87 self.given_name.is_some() || self.family_name.is_some()
88 }
89}
90
91impl QBFullUpdatable for Employee {
92 fn can_full_update(&self) -> bool {
93 self.has_read() && self.can_create()
94 }
95}