Compare commits

..

1 Commits

Author SHA1 Message Date
Rachel Arnould
b5020cc740 Update en.yml
Removing mentions about UFC Que choisir and changing the link
2024-11-25 13:31:36 +01:00
24 changed files with 78 additions and 187 deletions

View File

@@ -86,7 +86,7 @@ gem "active_model_serializers", "0.8.4"
gem 'activerecord-session_store'
gem 'acts-as-taggable-on'
gem 'angularjs-file-upload-rails', '~> 2.4.1'
gem 'bigdecimal'
gem 'bigdecimal', '3.0.2'
gem 'bootsnap', require: false
gem 'geocoder'
gem 'gmaps4rails'

View File

@@ -180,7 +180,7 @@ GEM
base64 (0.2.0)
bcp47_spec (0.2.1)
bcrypt (3.1.20)
bigdecimal (3.1.8)
bigdecimal (3.0.2)
bindata (2.5.0)
bindex (0.8.1)
bootsnap (1.18.3)
@@ -865,7 +865,7 @@ DEPENDENCIES
angularjs-rails (= 1.8.0)
arel-helpers (~> 2.12)
aws-sdk-s3
bigdecimal
bigdecimal (= 3.0.2)
bootsnap
bugsnag
bullet

View File

@@ -20,13 +20,10 @@ angular.module('Darkswarm').directive 'mapSearch', ($timeout, Search) ->
$timeout =>
map = ctrl.getMap()
if !map
alert(t('gmap_load_failure'))
else
searchBox = scope.createSearchBox map
scope.bindSearchResponse map, searchBox
scope.biasResults map, searchBox
scope.performUrlSearch map
searchBox = scope.createSearchBox map
scope.bindSearchResponse map, searchBox
scope.biasResults map, searchBox
scope.performUrlSearch map
scope.createSearchBox = (map) ->
map.controls[google.maps.ControlPosition.TOP_LEFT].push scope.input

View File

@@ -161,7 +161,7 @@ module ProductImport
end
def unit_fields_validation(entry)
unit_types = ['mg', 'g', 'kg', 'oz', 'lb', 't', 'ml', 'cl', 'dl', 'l', 'kl', 'gal', '']
unit_types = ['g', 'oz', 'lb', 'kg', 't', 'ml', 'l', 'kl', '']
if entry.units.blank?
mark_as_invalid(entry, attribute: 'units',
@@ -297,7 +297,7 @@ module ProductImport
unscaled_units = entry.unscaled_units.to_f || 0
entry.unit_value = unscaled_units * unit_scale unless unit_scale.nil?
if entry.match_variant?(existing_variant)
if entry.match_inventory_variant?(existing_variant)
variant_override = create_inventory_item(entry, existing_variant)
return validate_inventory_item(entry, variant_override)
end

View File

@@ -85,6 +85,10 @@ module ProductImport
end
def match_variant?(variant)
match_display_name?(variant) && variant.unit_value.to_d == unscaled_units.to_d
end
def match_inventory_variant?(variant)
match_display_name?(variant) && variant.unit_value.to_d == unit_value.to_d
end

View File

@@ -32,18 +32,14 @@ module ProductImport
def unit_scales
{
'mg' => { scale: 0.001, unit: 'weight' },
'g' => { scale: 1, unit: 'weight' },
'kg' => { scale: 1000, unit: 'weight' },
'oz' => { scale: 28.35, unit: 'weight' },
'lb' => { scale: 453.6, unit: 'weight' },
't' => { scale: 1_000_000, unit: 'weight' },
'ml' => { scale: 0.001, unit: 'volume' },
'cl' => { scale: 0.01, unit: 'volume' },
'dl' => { scale: 0.1, unit: 'volume' },
'l' => { scale: 1, unit: 'volume' },
'kl' => { scale: 1000, unit: 'volume' },
'gal' => { scale: 4.54609, unit: 'volume' },
'kl' => { scale: 1000, unit: 'volume' }
}
end

View File

@@ -58,7 +58,7 @@ module VariantUnits
def option_value_value_unit_scaled
unit_scale, unit_name = scale_for_unit_value
value = (@nameable.unit_value.to_d / unit_scale).round(2)
value = (@nameable.unit_value / unit_scale).to_d.truncate(2)
[value, unit_name]
end

View File

@@ -12,7 +12,7 @@
= f.hidden_field :variant_unit_scale
= f.select :variant_unit_with_scale,
options_for_select(WeightsAndMeasures.variant_unit_options, variant.variant_unit_with_scale),
{ include_blank: t('.select_unit_scale') },
{ include_blank: true },
{ class: "fullwidth no-input", 'aria-label': t('admin.products_page.columns.unit_scale'), data: { "controller": "tom-select", "tom-select-options-value": '{ "plugins": [] }', action: "change->toggle-control#displayIfMatch" }, required: true }
= error_message_on variant, :variant_unit, 'data-toggle-control-target': 'control'
.field

View File

@@ -10,8 +10,7 @@ export default class extends Controller {
changePage(event) {
const productsForm = document.querySelector("#products-form");
if (productsForm) productsForm.scrollIntoView({ behavior: "smooth" });
productsForm.scrollIntoView({ behavior: "smooth" });
this.page.value = event.target.dataset.page;
this.submitSearch();
this.page.value = 1;

View File

@@ -973,7 +973,6 @@ en:
category_field_name: "Category"
tax_category_field_name: "Tax Category"
producer_field_name: "Producer"
select_unit_scale: Select unit scale
clone:
success: Successfully cloned the product
error: Unable to clone the product
@@ -1413,7 +1412,7 @@ en:
connected_apps:
legend: "Connected apps"
affiliate_sales_data:
title: "INRAE / UFC QUE CHOISIR Research"
title: "INRAE Research"
tagline: "Allow this research project to access your orders data anonymously"
enable: "Allow data sharing"
disable: "Stop sharing"
@@ -1421,10 +1420,10 @@ en:
need_to_be_manager: "Only managers can connect apps."
description_html: |
<p>
INRAE and UFC QUE CHOISIR are teaming up to study food prices in short food systems and compare them with prices in the supermarket, for a given set of products. The data that is used by INRAE is mixed with data coming from other short food chain platforms in France. No individual product prices will be publicly disclosed through this project.
INRAE are studiying food prices in short food systems and compare them with prices in the supermarket, for a given set of products. The data that is used by INRAE is mixed with data coming from other short food chain platforms in France. No individual product prices will be publicly disclosed through this project.
</p>
<p>
<a href="https://apropos.coopcircuits.fr/"
<a href="https://pepr-sams.fr/2024/03/12/plat4terfood/"
target="_blank"><b>Learn more about this research project</b>
<i class="icon-external-link"></i></a>
</p>
@@ -2788,7 +2787,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using
confirm_hub_change: "Are you sure? This will change your selected hub and remove any items in your shopping cart."
confirm_oc_change: "Are you sure? This will change your selected order cycle and remove any items in your shopping cart."
location_placeholder: "Type in a location..."
gmap_load_failure: "Unable to load map. Please check your browser settings and allow 3rd party cookies for this website."
error_required: "can't be blank"
error_number: "must be number"
error_email: "must be email address"

View File

@@ -107,9 +107,6 @@ en_CA:
count_on_hand:
using_producer_stock_settings_but_count_on_hand_set: "must be blank because you are using producer stock settings"
limited_stock_but_no_count_on_hand: "must be specified because you are forcing limited stock"
connected_apps:
vine:
api_request_error: "An error occured when connecting to Vine API"
messages:
confirmation: "doesn't match %{attribute}"
blank: "can't be blank"
@@ -720,7 +717,6 @@ en_CA:
connected_apps_enabled:
discover_regen: Discover Regenerative portal
affiliate_sales_data: DFC anonymised orders API for research purposes
vine: Voucher Integration Engine (VINE)
update:
resource: Connected app settings
customers:
@@ -1377,25 +1373,9 @@ en_CA:
<i class="icon-external-link"></i></a>
</p>
vine:
title: "Voucher Integration Engine (VINE)"
tagline: "Allow redemption of VINE vouchers in your shopfront."
enable: "Donate"
disable: "Disconnect"
need_to_be_manager: "Only managers can connect apps."
vine_api_key: "VINE API Key"
vine_secret: "VINE secret"
description_html: |
<p>
To enable VINE for your enterprise, enter your API key and secret.
</p>
<p>
<a href="#" target="_blank"><b>VINE</b>
<i class="icon-external-link"></i></a>
</p>
api_parameters_empty: "Please enter an API key and a secret"
api_parameters_error: "Check you entered your API key and secret correctly, contact your instance manager if the error persists"
connection_error: "API connection error, please try again"
setup_error: "VINE API is not configured, please contact your instance manager"
actions:
edit_profile: Settings
properties: Properties
@@ -1692,7 +1672,6 @@ en_CA:
pack_by_customer: Pack By Customer
pack_by_supplier: Pack By Supplier
pack_by_product: Pack By Product
pay_your_suppliers: Pay your suppliers
display:
report_is_big: "This report is big and may slow down your device."
display_anyway: "Display anyway"
@@ -1738,8 +1717,6 @@ en_CA:
enterprise_fee_summary:
name: "Enterprise Fee Summary"
description: "Summary of Enterprise Fees collected"
suppliers:
name: Suppliers
enterprise_fees_with_tax_report_by_order: "Enterprise Fees With Tax Report By Order"
enterprise_fees_with_tax_report_by_producer: "Enterprise Fees With Tax Report By Producer"
errors:
@@ -3026,8 +3003,6 @@ en_CA:
report_render_options: Rendering Options
report_header_ofn_uid: OFN UID
report_header_order_cycle: Order Cycle
report_header_order_cycle_start_date: OC Start Date
report_header_order_cycle_end_date: OC End Date
report_header_user: User
report_header_email: Email
report_header_status: Status
@@ -3048,7 +3023,6 @@ en_CA:
report_header_hub_legal_name: "Hub Legal Name"
report_header_hub_contact_name: "Hub Contact Name"
report_header_hub_email: "Hub Public Email"
report_header_hub_contact_email: Hub Contact Email
report_header_hub_owner_email: Hub Owner Email
report_header_hub_phone: "Hub Phone Number"
report_header_hub_address_line1: "Hub Address Line 1"
@@ -3121,8 +3095,6 @@ en_CA:
report_header_producer_suburb: Producer City/Town
report_header_producer_tax_status: Producer Tax Status
report_header_producer_charges_sales_tax?: Tax registered
report_header_producer_abn_acn: Producer ABN/ACN
report_header_producer_address: Producer Address
report_header_unit: Unit
report_header_group_buy_unit_quantity: Group Buy Unit Quantity
report_header_cost: Cost
@@ -3183,11 +3155,7 @@ en_CA:
report_header_total_units: Total Units
report_header_sum_max_total: "Sum Max Total"
report_header_total_excl_vat: "Total excl. tax (%{currency_symbol})"
report_header_total_fees_excl_tax: "Total fees excl. tax (%{currency_symbol})"
report_header_total_tax_on_fees: "Total tax on fees (%{currency_symbol})"
report_header_total: "Total (%{currency_symbol})"
report_header_total_incl_vat: "Total incl. tax (%{currency_symbol})"
report_header_total_excl_fees_and_tax: "Total excl. fees and tax (%{currency_symbol})"
report_header_temp_controlled: TempControlled?
report_header_is_producer: Producer?
report_header_not_confirmed: Not Confirmed

View File

@@ -1341,7 +1341,7 @@ en_FR:
connected_apps:
legend: "Connected apps"
affiliate_sales_data:
title: "INRAE Research"
title: "INRAE / UFC QUE CHOISIR Research"
tagline: "Allow this research project to access your orders data anonymously"
enable: "Allow data sharing"
disable: "Stop sharing"
@@ -1349,7 +1349,7 @@ en_FR:
need_to_be_manager: "Only managers can connect apps."
description_html: |
<p>
INRAE are teaming up to study food prices in short food systems and compare them with prices in the supermarket, for a given set of products. The data that is used by INRAE is mixed with data coming from other short food chain platforms in France. No individual product prices will be publicly disclosed through this project.
INRAE and UFC QUE CHOISIR are teaming up to study food prices in short food systems and compare them with prices in the supermarket, for a given set of products. The data that is used by INRAE is mixed with data coming from other short food chain platforms in France. No individual product prices will be publicly disclosed through this project.
</p>
<p>
<a href="https://apropos.coopcircuits.fr/"
@@ -1382,7 +1382,7 @@ en_FR:
vine:
title: "Voucher Integration Engine (VINE)"
tagline: "Allow redemption of VINE vouchers in your shopfront."
enable: "Connect"
enable: "About"
disable: "Disconnect"
need_to_be_manager: "Only managers can connect apps."
vine_api_key: "VINE API Key"

View File

@@ -718,7 +718,7 @@ fr:
enabled_legend: "Applications connectées autorisées"
connected_apps_enabled:
discover_regen: Portail Discover Regenerative
affiliate_sales_data: API DFC de commandes anonymisées à fins de recherche
affiliate_sales_data: API de commandes anonymisées DFC à fins de recherche
vine: Éditeur de bons de réduction (VINE)
update:
resource: Paramètres de l'application connectée
@@ -1343,7 +1343,7 @@ fr:
connected_apps:
legend: "Applications connectées"
affiliate_sales_data:
title: "Programme de recherche INRAE"
title: "Programme de recherche INRAE / UFC QUE CHOISIR"
tagline: "Autoriser ce programme de recherche à accéder à vos données de commandes anonymisées"
enable: "Autoriser le partage de données"
disable: "Arrêter le partage"
@@ -1351,7 +1351,7 @@ fr:
need_to_be_manager: "Seuls les gestionnaires peuvent connecter des applications."
description_html: |
<p>
L'INRAE travaille sur les prix des produits distribués en circuit court, comparés aux prix des mêmes produits vendus en supermarché, pour un échantillon de produits. Les données utilisées dans le cadre de ce programme de recherche sont une agrégation des données fournies par plusieurs plateformes de vente en circuit court en France. Aucun prix de produit d'une boutique en particulier ne sera transmis publiquement à travers ce programme.
L'INRAE et UFC QUE CHOISIR travaillent conjointement sur les prix des produits distribués en circuit court, comparés aux prix des mêmes produits vendus en supermarché, pour un échantillon de produits. Les données utilisées dans le cadre de ce programme de recherche sont une agrégation des données fournies par plusieurs plateformes de vente en circuit court en France. Aucun prix de produit d'une boutique en particulier ne sera transmis publiquement à travers ce programme.
</p>
<p>
<a href="https://apropos.coopcircuits.fr/"

View File

@@ -107,9 +107,6 @@ fr_CA:
count_on_hand:
using_producer_stock_settings_but_count_on_hand_set: "doit être vide car utilise les informations de stock du producteur"
limited_stock_but_no_count_on_hand: "doit être spécifié car pas \"à volonté\""
connected_apps:
vine:
api_request_error: "Une erreur s'est produite lors de la connexion à l'API VINE"
messages:
confirmation: "ne correspond pas %{attribute}"
blank: "Champ obligatoire"
@@ -720,7 +717,6 @@ fr_CA:
connected_apps_enabled:
discover_regen: Portail Discover Regenerative
affiliate_sales_data: API de commandes anonymisées DFC à fins de recherche
vine: Éditeur de bons de réduction (VINE)
update:
resource: Paramètres de l'application connectée
customers:
@@ -1380,25 +1376,9 @@ fr_CA:
<i class="icon-external-link"></i></a>
</p>
vine:
title: "Éditeur de bons de réduction (VINE)"
tagline: "Autoriser l'utilisation de bons de réduction VINE dans votre boutique"
enable: "Se connecter"
disable: "Déconnecter"
need_to_be_manager: "Seuls les gestionnaires peuvent connecter des applications."
vine_api_key: "clé API VINE"
vine_secret: "VINE secret"
description_html: |
<p>
Pour mettre en place l'éditeur de bons de réduction VINE pour votre entreprise, entrer votre clé API et secret.
</p>
<p>
<a href="#" target="_blank"><b>VINE</b>
<i class="icon-external-link"></i></a>
</p>
api_parameters_empty: "Entrer une clé API et un secret"
api_parameters_error: "Vérifiez que vous avez entré la clé API et le secret correctement. Contactez l'équipe support de la plateforme si l'erreur persiste. "
connection_error: "Erreur de connexion à l'API. Merci de réessayer."
setup_error: "L'API VINE n'est pas configurée. Veuillez contacter l'équipe support de la plateforme."
actions:
edit_profile: Paramètres
properties: Labels / propriétés
@@ -1695,7 +1675,6 @@ fr_CA:
pack_by_customer: Préparation des commandes par Acheteur
pack_by_supplier: Préparation des commandes par Producteur
pack_by_product: Préparation des commandes par Produit
pay_your_suppliers: Payer vos fournisseurs
display:
report_is_big: "Ce rapport est volumineux et risque de ralentir l'appareil sur lequel vous êtes en train de le consulter."
display_anyway: "Afficher quand même"
@@ -1743,8 +1722,6 @@ fr_CA:
enterprise_fee_summary:
name: "Résumé des marges et commissions"
description: "Résumé des marges et commissions collectées"
suppliers:
name: Fournisseurs
enterprise_fees_with_tax_report_by_order: "Détail des montants de taxe par commande"
enterprise_fees_with_tax_report_by_producer: "Détail des montants de taxe par producteur"
errors:
@@ -3032,8 +3009,6 @@ fr_CA:
report_render_options: Mise en forme
report_header_ofn_uid: ID OFN
report_header_order_cycle: Cycle de Vente
report_header_order_cycle_start_date: Date d'ouverture du cycle de vente
report_header_order_cycle_end_date: Date de fermeture du cycle de vente
report_header_user: Utilisateur
report_header_email: Email
report_header_status: Statut
@@ -3054,7 +3029,6 @@ fr_CA:
report_header_hub_legal_name: "Raison sociale"
report_header_hub_contact_name: "Nom du contact"
report_header_hub_email: "Email public"
report_header_hub_contact_email: e-mail de contact de la boutique multi-producteurs
report_header_hub_owner_email: Email gestionnaire principal
report_header_hub_phone: "Numéro de téléphone"
report_header_hub_address_line1: "Adresse ligne 1"
@@ -3127,8 +3101,6 @@ fr_CA:
report_header_producer_suburb: Ville Producteur
report_header_producer_tax_status: Soumis à la taxe
report_header_producer_charges_sales_tax?: Soumis à la GST
report_header_producer_abn_acn: Numéro de SIRET/SIREN du producteur
report_header_producer_address: Adresse du producteur
report_header_unit: Unité
report_header_group_buy_unit_quantity: Nb d'unités achetées (vente par lots)
report_header_cost: Coût
@@ -3189,11 +3161,7 @@ fr_CA:
report_header_total_units: Vol. total
report_header_sum_max_total: "Somme Max Total"
report_header_total_excl_vat: "Total HT (%{currency_symbol})"
report_header_total_fees_excl_tax: "Total commission boutique hors taxe (%{currency_symbol})"
report_header_total_tax_on_fees: "Total taxe sur la commission boutique (%{currency_symbol})"
report_header_total: "Total (%{currency_symbol})"
report_header_total_incl_vat: "Total TTC (%{currency_symbol})"
report_header_total_excl_fees_and_tax: "Total hors commission boutique et taxe (%{currency_symbol})"
report_header_temp_controlled: Temp Contrôlée ?
report_header_is_producer: Producteur ?
report_header_not_confirmed: Non confirmé

View File

@@ -12,10 +12,7 @@ class AffiliateSalesDataRowBuilder < DfcBuilder
def build_supplier
DataFoodConsortium::Connector::Enterprise.new(
nil,
localizations: [build_address(
item[:supplier_postcode],
item[:supplier_country]
)],
localizations: [build_address(item[:supplier_postcode])],
suppliedProducts: [build_product],
)
end
@@ -23,10 +20,7 @@ class AffiliateSalesDataRowBuilder < DfcBuilder
def build_distributor
DataFoodConsortium::Connector::Enterprise.new(
nil,
localizations: [build_address(
item[:distributor_postcode],
item[:distributor_country]
)],
localizations: [build_address(item[:distributor_postcode])],
)
end
@@ -95,10 +89,9 @@ class AffiliateSalesDataRowBuilder < DfcBuilder
)
end
def build_address(postcode, country)
def build_address(postcode)
DataFoodConsortium::Connector::Address.new(
nil,
country:,
postalCode: postcode,
)
end

View File

@@ -38,11 +38,9 @@ class AffiliateSalesQuery
JOIN spree_products ON spree_products.id = spree_variants.product_id
JOIN enterprises AS suppliers ON suppliers.id = spree_variants.supplier_id
JOIN spree_addresses AS supplier_addresses ON supplier_addresses.id = suppliers.address_id
JOIN spree_countries AS supplier_countries ON supplier_countries.id = supplier_addresses.country_id
JOIN spree_orders ON spree_orders.id = spree_line_items.order_id
JOIN enterprises AS distributors ON distributors.id = spree_orders.distributor_id
JOIN spree_addresses AS distributor_addresses ON distributor_addresses.id = distributors.address_id
JOIN spree_countries AS distributor_countries ON distributor_countries.id = distributor_addresses.country_id
SQL
end
@@ -55,9 +53,7 @@ class AffiliateSalesQuery
spree_variants.unit_presentation,
spree_line_items.price,
distributor_addresses.zipcode AS distributor_postcode,
distributor_countries.name AS distributor_country,
supplier_addresses.zipcode AS supplier_postcode,
supplier_countries.name AS supplier_country,
SUM(spree_line_items.quantity) AS quantity_sold
SQL
@@ -72,9 +68,7 @@ class AffiliateSalesQuery
spree_variants.unit_presentation,
spree_line_items.price,
distributor_postcode,
supplier_postcode,
distributor_country,
supplier_country
supplier_postcode
SQL
end
@@ -88,9 +82,7 @@ class AffiliateSalesQuery
unit_presentation
price
distributor_postcode
distributor_country
supplier_postcode
supplier_country
quantity_sold
]
end

View File

@@ -53,15 +53,9 @@ RSpec.describe AffiliateSalesQuery do
it "converts an array to a hash" do
row = [
"Apples",
"item",
"item",
nil,
nil,
"item", "item", nil, nil,
15.50,
"3210",
"country1",
"3211",
"country2",
"3210", "3211",
3,
]
expect(query.label_row(row)).to eq(
@@ -73,9 +67,7 @@ RSpec.describe AffiliateSalesQuery do
unit_presentation: nil,
price: 15.50,
distributor_postcode: "3210",
distributor_country: "country1",
supplier_postcode: "3211",
supplier_country: "country2",
quantity_sold: 3,
}
)

View File

@@ -46,14 +46,10 @@ namespace :ofn do
unconfirmed_email = concat(id, '_ofn_user@example.com')")
Customer.where(user_id: nil)
.update_all("email = concat(id, '_ofn_customer@example.com'),
name = concat('Customer Number ', id, ' (without connected User)'),
first_name = concat('Customer Number ', id),
last_name = '(without connected User)'")
name = concat('Customer Number ', id, ' (without connected User)')")
Customer.where.not(user_id: nil)
.update_all("email = concat(user_id, '_ofn_user@example.com'),
name = concat('Customer Number ', id, ' - User ', user_id),
first_name = concat('Customer Number ', id),
last_name = concat('User ', user_id)")
name = concat('Customer Number ', id, ' - User ', user_id)")
Spree::Order.update_all("email = concat(id, '_ofn_order@example.com')")
end

View File

@@ -145,8 +145,7 @@ RSpec.describe "Reporting::Reports::SalesTax::SalesTaxTotalsByOrder" do
total = report.total_excl_tax(query_row)
# discounted order total - discounted order tax
# (113.3 - 10) - (3.3 - 0.29)
expect(total).to eq 100.29
expect(total).to eq((113.3 - 10) - (3.3 - 0.29))
end
end
end

View File

@@ -20,15 +20,16 @@ RSpec.describe ProductImport::SpreadsheetEntry do
}
let(:display_name) { "" }
# TODO test match on display_name
describe "#match_variant?" do
it "returns true if matching" do
variant = create(:variant, unit_value: 500_000)
variant = create(:variant, unit_value: 500)
expect(entry.match_variant?(variant)).to be(true)
end
it "returns false if not machting" do
variant = create(:variant, unit_value: 500)
variant = create(:variant, unit_value: 250)
expect(entry.match_variant?(variant)).to be(false)
end
@@ -37,7 +38,7 @@ RSpec.describe ProductImport::SpreadsheetEntry do
let(:display_name) { "Good" }
it "returns true" do
variant = create(:variant, unit_value: 500_000, display_name: "Good")
variant = create(:variant, unit_value: 500, display_name: "Good")
expect(entry.match_variant?(variant)).to be(true)
end
@@ -47,10 +48,44 @@ RSpec.describe ProductImport::SpreadsheetEntry do
let(:display_name) { "Bad" }
it "returns false" do
variant = create(:variant, unit_value: 500_000, display_name: "Good")
variant = create(:variant, unit_value: 500, display_name: "Good")
expect(entry.match_variant?(variant)).to be(false)
end
end
end
describe "#match_inventory_variant?" do
it "returns true if matching" do
variant = create(:variant, unit_value: 500_000)
expect(entry.match_inventory_variant?(variant)).to be(true)
end
it "returns false if not machting" do
variant = create(:variant, unit_value: 500)
expect(entry.match_inventory_variant?(variant)).to be(false)
end
context "with same display_name" do
let(:display_name) { "Good" }
it "returns true" do
variant = create(:variant, unit_value: 500_000, display_name: "Good")
expect(entry.match_inventory_variant?(variant)).to be(true)
end
end
context "with different display_name" do
let(:display_name) { "Bad" }
it "returns false" do
variant = create(:variant, unit_value: 500_000, display_name: "Good")
expect(entry.match_inventory_variant?(variant)).to be(false)
end
end
end
end

View File

@@ -578,11 +578,11 @@ RSpec.describe ProductImport::ProductImporter do
describe "updating non-updatable fields on existing variants" do
let(:csv_data) {
CSV.generate do |csv|
csv << ["name", "producer", "category", "on_hand", "price", "units", "variant_unit_name",
csv << ["name", "producer", "category", "on_hand", "price", "units", "unit_type",
"shipping_category"]
csv << ["Beetroot", enterprise3.name, "Vegetables", "5", "3.50", "500", "Half",
csv << ["Beetroot", enterprise3.name, "Vegetables", "5", "3.50", "500", "Kg",
shipping_category.name]
csv << ["Tomato", enterprise3.name, "Vegetables", "6", "5.50", "500", "Half",
csv << ["Tomato", enterprise3.name, "Vegetables", "6", "5.50", "500", "Kg",
shipping_category.name]
end
}

View File

@@ -34,8 +34,6 @@ RSpec.describe "Pay Your Suppliers Report" do
before do
login_as owner
visit admin_reports_path
update_line_items_product_names
end
context "on Reports page" do
@@ -140,18 +138,4 @@ RSpec.describe "Pay Your Suppliers Report" do
expect(lines.last).to have_content("TOTAL 50.0 50.0 0.0 0.0 0.0 50.0")
end
end
def update_line_items_product_names
n = 1
update_product_name_proc = proc do |order|
order.line_items.each do |line_item|
product = line_item.variant.product
product.update!(name: "Product##{n}")
n += 1
end
end
update_product_name_proc.call(order1)
update_product_name_proc.call(order2)
end
end

View File

@@ -1,28 +0,0 @@
# frozen_string_literal: true
require 'system_helper'
RSpec.describe 'Map' do
context 'map can load' do
it 'does not show alert' do
url_whitelist = page.driver.browser.url_whitelist
page.driver.browser.url_whitelist = nil
assert_raises(Capybara::ModalNotFound) do
accept_alert { visit '/map' }
end
page.driver.browser.url_whitelist = url_whitelist
end
end
context 'map cannot load' do
it 'shows alert' do
message = accept_alert { visit '/map' }
expect(message).to eq(
"Unable to load map. Please check your browser " \
"settings and allow 3rd party cookies for this website."
)
end
end
end

View File

@@ -97,13 +97,12 @@ paths:
dfc-b:hasAddress:
"@type": dfc-b:Address
dfc-b:hasPostalCode: '20170'
dfc-b:hasCountry: Australia
dfc-b:supplies:
"@type": dfc-b:SuppliedProduct
dfc-b:name: Tomato
dfc-b:hasQuantity:
"@type": dfc-b:QuantitativeValue
dfc-b:hasUnit: dfc-m:Piece
dfc-b:hasUnit: dfc-m:Gram
dfc-b:value: 1.0
dfc-b:concernedBy:
"@type": dfc-b:OrderLine
@@ -125,7 +124,6 @@ paths:
dfc-b:hasAddress:
"@type": dfc-b:Address
dfc-b:hasPostalCode: '20170'
dfc-b:hasCountry: Australia
'400':
description: bad request
"/api/dfc/enterprises/{enterprise_id}/catalog_items":