company or personal
This commit is contained in:
@@ -13,6 +13,11 @@ pub struct Model {
|
||||
pub id: i32,
|
||||
#[sea_orm(unique)]
|
||||
pub user_id: i32,
|
||||
pub account_type: String,
|
||||
pub company_name: Option<String>,
|
||||
pub company_id: Option<String>,
|
||||
pub tax_id: Option<String>,
|
||||
pub vat_id: Option<String>,
|
||||
pub phone_prefix: Option<String>,
|
||||
pub phone: Option<String>,
|
||||
pub address: Option<String>,
|
||||
|
||||
@@ -18,6 +18,11 @@ pub struct Model {
|
||||
pub status: String,
|
||||
pub total_cents: i64,
|
||||
pub currency: String,
|
||||
pub account_type: String,
|
||||
pub company_name: Option<String>,
|
||||
pub company_id: Option<String>,
|
||||
pub tax_id: Option<String>,
|
||||
pub vat_id: Option<String>,
|
||||
pub address: Option<String>,
|
||||
pub city: Option<String>,
|
||||
pub zip: Option<String>,
|
||||
|
||||
@@ -9,9 +9,15 @@ use sea_orm::{ActiveValue, IntoActiveModel, QueryFilter, TryIntoModel};
|
||||
pub type CustomerProfiles = Entity;
|
||||
|
||||
/// The editable profile fields, shared by the profile page and the checkout
|
||||
/// "save my address" path.
|
||||
/// "save my address" path. `account_type` is "personal" or "company"; the
|
||||
/// `company_*` fields are only meaningful for company accounts.
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct ProfileFields {
|
||||
pub account_type: String,
|
||||
pub company_name: Option<String>,
|
||||
pub company_id: Option<String>,
|
||||
pub tax_id: Option<String>,
|
||||
pub vat_id: Option<String>,
|
||||
pub phone_prefix: Option<String>,
|
||||
pub phone: Option<String>,
|
||||
pub address: Option<String>,
|
||||
@@ -53,6 +59,11 @@ impl Model {
|
||||
..Default::default()
|
||||
},
|
||||
};
|
||||
active.account_type = ActiveValue::set(fields.account_type);
|
||||
active.company_name = ActiveValue::set(fields.company_name);
|
||||
active.company_id = ActiveValue::set(fields.company_id);
|
||||
active.tax_id = ActiveValue::set(fields.tax_id);
|
||||
active.vat_id = ActiveValue::set(fields.vat_id);
|
||||
active.phone_prefix = ActiveValue::set(fields.phone_prefix);
|
||||
active.phone = ActiveValue::set(fields.phone);
|
||||
active.address = ActiveValue::set(fields.address);
|
||||
|
||||
@@ -14,6 +14,11 @@ pub struct Checkout {
|
||||
pub email: String,
|
||||
pub phone: String,
|
||||
pub customer_name: Option<String>,
|
||||
pub account_type: String,
|
||||
pub company_name: Option<String>,
|
||||
pub company_id: Option<String>,
|
||||
pub tax_id: Option<String>,
|
||||
pub vat_id: Option<String>,
|
||||
pub address: Option<String>,
|
||||
pub city: Option<String>,
|
||||
pub zip: Option<String>,
|
||||
@@ -70,6 +75,11 @@ pub async fn place(ctx: &AppContext, items: &[(i32, i32)], details: Checkout) ->
|
||||
status: Set("pending".to_string()),
|
||||
total_cents: Set(subtotal + details.method.price_cents),
|
||||
currency: Set(currency),
|
||||
account_type: Set(details.account_type),
|
||||
company_name: Set(details.company_name),
|
||||
company_id: Set(details.company_id),
|
||||
tax_id: Set(details.tax_id),
|
||||
vat_id: Set(details.vat_id),
|
||||
address: Set(details.address),
|
||||
city: Set(details.city),
|
||||
zip: Set(details.zip),
|
||||
|
||||
Reference in New Issue
Block a user