Add customs fields to admin UI

main
Ashelyn Dawn 3 years ago
parent f932fb6e4c
commit 779642a4c3

@ -41,7 +41,11 @@ router.post('/', parseJSON, itemValidators, async (req, res) => {
req.body.urlslug,
req.body.description,
req.body.price_cents,
req.body.published
req.body.published,
req.body.hs_tariff_number,
req.body.customs_description,
req.body.origin_country,
req.body.weight
)
res.json(item)

@ -227,7 +227,7 @@ router.post('/:uuid/ship/easypost', ensureAdmin, parseJSON, async (req, res) =>
)
const user = await db.order.getUser(order.uuid)
await email.sendShippingNotification(user, order)
await email.sendShippingNotification(user, updatedOrder)
res.json(updatedOrder)
})

@ -52,23 +52,23 @@ item.findBySlug = async (item_slug) => {
return joinjs.map(rows, mappings, 'itemMap', 'item_')[0];
}
item.create = async (name, urlslug, description, price_cents, published) => {
const query = {
text: 'select * from sos.create_item($1::text, $2::citext, $3::text, $4::integer, $5::boolean)',
values: [
item.create = async (name, urlslug, description, price_cents, published, hs_tariff_number, customs_description, origin_country, weight) =>
dbUtil.executeFunction({
name: 'create_item',
params: [
name,
urlslug,
description,
price_cents,
published
]
}
debug(query)
const {rows} = await pg.query(query)
return joinjs.map(rows, mappings, 'itemMap', 'item_')[0]
}
published,
hs_tariff_number,
customs_description,
origin_country,
weight
],
returnType: 'item',
single: true
})
item.update = async (uuid, name, urlslug, description, price_cents, published) => {
const query = {

@ -97,7 +97,7 @@ begin
return query select * from sos.validate_session(_session_uuid);
end; $function$;
create or replace function sos.create_item(_name text, _urlslug citext, _description text, _price_cents integer, _published boolean)
create or replace function sos.create_item(_name text, _urlslug citext, _description text, _price_cents integer, _published boolean, _hs_num text, _customs_desc text, _origin_country text, _weight integer)
returns setof sos.v_item
language plpgsql
as $function$
@ -109,13 +109,21 @@ begin
item_urlslug,
item_description,
item_price_cents,
item_published
item_published,
item_hs_tariff_number,
item_customs_description,
item_customs_origin_country,
item_weight_oz
) values (
_name,
_urlslug,
_description,
_price_cents,
_published
_published,
_hs_num,
_customs_desc,
_origin_country,
_weight
) returning item_uuid into _item_uuid;
return query select * from sos.v_item where item_uuid = _item_uuid;

@ -21,11 +21,19 @@ export default function NewItem() {
<>
<ActionBar title="Create New Item"/>
<FormController url="/api/items" afterSubmit={afterCreate}>
<h3>General Fields</h3>
<Input name="name" validate={stringLengthAtLeastOne} />
<TextArea name="description" validate={stringLengthAtLeastOne} />
<Input label="URL Slug" name="urlslug" validate={slugRestrictions} />
<DecimalInput label="Price" name="price_cents" prefix="$" numDecimals={2} transform={float => Math.floor(float * 100)} />
<Checkbox label="Published" name="published" hint="Publish this item" />
<h3>Customs Info</h3>
<Input name="hs_tariff_number" label="Tariff Number" validate={stringLengthAtLeastOne} hint="Please see https://hts.usitc.gov/current. Sock is 611595"/>
<Input name="customs_description" label="Customs Description" validate={stringLengthAtLeastOne} hint={"Short description like \"t-shirt\""}/>
<Input name="origin_country" label="Country of Origin" validate={s => s.length === 2} hint="2 letter ISO country code"/>
<DecimalInput label="Weight (ounces)" name="weight" hint="Please enter (in ounces) the weight of this item" prefix="" numDecimals={2} validate={val => val > 0} />
<p><strong>Note:</strong> You can add images to an item after creating it</p>
<Button type="submit">Create</Button>
</FormController>

@ -32,7 +32,7 @@ export default function CheckoutSummary({order: _order, addresses}){
const {item_total_price, shipping_price, tax_price, coupon_effective_discount} = currentTransaction
const {free_shipping} = currentTransaction.coupon || {}
const total_price =
(item_total_price && shipping_price && tax_price)
(item_total_price && shipping_price)
? item_total_price + (free_shipping ? 0 : shipping_price) + tax_price - (coupon_effective_discount || 0)
: null

Loading…
Cancel
Save