company or personal
This commit is contained in:
@@ -258,6 +258,15 @@ country-pl = Poland
|
||||
country-hu = Hungary
|
||||
checkout-note = Order note
|
||||
checkout-save-profile = Save this address to my profile
|
||||
account-type = Account type
|
||||
account-personal = Individual
|
||||
account-company = Company
|
||||
account-company-details = Company details
|
||||
company-name = Company name
|
||||
company-ico = Company ID (IČO)
|
||||
company-dic = Tax ID (DIČ)
|
||||
company-icdph = VAT ID (IČ DPH)
|
||||
field-optional = optional
|
||||
checkout-place-order = Place order
|
||||
checkout-summary = Order summary
|
||||
profile-title = My profile
|
||||
|
||||
@@ -258,6 +258,15 @@ country-pl = Poľsko
|
||||
country-hu = Maďarsko
|
||||
checkout-note = Poznámka k objednávke
|
||||
checkout-save-profile = Uložiť túto adresu do môjho profilu
|
||||
account-type = Typ účtu
|
||||
account-personal = Súkromná osoba
|
||||
account-company = Firma
|
||||
account-company-details = Firemné údaje
|
||||
company-name = Názov firmy
|
||||
company-ico = IČO
|
||||
company-dic = DIČ
|
||||
company-icdph = IČ DPH
|
||||
field-optional = nepovinné
|
||||
checkout-place-order = Odoslať objednávku
|
||||
checkout-summary = Súhrn objednávky
|
||||
profile-title = Môj profil
|
||||
|
||||
@@ -14,8 +14,47 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<form method="post" action="/account/profile" hx-boost="false" class="mt-6 space-y-6">
|
||||
<!-- account (read-only — managed by the login) -->
|
||||
<form method="post" action="/account/profile" hx-boost="false" class="mt-6 space-y-6"
|
||||
x-data="{ accountType: '{{ account_type | default(value='personal') }}' }">
|
||||
<!-- personal vs company: an account is exactly one of the two -->
|
||||
<fieldset class="space-y-3 rounded-radius border border-outline bg-surface p-6 dark:border-outline-dark dark:bg-surface-dark-alt">
|
||||
<legend class="px-1 text-sm font-semibold text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="account-type", lang=lang | default(value='sk')) }}</legend>
|
||||
<div class="grid gap-3 sm:grid-cols-2">
|
||||
<label class="flex cursor-pointer items-center gap-3 rounded-radius border border-outline px-4 py-3 transition has-[:checked]:border-primary dark:border-outline-dark dark:has-[:checked]:border-primary-dark">
|
||||
{{ ui::radio(name="account_type", value="personal", attrs='x-model="accountType"') }}
|
||||
<span class="font-medium text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="account-personal", lang=lang | default(value='sk')) }}</span>
|
||||
</label>
|
||||
<label class="flex cursor-pointer items-center gap-3 rounded-radius border border-outline px-4 py-3 transition has-[:checked]:border-primary dark:border-outline-dark dark:has-[:checked]:border-primary-dark">
|
||||
{{ ui::radio(name="account_type", value="company", attrs='x-model="accountType"') }}
|
||||
<span class="font-medium text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="account-company", lang=lang | default(value='sk')) }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- company billing details (company accounts only) -->
|
||||
<fieldset x-show="accountType === 'company'" x-cloak class="space-y-4 rounded-radius border border-outline bg-surface p-6 dark:border-outline-dark dark:bg-surface-dark-alt">
|
||||
<legend class="px-1 text-sm font-semibold text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="account-company-details", lang=lang | default(value='sk')) }}</legend>
|
||||
<div class="space-y-1.5">
|
||||
<label for="company_name" class="text-sm font-medium text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="company-name", lang=lang | default(value='sk')) }}</label>
|
||||
{{ ui::input(name="company_name", id="company_name", value=company_name | default(value=''), autocomplete="organization") }}
|
||||
</div>
|
||||
<div class="grid gap-4 sm:grid-cols-3">
|
||||
<div class="space-y-1.5">
|
||||
<label for="company_id" class="text-sm font-medium text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="company-ico", lang=lang | default(value='sk')) }}</label>
|
||||
{{ ui::input(name="company_id", id="company_id", value=company_id | default(value='')) }}
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label for="tax_id" class="text-sm font-medium text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="company-dic", lang=lang | default(value='sk')) }}</label>
|
||||
{{ ui::input(name="tax_id", id="tax_id", value=tax_id | default(value='')) }}
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label for="vat_id" class="text-sm font-medium text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="company-icdph", lang=lang | default(value='sk')) }} <span class="text-on-surface/50 dark:text-on-surface-dark/50">({{ t(key="field-optional", lang=lang | default(value='sk')) }})</span></label>
|
||||
{{ ui::input(name="vat_id", id="vat_id", value=vat_id | default(value='')) }}
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- contact (name/email are managed by the login) -->
|
||||
<fieldset class="space-y-4 rounded-radius border border-outline bg-surface p-6 dark:border-outline-dark dark:bg-surface-dark-alt">
|
||||
<legend class="px-1 text-sm font-semibold text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="checkout-contact", lang=lang | default(value='sk')) }}</legend>
|
||||
<div class="space-y-1.5">
|
||||
|
||||
@@ -52,6 +52,15 @@
|
||||
<p class="text-on-surface/80 dark:text-on-surface-dark/80">{{ order.email }}</p>
|
||||
{% if order.phone %}<p class="text-on-surface/80 dark:text-on-surface-dark/80">{{ order.phone }}</p>{% endif %}
|
||||
</div>
|
||||
{% if order.account_type == "company" %}
|
||||
<div>
|
||||
<p class="text-xs uppercase tracking-wide text-on-surface/60 dark:text-on-surface-dark/60">{{ t(key="account-company-details", lang=lang | default(value='sk')) }}</p>
|
||||
<p class="font-medium text-on-surface-strong dark:text-on-surface-dark-strong">{{ order.company_name }}</p>
|
||||
<p class="text-on-surface/80 dark:text-on-surface-dark/80">{{ t(key="company-ico", lang=lang | default(value='sk')) }}: {{ order.company_id }}</p>
|
||||
<p class="text-on-surface/80 dark:text-on-surface-dark/80">{{ t(key="company-dic", lang=lang | default(value='sk')) }}: {{ order.tax_id }}</p>
|
||||
{% if order.vat_id %}<p class="text-on-surface/80 dark:text-on-surface-dark/80">{{ t(key="company-icdph", lang=lang | default(value='sk')) }}: {{ order.vat_id }}</p>{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div>
|
||||
<p class="text-xs uppercase tracking-wide text-on-surface/60 dark:text-on-surface-dark/60">{{ t(key="checkout-shipping", lang=lang | default(value='sk')) }}</p>
|
||||
<p class="text-on-surface/80 dark:text-on-surface-dark/80">{{ order.address }}<br>{{ order.zip }} {{ order.city }}<br>{{ order.country }}</p>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<form method="post" action="/checkout" hx-boost="false"
|
||||
x-data="{
|
||||
paymentMethod: '',
|
||||
accountType: '{{ prefill_account_type | default(value='personal') }}',
|
||||
carrier: '',
|
||||
carrierPrice: 0,
|
||||
requiresPoint: false,
|
||||
@@ -31,6 +32,44 @@
|
||||
class="mt-6 grid gap-8 lg:grid-cols-3">
|
||||
|
||||
<div class="space-y-6 lg:col-span-2">
|
||||
<!-- personal vs company -->
|
||||
<fieldset class="space-y-3 rounded-radius border border-outline bg-surface p-6 dark:border-outline-dark dark:bg-surface-dark-alt">
|
||||
<legend class="px-1 text-sm font-semibold text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="account-type", lang=lang | default(value='sk')) }}</legend>
|
||||
<div class="grid gap-3 sm:grid-cols-2">
|
||||
<label class="flex cursor-pointer items-center gap-3 rounded-radius border border-outline px-4 py-3 transition has-[:checked]:border-primary dark:border-outline-dark dark:has-[:checked]:border-primary-dark">
|
||||
{{ ui::radio(name="account_type", value="personal", attrs='x-model="accountType"') }}
|
||||
<span class="font-medium text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="account-personal", lang=lang | default(value='sk')) }}</span>
|
||||
</label>
|
||||
<label class="flex cursor-pointer items-center gap-3 rounded-radius border border-outline px-4 py-3 transition has-[:checked]:border-primary dark:border-outline-dark dark:has-[:checked]:border-primary-dark">
|
||||
{{ ui::radio(name="account_type", value="company", attrs='x-model="accountType"') }}
|
||||
<span class="font-medium text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="account-company", lang=lang | default(value='sk')) }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- company billing details (company accounts only) -->
|
||||
<fieldset x-show="accountType === 'company'" x-cloak class="space-y-4 rounded-radius border border-outline bg-surface p-6 dark:border-outline-dark dark:bg-surface-dark-alt">
|
||||
<legend class="px-1 text-sm font-semibold text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="account-company-details", lang=lang | default(value='sk')) }}</legend>
|
||||
<div class="space-y-1.5">
|
||||
<label for="company_name" class="text-sm font-medium text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="company-name", lang=lang | default(value='sk')) }}</label>
|
||||
{{ ui::input(name="company_name", id="company_name", value=prefill_company_name | default(value=''), autocomplete="organization") }}
|
||||
</div>
|
||||
<div class="grid gap-4 sm:grid-cols-3">
|
||||
<div class="space-y-1.5">
|
||||
<label for="company_id" class="text-sm font-medium text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="company-ico", lang=lang | default(value='sk')) }}</label>
|
||||
{{ ui::input(name="company_id", id="company_id", value=prefill_company_id | default(value='')) }}
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label for="tax_id" class="text-sm font-medium text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="company-dic", lang=lang | default(value='sk')) }}</label>
|
||||
{{ ui::input(name="tax_id", id="tax_id", value=prefill_tax_id | default(value='')) }}
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label for="vat_id" class="text-sm font-medium text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="company-icdph", lang=lang | default(value='sk')) }} <span class="text-on-surface/50 dark:text-on-surface-dark/50">({{ t(key="field-optional", lang=lang | default(value='sk')) }})</span></label>
|
||||
{{ ui::input(name="vat_id", id="vat_id", value=prefill_vat_id | default(value='')) }}
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- contact -->
|
||||
<fieldset class="space-y-4 rounded-radius border border-outline bg-surface p-6 dark:border-outline-dark dark:bg-surface-dark-alt">
|
||||
<legend class="px-1 text-sm font-semibold text-on-surface-strong dark:text-on-surface-dark-strong">{{ t(key="checkout-contact", lang=lang | default(value='sk')) }}</legend>
|
||||
|
||||
@@ -32,6 +32,7 @@ mod m20260617_000002_add_shipment_to_orders;
|
||||
mod m20260617_000003_add_phone_to_orders;
|
||||
mod m20260618_000001_o_auth2_sessions;
|
||||
mod m20260618_000002_customer_profiles;
|
||||
mod m20260618_000003_account_type;
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -68,6 +69,7 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20260617_000003_add_phone_to_orders::Migration),
|
||||
Box::new(m20260618_000001_o_auth2_sessions::Migration),
|
||||
Box::new(m20260618_000002_customer_profiles::Migration),
|
||||
Box::new(m20260618_000003_account_type::Migration),
|
||||
// inject-above (do not remove this comment)
|
||||
]
|
||||
}
|
||||
|
||||
39
migration/src/m20260618_000003_account_type.rs
Normal file
39
migration/src/m20260618_000003_account_type.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use loco_rs::schema::*;
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
// Personal vs company purchasing. `account_type` is "personal" or "company";
|
||||
// the company_* columns hold the Slovak invoicing identifiers (IČO, DIČ and the
|
||||
// optional VAT id IČ DPH) and are only filled for company accounts/orders.
|
||||
const COMPANY_COLUMNS: [&str; 4] = ["company_name", "company_id", "tax_id", "vat_id"];
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||
for table in ["customer_profiles", "orders"] {
|
||||
add_column(
|
||||
m,
|
||||
table,
|
||||
"account_type",
|
||||
ColType::StringWithDefault("personal".to_string()),
|
||||
)
|
||||
.await?;
|
||||
for col in COMPANY_COLUMNS {
|
||||
add_column(m, table, col, ColType::StringNull).await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||
for table in ["customer_profiles", "orders"] {
|
||||
remove_column(m, table, "account_type").await?;
|
||||
for col in COMPANY_COLUMNS {
|
||||
remove_column(m, table, col).await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,11 @@ use crate::{
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct ProfileForm {
|
||||
account_type: Option<String>,
|
||||
company_name: Option<String>,
|
||||
company_id: Option<String>,
|
||||
tax_id: Option<String>,
|
||||
vat_id: Option<String>,
|
||||
phone_prefix: Option<String>,
|
||||
phone: Option<String>,
|
||||
address: Option<String>,
|
||||
@@ -28,9 +33,27 @@ fn trimmed(value: Option<&str>) -> Option<String> {
|
||||
value.map(str::trim).filter(|v| !v.is_empty()).map(String::from)
|
||||
}
|
||||
|
||||
/// Normalize an account type to one of the two known values, defaulting to
|
||||
/// "personal" for anything unexpected.
|
||||
pub fn normalize_account_type(value: Option<&str>) -> String {
|
||||
match value.map(str::trim) {
|
||||
Some("company") => "company".to_string(),
|
||||
_ => "personal".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ProfileForm> for ProfileFields {
|
||||
fn from(form: ProfileForm) -> Self {
|
||||
let is_company = normalize_account_type(form.account_type.as_deref()) == "company";
|
||||
// Company identifiers are only stored for company accounts, so switching
|
||||
// back to personal clears stale data.
|
||||
let company = |v: Option<&str>| if is_company { trimmed(v) } else { None };
|
||||
Self {
|
||||
account_type: normalize_account_type(form.account_type.as_deref()),
|
||||
company_name: company(form.company_name.as_deref()),
|
||||
company_id: company(form.company_id.as_deref()),
|
||||
tax_id: company(form.tax_id.as_deref()),
|
||||
vat_id: company(form.vat_id.as_deref()),
|
||||
phone_prefix: trimmed(form.phone_prefix.as_deref()),
|
||||
phone: trimmed(form.phone.as_deref()),
|
||||
address: trimmed(form.address.as_deref()),
|
||||
@@ -61,6 +84,11 @@ fn profile_view(
|
||||
"saved": saved,
|
||||
"name": name,
|
||||
"email": email,
|
||||
"account_type": profile.map_or("personal", |p| p.account_type.as_str()),
|
||||
"company_name": profile.and_then(|p| p.company_name.clone()),
|
||||
"company_id": profile.and_then(|p| p.company_id.clone()),
|
||||
"tax_id": profile.and_then(|p| p.tax_id.clone()),
|
||||
"vat_id": profile.and_then(|p| p.vat_id.clone()),
|
||||
"phone_prefix": profile.and_then(|p| p.phone_prefix.clone()),
|
||||
"phone": profile.and_then(|p| p.phone.clone()),
|
||||
"address": profile.and_then(|p| p.address.clone()),
|
||||
|
||||
@@ -9,6 +9,7 @@ use serde_json::json;
|
||||
use time::Duration as TimeDuration;
|
||||
|
||||
use crate::{
|
||||
controllers::account::normalize_account_type,
|
||||
controllers::cart::{resolve_cart, CART_COOKIE},
|
||||
models::{customer_profiles::{self, ProfileFields}, order_items, orders, shipping_methods},
|
||||
controllers::i18n::current_lang,
|
||||
@@ -24,6 +25,11 @@ struct CheckoutForm {
|
||||
phone_prefix: String,
|
||||
phone: String,
|
||||
customer_name: String,
|
||||
account_type: Option<String>,
|
||||
company_name: Option<String>,
|
||||
company_id: Option<String>,
|
||||
tax_id: Option<String>,
|
||||
vat_id: Option<String>,
|
||||
address: String,
|
||||
city: String,
|
||||
zip: String,
|
||||
@@ -115,6 +121,11 @@ async fn checkout_page(
|
||||
"logged_in_customer": is_customer,
|
||||
"prefill_email": user.as_ref().filter(|_| is_customer).map(|u| u.email.clone()),
|
||||
"prefill_name": user.as_ref().filter(|_| is_customer).map(|u| u.name.clone()),
|
||||
"prefill_account_type": profile.as_ref().map_or("personal", |x| x.account_type.as_str()),
|
||||
"prefill_company_name": p(|x| x.company_name.clone()),
|
||||
"prefill_company_id": p(|x| x.company_id.clone()),
|
||||
"prefill_tax_id": p(|x| x.tax_id.clone()),
|
||||
"prefill_vat_id": p(|x| x.vat_id.clone()),
|
||||
"prefill_phone_prefix": p(|x| x.phone_prefix.clone()),
|
||||
"prefill_phone": p(|x| x.phone.clone()),
|
||||
"prefill_address": p(|x| x.address.clone()),
|
||||
@@ -158,6 +169,20 @@ async fn place_order(
|
||||
let zip = require(&form.zip, "zip")?;
|
||||
let country = require(&form.country, "country")?;
|
||||
|
||||
// Company purchases must carry the invoicing identifiers (IČO + DIČ
|
||||
// required, IČ DPH optional). Personal orders carry none.
|
||||
let account_type = normalize_account_type(form.account_type.as_deref());
|
||||
let (company_name, company_id, tax_id, vat_id) = if account_type == "company" {
|
||||
(
|
||||
Some(require(form.company_name.as_deref().unwrap_or(""), "company name")?),
|
||||
Some(require(form.company_id.as_deref().unwrap_or(""), "IČO")?),
|
||||
Some(require(form.tax_id.as_deref().unwrap_or(""), "DIČ")?),
|
||||
form.vat_id.as_deref().and_then(trimmed),
|
||||
)
|
||||
} else {
|
||||
(None, None, None, None)
|
||||
};
|
||||
|
||||
if !PAYMENT_METHODS.contains(&form.payment_method.as_str()) {
|
||||
return Err(Error::BadRequest("invalid payment method".to_string()));
|
||||
}
|
||||
@@ -190,6 +215,11 @@ async fn place_order(
|
||||
if let Some(user) = guard::current_user(&ctx, &jar).await {
|
||||
if !guard::is_admin(&ctx, &user) {
|
||||
let fields = ProfileFields {
|
||||
account_type: account_type.clone(),
|
||||
company_name: company_name.clone(),
|
||||
company_id: company_id.clone(),
|
||||
tax_id: tax_id.clone(),
|
||||
vat_id: vat_id.clone(),
|
||||
phone_prefix: trimmed(&form.phone_prefix),
|
||||
phone: Some(number.clone()),
|
||||
address: Some(address.clone()),
|
||||
@@ -211,6 +241,11 @@ async fn place_order(
|
||||
email,
|
||||
phone,
|
||||
customer_name: Some(customer_name),
|
||||
account_type,
|
||||
company_name,
|
||||
company_id,
|
||||
tax_id,
|
||||
vat_id,
|
||||
address: Some(address),
|
||||
city: Some(city),
|
||||
zip: Some(zip),
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -30,6 +30,11 @@ pub fn detail(order: &orders::Model, bank_iban: &str, bank_account_name: &str) -
|
||||
"email": order.email,
|
||||
"phone": order.phone,
|
||||
"customer_name": order.customer_name,
|
||||
"account_type": order.account_type,
|
||||
"company_name": order.company_name,
|
||||
"company_id": order.company_id,
|
||||
"tax_id": order.tax_id,
|
||||
"vat_id": order.vat_id,
|
||||
"status": order.status,
|
||||
"subtotal": format_price(order.total_cents - order.shipping_cents),
|
||||
"shipping": format_price(order.shipping_cents),
|
||||
|
||||
Reference in New Issue
Block a user