Changes between Version 2 and Version 3 of Buy-Rent


Ignore:
Timestamp:
06/08/25 14:52:02 (3 days ago)
Author:
211301
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Buy-Rent

    v2 v3  
    11
    22== **Купување или изнајмување на камион**
    3 * Клиентот избира производ.
     3* Клиентот избира производ од достапните (со статус available).
    44
    55* Системот нуди опција: купи или изнајми.
    66
    7 * При купување: внеси количина, добива вкупна цена.
     7* При потврда, НЕ се креира веднаш трансакција, туку се креира запис во procurement_request со статус 'Pending'. Ова чека одобрување од вработен.
    88
    9 * При изнајмување: избери период (времетраење), добива месечна цена.
     9* Кога вработениот ќе ја одобри нарачката, се креира запис во procurement и t_type, а производот се менува во 'sold' или 'rented'.
    1010
    11 * Се креира запис во Procurement и T_Type.
     11**Пример INSERT во procurement_request
    1212
    1313{{{
    14 INSERT INTO Procurement (TransactionID, EmployeeID, CustomerID, ProductID, ProcurementDate, Quantity)
    15 VALUES (3, 1, 2, 3, '2025-05-04', 1);
     14INSERT INTO procurement_request
     15(CustomerID, ProductID, CardID, TransactionType, Duration, TotalPrice, MonthlyPay, Status, PaymentStatus, GroupID)
     16VALUES
     17(2, 3, 1, 'Buy', NULL, 30000.00, NULL, 'Pending', 'Paid', 1001);
     18
    1619}}}
    1720
     21**INSERT-и по одобрување од вработен
    1822{{{
    19 INSERT INTO T_Type (TransactionID, Type, Duration, MonthlyPay, TotalPrice)
    20 VALUES (3, 'Buy', NULL, NULL, 30000.00);
     23-- Procurement
     24INSERT INTO procurement
     25(TransactionID, EmployeeID, CustomerID, ProductID, Quantity, ProcurementDate, Status, GroupID)
     26VALUES
     27(3, 1, 2, 3, 1, NOW(), 'Approved', 1001);
     28
     29-- T_Type
     30INSERT INTO t_type
     31(TransactionID, Type, Duration, MonthlyPay, TotalPrice)
     32VALUES
     33(3, 'Buy', NULL, NULL, 30000.00);
     34
     35-- Промена на статус на производот
     36UPDATE product SET Status = 'sold' WHERE ProductID = 3;
     37
    2138}}}
    2239
    23 * Преглед на извршени трансакции.
    24 
     40**Преглед на извршени трансакции
    2541{{{
    2642SELECT
     
    2844    c.CustomerSurName,
    2945    p.Model AS TruckModel,
     46    tt.Type,
    3047    tt.TotalPrice,
    3148    pr.ProcurementDate
    3249FROM
    33     Procurement pr
    34 JOIN Customer c ON pr.CustomerID = c.CustomerID
    35 JOIN Product p ON pr.ProductID = p.ProductID
    36 JOIN T_Type tt ON pr.TransactionID = tt.TransactionID
     50    procurement pr
     51JOIN customer c ON pr.CustomerID = c.CustomerID
     52JOIN product p ON pr.ProductID = p.ProductID
     53JOIN t_type tt ON pr.TransactionID = tt.TransactionID
    3754WHERE
    38     tt.Type = 'Buy';
     55    tt.Type IN ('Buy', 'Rent');
     56
    3957}}}