Skip to main content

PurchaseRequisition

Struct PurchaseRequisition 

Source
pub struct PurchaseRequisition {
Show 23 fields pub header: DocumentHeader, pub pr_type: PurchaseRequisitionType, pub priority: RequisitionPriority, pub requester_id: String, pub requester_name: Option<String>, pub requester_email: Option<String>, pub requester_department: Option<String>, pub approver_id: Option<String>, pub purchasing_org: String, pub purchasing_group: Option<String>, pub items: Vec<PurchaseRequisitionItem>, pub total_net_amount: Decimal, pub total_tax_amount: Decimal, pub total_gross_amount: Decimal, pub is_approved: bool, pub is_converted: bool, pub is_closed: bool, pub purchase_order_ids: Vec<String>, pub justification: Option<String>, pub budget_code: Option<String>, pub workflow_id: Option<String>, pub notes: Option<String>, pub desired_vendor: Option<String>,
}
Expand description

Purchase Requisition document.

Fields§

§header: DocumentHeader

Document header

§pr_type: PurchaseRequisitionType

PR type

§priority: RequisitionPriority

Priority

§requester_id: String

Requester user ID (document-level)

§requester_name: Option<String>

Requester name

§requester_email: Option<String>

Requester email

§requester_department: Option<String>

Requester department

§approver_id: Option<String>

Approver user ID (document-level)

§purchasing_org: String

Purchasing organization

§purchasing_group: Option<String>

Default purchasing group

§items: Vec<PurchaseRequisitionItem>

Line items

§total_net_amount: Decimal

Total net amount

§total_tax_amount: Decimal

Total tax amount

§total_gross_amount: Decimal

Total gross amount

§is_approved: bool

Is this PR fully approved?

§is_converted: bool

Is this PR fully converted to PO(s)?

§is_closed: bool

Is this PR closed?

§purchase_order_ids: Vec<String>

Related PO IDs (multiple POs can be created from one PR)

§justification: Option<String>

Business justification (document-level)

§budget_code: Option<String>

Budget code for approval routing

§workflow_id: Option<String>

Approval workflow ID

§notes: Option<String>

Notes/comments

§desired_vendor: Option<String>

Desired vendor (document-level preference)

Implementations§

Source§

impl PurchaseRequisition

Source

pub fn new( pr_id: impl Into<String>, company_code: impl Into<String>, requester_id: impl Into<String>, fiscal_year: u16, fiscal_period: u8, document_date: NaiveDate, created_by: impl Into<String>, ) -> Self

Create a new purchase requisition.

Source

pub fn with_pr_type(self, pr_type: PurchaseRequisitionType) -> Self

Set PR type.

Source

pub fn with_priority(self, priority: RequisitionPriority) -> Self

Set priority.

Source

pub fn with_purchasing_org(self, org: impl Into<String>) -> Self

Set purchasing organization.

Source

pub fn with_purchasing_group(self, group: impl Into<String>) -> Self

Set purchasing group.

Source

pub fn with_requester_details( self, name: impl Into<String>, email: impl Into<String>, department: impl Into<String>, ) -> Self

Set requester details.

Source

pub fn with_justification(self, justification: impl Into<String>) -> Self

Set justification.

Source

pub fn with_budget_code(self, code: impl Into<String>) -> Self

Set budget code.

Source

pub fn with_desired_vendor(self, vendor: impl Into<String>) -> Self

Set desired vendor.

Source

pub fn add_item(&mut self, item: PurchaseRequisitionItem)

Add a line item.

Source

pub fn recalculate_totals(&mut self)

Recalculate totals from items.

Source

pub fn submit(&mut self, user: impl Into<String>)

Submit the PR for approval.

Source

pub fn approve(&mut self, approver: impl Into<String>)

Approve the entire PR.

Source

pub fn reject(&mut self, approver: impl Into<String>, reason: impl Into<String>)

Reject the entire PR.

Source

pub fn release(&mut self, user: impl Into<String>)

Release the PR for conversion to PO.

Source

pub fn convert_to_po( &mut self, po_id: impl Into<String>, user: impl Into<String>, )

Convert to PO (mark as converted).

Source

pub fn close(&mut self, user: impl Into<String>)

Close the PR.

Source

pub fn open_amount(&self) -> Decimal

Get total open amount (not yet converted to PO).

Source

pub fn approved_item_count(&self) -> usize

Get count of approved items.

Source

pub fn rejected_item_count(&self) -> usize

Get count of rejected items.

Source

pub fn converted_item_count(&self) -> usize

Get count of converted items.

Source

pub fn all_items_approved(&self) -> bool

Check if all items are approved.

Source

pub fn has_convertible_items(&self) -> bool

Check if any items can be converted.

Trait Implementations§

Source§

impl Clone for PurchaseRequisition

Source§

fn clone(&self) -> PurchaseRequisition

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PurchaseRequisition

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PurchaseRequisition

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for PurchaseRequisition

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,