Sfoglia il codice sorgente

fix: [AE-会员端] 修改未登录时下单的价格

bill 3 settimane fa
parent
commit
df97ec1c79

+ 2 - 0
src/ui-refactor/components/ProductDetailsDialog.vue

@@ -20,6 +20,7 @@
           <h3 slot="title" class="ng-product-details-name">{{ product.GOODS_NAME }}</h3>
           <el-descriptions-item label="Product Code">{{ product.GOODS_NO }}</el-descriptions-item>
           <el-descriptions-item
+            v-if="showSalesPrice"
             label="Sales Price"
           >{{ currency }} {{ product.SELL_PRICE | toThousandFilter }}</el-descriptions-item>
           <el-descriptions-item
@@ -50,6 +51,7 @@ export default {
   filters: { toThousandFilter },
   props: {
     visible: { type: Boolean, default: false },
+    showSalesPrice: { type: Boolean, default: true },
     showBv: { type: Boolean, default: true },
     product: { type: Object, required: true },
     currency: { type: String, default: '' }

+ 1 - 1
src/ui-refactor/components/README.md

@@ -19,7 +19,7 @@
 
 ## 商品详情
 
-`ProductDetailsDialog.vue` 供注册、Member Welcome Pack 和会员购买流程共用,基于现有 `UiDialog` 展示图片、商品编号、销售价、市场价、BV、税率、税额和库存。统一使用现有千分位过滤器,税率仍为 `TAX_RATE / 100`,税额直接读取页面提供的 `taxAmount`,不查询接口或计算订单金额。
+`ProductDetailsDialog.vue` 供注册、游客购物、Member Welcome Pack 和会员购买流程共用,基于现有 `UiDialog` 展示图片、商品编号、销售价、市场价、BV、税率、税额和库存。`showSalesPrice` 默认开启,注册和游客购物显式关闭以隐藏销售价,会员保持原展示。统一使用现有千分位过滤器,税率仍为 `TAX_RATE / 100`,税额直接读取页面提供的 `taxAmount`,不查询接口或计算订单金额。
 
 ```vue
 <product-details-dialog :visible.sync="visibleProduct" :product="product" :currency="currencyUnitCode" />

+ 2 - 0
src/ui-refactor/views/guest-shop/GuestPurchaseFlow.vue

@@ -7,6 +7,7 @@
       <signup-products
         v-loading="listLoading"
         :items="displayProducts"
+        use-market-price
         :quantities="quantities"
         :selected-ids="selectedIds"
         country-selected
@@ -187,6 +188,7 @@
       />
     </paystack-payment-dialog>
     <product-details-dialog
+      :show-sales-price="false"
       :visible.sync="productVisible"
       :product="product"
       :currency="currency"

+ 3 - 1
src/ui-refactor/views/guest-shop/README.md

@@ -23,7 +23,7 @@
 
 下单只发送 `countryId / goodsId / goodsNum / email / payType / consignee / acceptMobile / province / lgaName / cityName / detailaddress`。手机号区号跟随国家显示,`acceptMobile` 仍传用户输入值,`province` 保留地区路径数组。不发送会员编号、报单中心、支付密码或会员地址 ID。
 
-计价沿用复消的 SELL_PRICE × DISCOUNT / 100、含税展示及免运费阈值;税不再叠加到应付金额。商品、购物车和结账展示优先使用商品 `COIN`,结算配置的 `coin` 只作兜底;两个 GET 的返回顺序不影响商品币种。Place order 先验证地址,再确认邮箱,最后下单。非 Paystack 以匿名下单成功返回的 SN 进入公开详情骨架。
+游客商品卡片、购物车单价/行金额、结账汇总与税额统一使用接口 `MARKET_PRICE`,不套用会员销售价或折扣;保留原含税算法及免运费阈值,税不再叠加到应付金额。游客和注册详情隐藏 Sales Price,登录后的展示与计价保持原样。商品、购物车和结账展示优先使用商品 `COIN`,结算配置的 `coin` 只作兜底;两个 GET 的返回顺序不影响商品币种。Place order 先验证地址,再确认邮箱,最后下单。非 Paystack 以匿名下单成功返回的 SN 进入公开详情骨架。
 
 匿名下单实际可返回订单记录 `SN / PAY_AMOUNT / ORDER_AMOUNT / COUNTRY_ID / CURRENCY_ID`:金额优先取 `PAY_AMOUNT`,缺失时取 `ORDER_AMOUNT`,不使用 `_STANDARD` 字段或 `EXCHANGE_RATE` 换算。订单未返回 ISO 币种代码时,必须先核对 `COUNTRY_ID` 和当前国家,再用 `CURRENCY_ID` 匹配所选商品的 `LOCAL_CURRENCY_ID`,使用该商品的 `COIN`;无法匹配时保留订单并阻止支付。继续兼容原 `SN / amount / currency`,显式返回的 `amount / currency` 优先。返回 `EMAIL` 为空时仍使用表单内已确认的邮箱。
 
@@ -74,6 +74,8 @@ $env:NODE_PATH='C:\Users\Administrator\.cache\codex-runtimes\codex-primary-runti
 
 ## 交付限制
 
+2026-10-23 未登录计价修正验证:新增 25 项回归通过;全量 UI 回归 391 项通过、相同 12 项既有失败。定向 lint、生产构建、90 组隔离浏览器布局检查通过,覆盖 Nigeria/UAE 与注册的市场价卡片、详情和游客购物步骤;会员原价格及 Sales Price 展示有独立回归。6/6 价格与展示故障注入被捕获,使用临时源码副本,没有修改运行中的源码。未执行真实注册、下单或支付。
+
 - 未进行真实后端、真实订单、实际 Paystack 扣款或服务端付款确认。匿名 API、地区访问权限、可用支付方式、支付币种与 SN / amount / currency 响应仍须在授权测试环境联调。
 - 没有匿名详情或订单状态接口,刷新后不能恢复未付单,无法查询网络中断时的下单结果;接口须负责最终计价、库存与订单幂等,前端不宣称提供服务端幂等保证。
 - 本轮核对 469 个既有文件(包含未跟踪文件和根环境/lockfile);只改动登录入口、shop API、路由、白名单、四个共用展示组件、商品卡片和登录测试依赖设置,未删除文件。未提交、推送或部署。

+ 33 - 7
src/ui-refactor/views/guest-shop/__tests__/verifyBrowser.cjs

@@ -43,6 +43,12 @@ async function main() {
           // 故意返回相反币种,验证商品 COIN 不被结算配置覆盖。
           else if (api.endsWith('no-login-show-cart')) data = { sellType: [{ id: 1, sell_type: [{ label: 'pay_stack', name: 'Paystack' }] }], freight: 10, freeShipping: 500, coin: currency === 'NGN' ? 'AED' : 'NGN' }
           else data = [{ value: 'R1', label: country === ids.ae ? 'Dubai' : 'Lagos' }]
+        } else if (api === '/v1/user/guest-dec' && request.method() === 'GET') {
+          data = {
+            draft: { insertUserName: 'SAMPLE-MEMBER', currency: 'NGN' },
+            allGoods: [{ ID: 'P1', GOODS_NAME: 'Sample registration product', GOODS_NO: 'SKU1', COVER: 'guest-fixture.png', SELL_PRICE: 100, MARKET_PRICE: 120, PRICE_PV: 20, STORE_NUMS: 5, TAX_RATE: 7.5, CODE: 'NGN' }],
+            allOpenBank: [], region: [], decLevel: [], isDec: '0', payList: [{ label: 'pay_stack', name: 'Paystack' }]
+          }
         } else if (api === '/v1/shop/no-login-reconsume-sure-order') {
           assert.equal(request.method(), 'POST')
           const params = request.postDataJSON()
@@ -51,7 +57,7 @@ async function main() {
           orders.push(params)
           data = params.countryId === ids.ae
             ? { SN: 'SAMPLE-ORDER-' + orders.length, amount: 10, currency: 'USD' }
-            : { SN: 'SAMPLE-ORDER-' + orders.length, DEC_SN: 'SAMPLE-DECLARATION', COUNTRY_ID: ids.ng, CURRENCY_ID: '104', ORDER_AMOUNT: 90, PAY_AMOUNT: 90, PAY_FREIGHT: 0, PAY_AMOUNT_STANDARD: 0.075, EXCHANGE_RATE: '1200', EMAIL: '', STATUS: 1 }
+            : { SN: 'SAMPLE-ORDER-' + orders.length, DEC_SN: 'SAMPLE-DECLARATION', COUNTRY_ID: ids.ng, CURRENCY_ID: '104', ORDER_AMOUNT: 130, PAY_AMOUNT: 130, PAY_FREIGHT: 0, PAY_AMOUNT_STANDARD: 0.075, EXCHANGE_RATE: '1200', EMAIL: '', STATUS: 1 }
         } else { unknown.push(api); return route.abort() }
         return route.fulfill({ contentType: 'application/json', body: JSON.stringify({ success: true, data: { data }}) })
       }
@@ -98,17 +104,24 @@ async function main() {
       assert.equal(await page.locator('.ng-public-header').count(), 0)
       assert((await page.locator('.ng-public-hero-title').textContent()).includes(market === 'ae' ? 'UAE.' : 'Nigeria.'))
       assert.equal(await page.locator('.ng-signup-product-bv').count(), 0)
-      assert((await page.locator('.ng-signup-product-price').first().textContent()).includes(currency + ' 80'))
+      assert((await page.locator('.ng-signup-product-price').first().textContent()).includes(currency + ' 120'))
       await layouts(market + '-catalog')
+      await page.getByRole('button', { name: /View product/ }).first().click()
+      const details = page.locator('.ng-product-details-dialog .el-dialog:visible')
+      await details.waitFor()
+      assert(!(await details.textContent()).includes('Sales Price'))
+      assert((await details.textContent()).includes(currency + ' 120'))
+      await layouts(market + '-details', true)
+      await details.getByRole('button', { name: 'Close', exact: true }).last().click()
       await page.getByRole('button', { name: 'Add to cart', exact: true }).first().click()
       await page.getByRole('button', { name: /Open cart/ }).click()
       await page.waitForURL(/\/cart$/)
-      assert((await page.locator('.ng-purchase-cart-item').first().textContent()).includes(currency + ' 80 each'))
-      assert((await page.locator('.ng-purchase-summary').textContent()).includes(currency + ' 90'))
+      assert((await page.locator('.ng-purchase-cart-item').first().textContent()).includes(currency + ' 120 each'))
+      assert((await page.locator('.ng-purchase-summary').textContent()).includes(currency + ' 130'))
       await layouts(market + '-cart')
       await page.getByRole('button', { name: 'Proceed to checkout', exact: true }).click()
       await page.waitForURL(/\/checkout$/)
-      assert((await page.locator('.ng-purchase-summary').textContent()).includes(currency + ' 90'))
+      assert((await page.locator('.ng-purchase-summary').textContent()).includes(currency + ' 130'))
       await page.locator('#ng-guest-consignee').fill('Sample recipient')
       await page.locator('#ng-guest-consignee').press('Tab')
       assert.equal(await page.evaluate(() => document.activeElement.id), 'ng-guest-acceptMobile')
@@ -121,7 +134,7 @@ async function main() {
       await layouts(market + '-checkout')
       await page.getByRole('button', { name: 'Place order', exact: true }).click()
       await page.locator('#ng-paystack-payment-email').fill('visitor@example.test')
-      assert((await page.locator('.ng-paystack-payment-amount strong').textContent()).includes(currency + ' 90'))
+      assert((await page.locator('.ng-paystack-payment-amount strong').textContent()).includes(currency + ' 130'))
       await layouts(market + '-email', true)
       await page.getByRole('button', { name: 'Continue to Paystack', exact: true }).click()
       if (market === 'ae') {
@@ -135,7 +148,7 @@ async function main() {
         throw error
       }
       const payment = await page.evaluate(() => ({ amount: window.samplePayment.amount, currency: window.samplePayment.currency, cart: window.samplePayment.metadata.cart_id, email: window.samplePayment.email }))
-      assert.equal(payment.amount, market === 'ae' ? 1000 : 9000)
+      assert.equal(payment.amount, market === 'ae' ? 1000 : 13000)
       assert.equal(payment.currency, market === 'ae' ? 'USD' : 'NGN')
       assert.equal(payment.cart, 'SAMPLE-ORDER-' + orders.length)
       assert.equal(payment.email, 'visitor@example.test')
@@ -150,6 +163,19 @@ async function main() {
       assert((await page.locator('.ng-guest-order').textContent()).includes('Order details are not available yet'))
       await layouts(market + '-order')
     }
+    await page.goto(origin + '/#/signup')
+    await page.locator('#ng-signup-SignupPagevue-0').click()
+    await page.getByText('Nigeria', { exact: true }).click()
+    await page.locator('.ng-signup-product-add:not(.is-disabled)').first().waitFor()
+    assert.equal((await page.locator('.ng-signup-product-price strong').textContent()).trim(), 'NGN 120')
+    await layouts('signup-catalog')
+    await page.getByRole('button', { name: /View product/ }).first().click()
+    const signupDetails = page.locator('.ng-product-details-dialog .el-dialog:visible')
+    await signupDetails.waitFor()
+    assert(!(await signupDetails.textContent()).includes('Sales Price'))
+    assert((await signupDetails.textContent()).includes('NGN 120'))
+    await layouts('signup-details', true)
+    await signupDetails.getByRole('button', { name: 'Close', exact: true }).last().click()
     await page.goto(origin + '/#/guest-shop/ae/checkout')
     await page.waitForURL(/guest-shop\/ae\/cart$/)
     await page.getByText('Your cart is empty', { exact: true }).waitFor()

+ 7 - 11
src/ui-refactor/views/guest-shop/guestPurchase.js

@@ -12,20 +12,17 @@ export const validItem = item =>
   Number.isInteger(item.quantity) &&
   item.quantity > 0 &&
   item.quantity <= Number(item.STORE_NUMS) &&
-  ['SELL_PRICE', 'DISCOUNT', 'TAX_RATE'].every(key => numeric(item[key]) && Number(item[key]) >= 0)
+  ['MARKET_PRICE', 'TAX_RATE'].every(key => numeric(item[key]) && Number(item[key]) >= 0)
 
 export function cartTotals(items, freeShipping, freight) {
   const subtotal = money(
-    items.reduce(
-      (sum, item) => sum + (Number(item.SELL_PRICE) * item.quantity * Number(item.DISCOUNT)) / 100,
-      0
-    )
+    items.reduce((sum, item) => sum + Number(item.MARKET_PRICE) * item.quantity, 0)
   )
   const shipping = items.length && subtotal < Number(freeShipping) ? Number(freight) : 0
   const tax = money(
     items.reduce(
       (sum, item) =>
-        sum + tool.calculateTax(Number(item.SELL_PRICE), Number(item.TAX_RATE), item.quantity),
+        sum + tool.calculateTax(Number(item.MARKET_PRICE), Number(item.TAX_RATE), item.quantity),
       0
     )
   )
@@ -130,16 +127,15 @@ export default {
     displayProducts() {
       return this.products.map(item => ({
         ...item,
-        CODE: this.currency,
-        SELL_PRICE: money((Number(item.SELL_PRICE) * Number(item.DISCOUNT)) / 100)
+        CODE: this.currency
       }))
     },
     cartRows() {
       return this.items.map(item => ({
         ...item,
         image: tool.getArImage(item.COVER, '/files/'),
-        unitPrice: money((Number(item.SELL_PRICE) * Number(item.DISCOUNT)) / 100),
-        linePrice: money(((Number(item.SELL_PRICE) * Number(item.DISCOUNT)) / 100) * item.quantity)
+        unitPrice: money(Number(item.MARKET_PRICE)),
+        linePrice: money(Number(item.MARKET_PRICE) * item.quantity)
       }))
     },
     paymentMethod() {
@@ -424,7 +420,7 @@ export default {
       this.$router.push({ path: '/guest-order', query: { order: sn }})
     },
     showProduct(row) {
-      this.product = { ...row, taxAmount: tool.calculateTax(row.SELL_PRICE, row.TAX_RATE) }
+      this.product = { ...row, taxAmount: tool.calculateTax(row.MARKET_PRICE, row.TAX_RATE) }
       this.productVisible = true
     }
   }

+ 12 - 0
src/ui-refactor/views/purchase/__tests__/PurchaseFlow.spec.js

@@ -64,6 +64,18 @@ async function withProducts(source = names[0]) {
   return vm
 }
 
+it.each(names)('%s keeps member catalog and sales price details unchanged', async source => {
+  const vm = await withProducts(source)
+  vm.stage = 'catalog'
+  await settle()
+  expect(vm.$el.querySelector('.ng-signup-product-price strong').textContent).toBe('NGN 100')
+  vm.$el.querySelector('.ng-signup-product-view').click()
+  await settle()
+  const dialog = document.body.querySelector('.ng-product-details-dialog')
+  expect(dialog.textContent).toContain('Sales PriceNGN 100')
+  expect(dialog.textContent).toContain('Market PriceNGN 120')
+})
+
 it('uses the shared cart list and preserves quantity and remove events', async() => {
   const vm = await withProducts('repeat-purchase')
   vm.stage = 'cart'

+ 1 - 0
src/ui-refactor/views/signup/SignupPage.vue

@@ -103,6 +103,7 @@
       <ui-section-card title="Products">
         <signup-products
           :items="tableData"
+          use-market-price
           :quantities="storeNums"
           :selected-ids="selectedIds"
           :country-selected="!!form.countryId"

+ 1 - 0
src/ui-refactor/views/signup/components/SignupDialogs.vue

@@ -24,6 +24,7 @@
       />
     </paystack-payment-dialog>
     <product-details-dialog
+      :show-sales-price="false"
       :visible="productVisible"
       :product="product"
       :currency="currency"

+ 2 - 1
src/ui-refactor/views/signup/components/SignupProducts.vue

@@ -46,7 +46,7 @@
             <h3 class="ng-signup-product-name">{{ item.GOODS_NAME }}</h3>
             <p class="ng-signup-product-code">{{ item.CONTENT }}</p>
             <div class="ng-signup-product-price">
-              <strong>{{ item.CODE }} {{ item.SELL_PRICE | toThousandFilter }}</strong>
+              <strong>{{ item.CODE }} {{ (useMarketPrice ? item.MARKET_PRICE : item.SELL_PRICE) | toThousandFilter }}</strong>
               <el-tag v-if="showBv" class="ng-signup-product-bv" size="mini" color="#E9F4F8">
                 {{ item.PRICE_PV | toThousandFilter }} BV
               </el-tag>
@@ -131,6 +131,7 @@ export default {
     bv: { type: [Number, String], required: true },
     tax: { type: [Number, String], required: true },
     currency: { type: String, default: '' },
+    useMarketPrice: { type: Boolean, default: false },
     showBv: { type: Boolean, default: true },
     helpText: {
       type: String,

+ 38 - 16
tests/unit/ui-refactor/guestShop.spec.js

@@ -1,6 +1,6 @@
 /* eslint-env jest */
 import Vue from 'vue'
-import behavior, { cartTotals, paymentOrder } from '@/ui-refactor/views/guest-shop/guestPurchase'
+import behavior, { cartTotals, paymentOrder, validItem } from '@/ui-refactor/views/guest-shop/guestPurchase'
 import * as shop from '@/api/shop'
 import { getGuestRegionList } from '@/api/config'
 
@@ -8,7 +8,7 @@ jest.mock('@/api/shop', () => ({ fetchGuestProducts: jest.fn(), fetchGuestCart:
 jest.mock('@/api/config', () => ({ getGuestRegionList: jest.fn() }))
 jest.mock('@/router', () => ({ push: jest.fn(), replace: jest.fn() }))
 
-const product = { ID: 'P1', GOODS_NAME: 'Product', SELL_PRICE: 100, DISCOUNT: 80, STORE_NUMS: 5, TAX_RATE: 7.5, COIN: 'NGN' }
+const product = { ID: 'P1', GOODS_NAME: 'Product', SELL_PRICE: 100, MARKET_PRICE: 120, DISCOUNT: 80, STORE_NUMS: 5, TAX_RATE: 7.5, COIN: 'NGN' }
 const instances = []
 const shipping = { consignee: 'Recipient', acceptMobile: '123456789', province: ['R1'], lgaName: 'District', cityName: 'City', detailaddress: 'Street', email: 'guest@example.test' }
 async function settle() { for (let i = 0; i < 12; i++) { await Promise.resolve(); await Vue.nextTick() } }
@@ -36,7 +36,7 @@ beforeEach(() => {
   shop.fetchGuestProducts.mockResolvedValue({ data: { list: [product], totalCount: 1 }})
   shop.fetchGuestCart.mockResolvedValue({ data: { sellType: [{ id: 1, sell_type: [{ label: 'pay_stack', name: 'Paystack' }] }], freight: 10, freeShipping: 500, coin: 'NGN' }})
   getGuestRegionList.mockResolvedValue({ data: [{ value: 'R1', label: 'Region' }] })
-  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'ORDER1', amount: 90, currency: 'NGN' }})
+  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'ORDER1', amount: 130, currency: 'NGN' }})
 })
 afterEach(() => { instances.splice(0).forEach(vm => vm.$destroy()) })
 
@@ -68,19 +68,41 @@ it.each([
   expect(vm.currency).toBe(coin)
   expect(vm.displayProducts[0].CODE).toBe(coin)
 })
-it('calculates the legacy discount and shipping without adding included tax again', () => {
-  expect(cartTotals([{ ...product, quantity: 2 }], 500, 10)).toMatchObject({ subtotal: 160, shipping: 10, total: 170, tax: 13.95 })
-  expect(cartTotals([{ ...product, quantity: 5 }], 400, 10).total).toBe(400)
+it('uses market price without member discount and does not add included tax again', () => {
+  expect(cartTotals([{ ...product, quantity: 2 }], 500, 10)).toEqual({ subtotal: 240, shipping: 10, total: 250, tax: 16.74 })
+  expect(cartTotals([{ ...product, quantity: 5 }], 600, 10).total).toBe(600)
+  expect(cartTotals([], 500, 10)).toEqual({ subtotal: 0, shipping: 0, total: 0, tax: 0 })
 })
 it('holds quantity and total invariants over a range of stock and prices', () => {
   for (let cents = 1; cents < 130; cents += 7) {
-    const row = { ...product, SELL_PRICE: cents / 100, DISCOUNT: 100, quantity: 3 }
-    const result = cartTotals([row], 0, 0)
-    expect(result.total).toBe(Math.round(cents * 3) / 100)
-    expect(result.tax).toBeGreaterThanOrEqual(0)
-    expect(result.tax).toBeLessThanOrEqual(result.total)
+    for (let quantity = 1; quantity <= product.STORE_NUMS; quantity++) {
+      for (const price of [cents / 100, (cents / 100).toFixed(2)]) {
+        const row = { ...product, MARKET_PRICE: price, quantity }
+        const result = cartTotals([row], 0, 0)
+        expect(result.total).toBe(cents * quantity / 100)
+        expect(result.tax).toBeGreaterThanOrEqual(0)
+        expect(result.tax).toBeLessThanOrEqual(result.total)
+      }
+    }
   }
 })
+it.each([null, undefined, '', ' ', -1, 'bad', Infinity, true, []])('rejects invalid market price %s instead of falling back to sales price', price => {
+  expect(validItem({ ...product, MARKET_PRICE: price, quantity: 1 })).toBe(false)
+})
+it.each([0, '0', '120.50'])('validates market price %s without requiring sales price or discount', price => {
+  expect(validItem({ ...product, MARKET_PRICE: price, SELL_PRICE: undefined, DISCOUNT: undefined, quantity: 1 })).toBe(true)
+})
+it('uses original market prices for product details, cart unit and line prices', async() => {
+  const vm = await instance()
+  const row = vm.displayProducts[0]
+  expect(row.SELL_PRICE).toBe(100)
+  vm.toggleProduct(row)
+  vm.changeQuantity({ row, value: 2 })
+  expect(vm.cartRows[0]).toMatchObject({ unitPrice: 120, linePrice: 240 })
+  vm.showProduct(row)
+  expect(vm.product).toMatchObject({ SELL_PRICE: 100, MARKET_PRICE: 120, taxAmount: 8.37 })
+  expect(product).not.toHaveProperty('taxAmount')
+})
 it.each([null, '', '  ', 0, -1, 'abc', Infinity, true, ['100'], 1e20])('rejects invalid payment amount %s', amount => {
   expect(() => paymentOrder({ SN: 'O1', amount, currency: 'NGN' })).toThrow()
 })
@@ -125,7 +147,7 @@ it('blocks duplicate submit and retains the same unpaid order after cancellation
   const first = vm.continuePayment()
   await vm.continuePayment()
   expect(shop.createGuestOrder).toHaveBeenCalledTimes(1)
-  resolve({ data: { SN: 'ORDER1', amount: 90, currency: 'NGN' }})
+  resolve({ data: { SN: 'ORDER1', amount: 130, currency: 'NGN' }})
   await first
   const callback = vm.paymentCallback
   vm.closePayment()
@@ -163,9 +185,9 @@ it.each([
   vm.stage = 'checkout'
   await settle()
   vm.openEmail()
-  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'RECORD1', DEC_SN: 'DECLARATION1', COUNTRY_ID: countryId, CURRENCY_ID: currencyId, PAY_AMOUNT: 90, ORDER_AMOUNT: 100, PAY_AMOUNT_STANDARD: 0.075, EXCHANGE_RATE: '1200', EMAIL: '', STATUS: 1 }})
+  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'RECORD1', DEC_SN: 'DECLARATION1', COUNTRY_ID: countryId, CURRENCY_ID: currencyId, PAY_AMOUNT: 130, ORDER_AMOUNT: 150, PAY_AMOUNT_STANDARD: 0.075, EXCHANGE_RATE: '1200', EMAIL: '', STATUS: 1 }})
   await vm.continuePayment()
-  expect(vm.pending).toEqual({ SN: 'RECORD1', amount: 90, currency, subunits: 9000 })
+  expect(vm.pending).toEqual({ SN: 'RECORD1', amount: 130, currency, subunits: 13000 })
   expect(vm.$refs.paystack.payWithPaystack).toHaveBeenCalledTimes(1)
   expect(vm.metadata.cart_id).toBe('RECORD1')
   expect(vm.form.email).toBe(shipping.email)
@@ -179,9 +201,9 @@ it.each([
 it('accepts ORDER_AMOUNT when the returned order record has no PAY_AMOUNT', async() => {
   shop.fetchGuestProducts.mockResolvedValue({ data: { list: [{ ...product, LOCAL_CURRENCY_ID: '104' }], totalCount: 1 }})
   const vm = await checkout()
-  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'RECORD1', COUNTRY_ID: '620699181539139625', CURRENCY_ID: '104', ORDER_AMOUNT: 90 }})
+  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'RECORD1', COUNTRY_ID: '620699181539139625', CURRENCY_ID: '104', ORDER_AMOUNT: 130 }})
   await vm.continuePayment()
-  expect(vm.pending).toEqual({ SN: 'RECORD1', amount: 90, currency: 'NGN', subunits: 9000 })
+  expect(vm.pending).toEqual({ SN: 'RECORD1', amount: 130, currency: 'NGN', subunits: 13000 })
   expect(vm.$refs.paystack.payWithPaystack).toHaveBeenCalledTimes(1)
 })
 it('updates the email amount and requests confirmation when the order record changes the total', async() => {

+ 20 - 9
tests/unit/ui-refactor/guestShopUi.spec.js

@@ -57,16 +57,27 @@ it('offers the two markets and navigates without asking for credentials', async(
   options[1].click()
   expect(push).toHaveBeenCalledWith({ path: '/guest-shop/ae' })
 })
+it('hides Sales Price and BV in guest product details while keeping market price and its tax', async() => {
+  const vm = mount(Flow, { market: 'ae', stage: 'catalog' })
+  await settle()
+  vm.$el.querySelector('.ng-signup-product-view').click()
+  await settle()
+  const dialog = document.body.querySelector('.ng-product-details-dialog')
+  expect(dialog.textContent).not.toContain('Sales Price')
+  expect(dialog.textContent).not.toContain('BV')
+  expect(dialog.textContent).toContain('AED 150')
+  expect(dialog.textContent).toContain('AED 10.47')
+})
 it('connects product, cart and checkout controls without guest BV or member fields', async() => {
   const vm = mount(Flow, { market: 'ae', stage: 'catalog' })
   await settle()
-  expect(vm.$el.querySelector('.ng-signup-product-price').textContent).toContain('AED 80')
+  expect(vm.$el.querySelector('.ng-signup-product-price').textContent).toContain('AED 150')
   expect(vm.$el.textContent).not.toContain('BV')
   vm.$el.querySelector('.ng-signup-product-add').click()
   await settle()
   vm.stage = 'cart'
   await settle()
-  expect(vm.$el.querySelector('.ng-purchase-cart-item').textContent).toContain('AED 80 each')
+  expect(vm.$el.querySelector('.ng-purchase-cart-item').textContent).toContain('AED 150 each')
   const cart = descendants(vm).find(child => child.$options.name === 'GuestCart')
   expect(cart.$children[0].$options.name).toBe('PurchaseCartItems')
   expect(vm.$el.querySelector('.ng-purchase-summary').textContent).not.toContain('BV')
@@ -96,29 +107,29 @@ it('connects product, cart and checkout controls without guest BV or member fiel
   expect(dialog.$el.querySelector('[type=password]')).toBeNull()
 })
 it('keeps Nigeria merchandise, cart, checkout and email amounts in the product currency', async() => {
-  shop.fetchGuestProducts.mockResolvedValue({ data: { list: [{ ID: 'P1', GOODS_NAME: 'Nigeria product', SELL_PRICE: 100, DISCOUNT: 80, TAX_RATE: 7.5, STORE_NUMS: 5, COIN: 'NGN' }], totalCount: 1 }})
+  shop.fetchGuestProducts.mockResolvedValue({ data: { list: [{ ID: 'P1', GOODS_NAME: 'Nigeria product', SELL_PRICE: 100, MARKET_PRICE: 120, DISCOUNT: 80, TAX_RATE: 7.5, STORE_NUMS: 5, COIN: 'NGN' }], totalCount: 1 }})
   const vm = mount(Flow, { market: 'ng', stage: 'catalog' })
   await settle()
-  expect(vm.$el.querySelector('.ng-signup-product-price').textContent).toContain('NGN 80')
+  expect(vm.$el.querySelector('.ng-signup-product-price').textContent).toContain('NGN 120')
   vm.$el.querySelector('.ng-signup-product-add').click()
   vm.stage = 'cart'
   await settle()
-  expect(vm.$el.querySelector('.ng-purchase-cart-item').textContent).toContain('NGN 80 each')
-  expect(vm.$el.querySelector('.ng-purchase-summary').textContent).toContain('NGN 90')
+  expect(vm.$el.querySelector('.ng-purchase-cart-item').textContent).toContain('NGN 120 each')
+  expect(vm.$el.querySelector('.ng-purchase-summary').textContent).toContain('NGN 130')
   vm.stage = 'checkout'
   await settle()
-  expect(vm.$el.querySelector('.ng-purchase-summary').textContent).toContain('NGN 90')
+  expect(vm.$el.querySelector('.ng-purchase-summary').textContent).toContain('NGN 130')
   Object.assign(vm.form, { consignee: 'Recipient', acceptMobile: '123', province: ['R1'], lgaName: 'District', cityName: 'Lagos', detailaddress: 'Street' })
   vm.openEmail()
   await settle()
   const dialog = descendants(vm).find(child => child.$options.name === 'PaystackPaymentDialog')
   expect(dialog.visible).toBe(true)
-  expect(dialog.$el.querySelector('.ng-paystack-payment-amount').textContent).toContain('NGN 90')
+  expect(dialog.$el.querySelector('.ng-paystack-payment-amount').textContent).toContain('NGN 130')
 })
 it('opens Paystack with the order record amount, product currency and entered email', async() => {
   const openIframe = jest.fn()
   window.PaystackPop = { setup: jest.fn(() => ({ openIframe })) }
-  shop.fetchGuestProducts.mockResolvedValue({ data: { list: [{ ID: 'P1', GOODS_NAME: 'Nigeria product', SELL_PRICE: 62500, DISCOUNT: 80, TAX_RATE: 7.5, STORE_NUMS: 5, COIN: 'NGN', LOCAL_CURRENCY_ID: '104' }], totalCount: 1 }})
+  shop.fetchGuestProducts.mockResolvedValue({ data: { list: [{ ID: 'P1', GOODS_NAME: 'Nigeria product', SELL_PRICE: 62500, MARKET_PRICE: 50000, DISCOUNT: 80, TAX_RATE: 7.5, STORE_NUMS: 5, COIN: 'NGN', LOCAL_CURRENCY_ID: '104' }], totalCount: 1 }})
   shop.fetchGuestCart.mockResolvedValue({ data: { sellType: [{ id: 1, sell_type: [{ label: 'pay_stack', name: 'Paystack' }] }], freight: 0, freeShipping: 0, coin: 'NGN' }})
   shop.createGuestOrder.mockResolvedValue({ data: { SN: 'SAMPLE-ORDER', DEC_SN: 'SAMPLE-DECLARATION', ORDER_AMOUNT: 50000, PAY_AMOUNT: 50000, PAY_FREIGHT: 0, COUNTRY_ID: '620699181539139625', CURRENCY_ID: '104', EMAIL: '', STATUS: 1 }})
   const vm = mount(Flow, { market: 'ng', stage: 'catalog' })

+ 16 - 3
tests/unit/ui-refactor/productDetails.spec.js

@@ -14,13 +14,13 @@ const product = Object.freeze({
 })
 const instances = []
 
-function mount() {
+function mount(showSalesPrice) {
   const closed = jest.fn()
   const vm = new Vue({
-    data: () => ({ visible: true, product }),
+    data: () => ({ visible: true, product, showSalesPrice }),
     render(h) {
       return h(ProductDetails, {
-        props: { visible: this.visible, product: this.product, currency: 'NGN' },
+        props: { visible: this.visible, product: this.product, currency: 'NGN', showSalesPrice: this.showSalesPrice },
         on: { 'update:visible': value => { this.visible = value; closed(value) } }
       })
     }
@@ -53,6 +53,19 @@ it('preserves the original product fields and supplied tax amount with shared nu
   expect(vm.$children[0].product).toBe(product)
 })
 
+it('hides sales price for anonymous callers and restores it for member callers', async() => {
+  const { vm } = mount(false)
+  await settle()
+  expect(vm.$el.textContent).not.toContain('Sales Price')
+  expect(vm.$el.textContent).not.toContain('NGN 38,000')
+  expect(vm.$el.textContent).toContain('Market Price')
+  expect(vm.$el.textContent).toContain('NGN 42,000')
+  vm.showSalesPrice = true
+  await settle()
+  expect(vm.$el.textContent).toContain('Sales Price')
+  expect(vm.$el.textContent).toContain('NGN 38,000')
+})
+
 it.each(['.el-dialog__headerbtn', '.el-dialog__footer button'])('updates the parent visible state once when closing with %s', async selector => {
   const { vm, closed } = mount()
   await settle()

+ 47 - 1
tests/unit/ui-refactor/signupProducts.spec.js

@@ -3,12 +3,58 @@ import Vue from 'vue'
 import ElementUI from 'element-ui'
 import path from 'path'
 import { toThousandFilter } from '@/filters'
-import { load } from '@/ui-refactor/views/purchase/__tests__/loadComponent'
+import { load } from './loadGuestComponent'
 
 jest.mock('@/utils/usersInfo', () => ({}))
+jest.mock('@/api/user', () => ({}))
 Vue.use(ElementUI)
 Vue.filter('toThousandFilter', toThousandFilter)
 const Products = load(path.resolve('src/ui-refactor/views/signup/components/SignupProducts.vue'))
+const SignupPage = load(path.resolve('src/ui-refactor/views/signup/SignupPage.vue'))
+
+it.each([
+  [undefined, 27000, 32400, 'NGN 27,000'],
+  [false, 27000, 32400, 'NGN 27,000'],
+  [true, 27000, 32400, 'NGN 32,400'],
+  [true, 27000, '32400', 'NGN 32,400'],
+  [true, 27000, 0, 'NGN 0']
+])('uses market price only when requested (%s)', (useMarketPrice, sellPrice, marketPrice, expected) => {
+  const vm = new Vue({
+    ...Products,
+    propsData: {
+      items: [{ ID: 'sample', CODE: 'NGN', SELL_PRICE: sellPrice, MARKET_PRICE: marketPrice }],
+      quantities: [1], selectedIds: [], subtotal: 0, bv: 0, tax: 0, useMarketPrice
+    }
+  }).$mount()
+  try {
+    expect(vm.$el.querySelector('.ng-signup-product-price strong').textContent).toBe(expected)
+  } finally { vm.$destroy() }
+})
+
+it('keeps registration cards, totals and product details on market price', async() => {
+  const vm = new Vue({
+    ...SignupPage,
+    components: { ...SignupPage.components, RouterLink: { render: h => h('a') }},
+    beforeCreate() { this.$route = { query: {}} }
+  }).$mount()
+  document.body.appendChild(vm.$el)
+  try {
+    vm.tableData = [{ ID: 'sample', GOODS_NAME: 'Sample product', GOODS_NO: 'SKU1', CODE: 'NGN', SELL_PRICE: 27000, MARKET_PRICE: 32400, TAX_RATE: 7.5, PRICE_PV: 10, STORE_NUMS: 5 }]
+    vm.storeNums = [1]
+    vm.currencyUnitCode = 'NGN'
+    await Vue.nextTick()
+    expect(vm.$el.querySelector('.ng-signup-product-price strong').textContent).toBe('NGN 32,400')
+    vm.$el.querySelector('.ng-signup-product-add').click()
+    await Vue.nextTick()
+    expect(vm.sellPriceSum).toBe('32400.00')
+    vm.$el.querySelector('.ng-signup-product-view').click()
+    await Vue.nextTick()
+    const details = document.body.querySelector('.ng-product-details-dialog')
+    expect(details.textContent).toContain('NGN 32,400')
+    expect(details.textContent).not.toContain('Sales Price')
+    expect(details.textContent).not.toContain('NGN 27,000')
+  } finally { vm.$destroy(); vm.$el.remove() }
+})
 
 it.each([
   [0, '0', true],