Uploaded image for project: 'mod-orders-storage'
  1. mod-orders-storage
  2. MODORDSTOR-86

Orders without PO Lines are not returned by /orders-storage/orders

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • P3
    • Resolution: Done
    • 5.0.0
    • 6.0.0
    • ACQ Sprint 65
    • 1
    • Thunderjet

    Description

      Overview
      If an order does not have any PO Line yet, the GET /orders-storage/orders does not include it to the results. The easiest way to see it to create an order using UI and then try to find it:

      Reason
      The orders_view view created in scope of MODORDSTOR-22 is defined like:

       SELECT purchase_order.id,
          purchase_order.jsonb,
          po_line.jsonb || COALESCE(purchase_order.jsonb, '{}'::jsonb) AS metadata
         FROM diku_mod_orders_storage.po_line
           LEFT JOIN diku_mod_orders_storage.purchase_order ON (po_line.jsonb -> 'purchaseOrderId'::text) = (purchase_order.jsonb -> 'id'::text);
      

      This means that primary source is po_line table and if there is no yet record for some order, those orders are ignored

      Proposed solution
      Modify orders_view definition like following:

       SELECT purchase_order.id,
          purchase_order.jsonb,
          COALESCE(po_line.jsonb, '{}'::jsonb) || purchase_order.jsonb AS metadata
         FROM diku_mod_orders_storage.purchase_order
           LEFT JOIN diku_mod_orders_storage.po_line ON (po_line.jsonb -> 'purchaseOrderId'::text) = (purchase_order.jsonb -> 'id'::text);
      

      i.e. use purchase_order table as primary and use empty json if no PO Lines found when building metadata

      Acceptance Criteria

      • The view is updated
      • Unit test for this case added
      • API tests updated

      TestRail: Results

        Attachments

          1. NewOrder.gif
            NewOrder.gif
            3.23 MB
          2. NewOrderWithoutPoLine.gif
            NewOrderWithoutPoLine.gif
            1.51 MB
          3. OrderWithoutLines.gif
            OrderWithoutLines.gif
            799 kB

          Issue Links

            Activity

              People

                piotr_kalashuk Piotr Kalashuk
                piotr_kalashuk Piotr Kalashuk
                Craig McNally Craig McNally
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  TestRail: Runs

                    TestRail: Cases