Configurable shipping from address

main
Ashelyn Dawn 4 years ago
parent 88b724134f
commit dab9c228ad

@ -7,5 +7,6 @@ module.exports = [{
],
associations: [
{name: 'modified_by', mapId: 'userMap', columnPrefix: 'user_'},
{name: 'shipping_from', mapId: 'addressMap', columnPrefix: 'address_'}
]
}]

@ -19,6 +19,7 @@ address.create = async (name, street1, street2, city, state, zip, country) => {
const {success} = epAddress.verifications.delivery
if (!success) {
// TODO: Send back an error?
console.error(`Could not verify address: ${epAddress.id}`)
}
const query = {

@ -283,17 +283,15 @@ order.setDelivery = (uuid, description, deliveryDate) =>
order.shipEasyPost = async ( uuid, length, width, height, weight ) => {
// Retrieve address
const {address} = await order.findByUUID(uuid)
const {shipping_from} = await config.getLatestConfig()
if(!shipping_from?.easypost_id)
throw new Error("Cannot ship - no from address set in config")
// Create shipment
const epShipment = new easypost.Shipment({
to_address: address.easypost_id,
from_address: {
street1: '11381 N. Sampson Drive',
city: 'Highland',
state: 'UT',
zip: '84003',
country: 'US'
},
from_address: shipping_from.easypost_id,
parcel: {length, width, height, weight}
})

@ -272,7 +272,8 @@ create table sos."config" (
config_uuid uuid primary key default uuid_generate_v4(),
config_date_updated timestamptz not null default now(),
config_updated_by uuid references sos."user" (user_uuid),
config_default_tax_percent numeric(8,6) not null default 7.250
config_default_tax_percent numeric(8,6) not null default 7.250,
config_shipping_from uuid references sos."address" (address_uuid)
);
insert into sos."config" default values;

@ -147,6 +147,7 @@ create or replace view sos.v_order as
create or replace view sos.v_config as
select * from sos."config"
left join sos."user" on config_updated_by = user_uuid
left join sos."address" on config_shipping_from = address_uuid
where config_date_updated = (select max(config_date_updated) from sos."config");
create or replace view sos.v_stockchange as

Loading…
Cancel
Save