Skip to content

Commit

Permalink
fix: add quality control price to genetic analysis order (#466)
Browse files Browse the repository at this point in the history
* Update impl_genetic_analysis_orders.rs

* Update impl_genetic_analysis_orders.rs

* Update impl_genetic_analysis_orders.rs

* Update impl_genetic_analysis_orders.rs
  • Loading branch information
RiXelanya authored Sep 22, 2023
1 parent 49c7e87 commit 5871415
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::*;
use frame_support::sp_runtime::traits::Zero;
use traits_genetic_analysis_orders::{
GeneticAnalysisOrderEventEmitter, GeneticAnalysisOrderStatusUpdater,
};
Expand Down Expand Up @@ -236,7 +237,16 @@ impl<T: Config> GeneticAnalysisOrderInterface<T> for Pallet<T> {
return Err(Error::<T>::GeneticAnalysisOrderNotYetExpired)
}

let total_price = genetic_analysis_order.total_price;
let mut testing_price = Zero::zero();
let mut qc_price = Zero::zero();

for price in genetic_analysis_order.prices.iter() {
testing_price += price.value;
}

for price in genetic_analysis_order.additional_prices.iter() {
qc_price += price.value;
}
let asset_id = genetic_analysis_order.asset_id;
let account_id = Self::account_id();

Expand All @@ -245,7 +255,15 @@ impl<T: Config> GeneticAnalysisOrderInterface<T> for Pallet<T> {
&genetic_analysis_order.currency,
&account_id,
&genetic_analysis_order.customer_id,
total_price,
testing_price,
asset_id,
)?;

Self::do_transfer(
&genetic_analysis_order.currency,
&account_id,
&genetic_analysis_order.seller_id,
qc_price,
asset_id,
)?;

Expand Down

0 comments on commit 5871415

Please sign in to comment.