--order 502682    
      /*
      ACTION is CREATE Table PICKLISTSTOCKTRANSACTION
      */

CREATE TABLE PICKLISTSTOCKTRANSACTION (
       STOCKTRANSACTION_ID  NUMBER NOT NULL,
       PICKLISTLINE_ID      NUMBER NOT NULL,
       QUANTITY             NUMBER NOT NULL,
       SYSTEMUSER_ID        NUMBER NOT NULL,
       TIMESTAMP            DATE NOT NULL
);

CREATE INDEX XIF1PICKLISTSTOCKTRANSACTION ON PICKLISTSTOCKTRANSACTION
(
       STOCKTRANSACTION_ID            ASC
);

CREATE INDEX XIF2PICKLISTSTOCKTRANSACTION ON PICKLISTSTOCKTRANSACTION
(
       PICKLISTLINE_ID                ASC
);


ALTER TABLE PICKLISTSTOCKTRANSACTION
       ADD  ( CONSTRAINT XPKPICKLISTSTOCKTRANSACTION PRIMARY KEY (
              STOCKTRANSACTION_ID, PICKLISTLINE_ID) ) ;

      
      /*
      CHANGE REPORT for Table STOCKTRANSACTION
          - Adding column REMARK
	  - Adding column DOCUMENTTYPE
          - Adding column DOCUMENTNUMBER
          - Adding column DOCUMENTNUMBERPREFIX
          - Adding column STOCKVALUATIONMETHOD
          - Adding column CALCULATIONPRICE
      ACTION is ALTER or modify Table STOCKTRANSACTION
      */

ALTER TABLE STOCKTRANSACTION ADD (REMARK               VARCHAR2(80) NULL);

   
ALTER TABLE STOCKTRANSACTION ADD (DOCUMENTTYPE         NUMBER DEFAULT 0 NOT NULL
                                   CONSTRAINT DocumentType_valid
                                          CHECK (DOCUMENTTYPE BETWEEN 0 AND 12));

COMMENT ON COLUMN STOCKTRANSACTION.DOCUMENTTYPE IS '0 = Stocktransaction
1 = Internal Purchase Order
2 = External Purchase Order
3 = Work Order
4 = Pick List (Internal movements)
5 = Truck Load List
6 = Sales Note
7 = Credit Note
8 = Stock Delivery (Internal PO)
9 = Stock Delivery (Direct)
10 = Mounting Order
11 = Dismounting Order
12 = Delivery Note';

ALTER TABLE STOCKTRANSACTION ADD (DOCUMENTNUMBER       NUMBER DEFAULT 0 NOT 
    NULL);


ALTER TABLE STOCKTRANSACTION ADD (DOCUMENTNUMBERPREFIX VARCHAR2(1) NULL);

COMMENT ON COLUMN STOCKTRANSACTION.DOCUMENTNUMBERPREFIX IS 'This attribute can contain a prefix that might be added in front of the document number.';



ALTER TABLE STOCKTRANSACTION ADD (STOCKVALUATIONMETHOD NUMBER DEFAULT 0 NOT NULL
                                   CONSTRAINT StockValuationMethod_valid2
                                          CHECK (STOCKVALUATIONMETHOD BETWEEN 0 AND 3));

COMMENT ON COLUMN STOCKTRANSACTION.STOCKVALUATIONMETHOD IS '0 = Standard (Historical purchase price)
1 = FIFO (First in First out)
2 = AVGPP (average purchase price)
3 = FSP (fixed settle price)';

ALTER TABLE STOCKTRANSACTION ADD (CALCULATIONPRICE     NUMBER DEFAULT 0 NOT 
    NULL);

COMMENT ON COLUMN STOCKTRANSACTION.CALCULATIONPRICE IS 'Price that is used to calculate the value of the goods involved in the transaction.';


ALTER TABLE PICKLISTSTOCKTRANSACTION
       ADD  ( CONSTRAINT PICKLISTSTOCKTRANSACTION_PICKL
              FOREIGN KEY (PICKLISTLINE_ID)
                             REFERENCES PICKLISTLINE ) ;


ALTER TABLE PICKLISTSTOCKTRANSACTION
       ADD  ( CONSTRAINT PICKLISTSTOCKTRANSACTION_STOCK
              FOREIGN KEY (STOCKTRANSACTION_ID)
                             REFERENCES STOCKTRANSACTION ) ;



