Subversion Repositories SmartDukaan

Rev

Rev 36346 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
36335 ranu 1
package com.spice.profitmandi.dao.model;
2
 
3
import javax.persistence.*;
4
 
5
@Entity
6
@NamedNativeQueries({
7
        @NamedNativeQuery(name = "Aging.15DaysWarehouseWiseStock",
8
                query = "SELECT " +
9
                        "    po.warehouseId AS warehouse_id, " +
10
                        "    SUM(tl.selling_price) AS total_aging " +
11
                        "FROM warehouse.invoice inv " +
12
                        "JOIN warehouse.supplier su ON su.id = inv.supplierId AND su.internal = 0 " +
13
                        "JOIN warehouse.purchase p ON p.invoice_id = inv.id " +
14
                        "JOIN warehouse.purchaseorder po ON po.id = p.purchaseOrder_id " +
15
                        "    AND po.supplierId = inv.supplierId " +
16
                        "JOIN warehouse.inventoryItem ii2 ON ii2.purchaseId = p.id " +
17
                        "    AND ii2.lastScanType != 'PURCHASE_RETURN' AND ii2.physicalWarehouseId = po.warehouseId " +
18
                        "JOIN warehouse.inventoryItem ii ON ii.serialNumber = ii2.serialNumber " +
19
                        "    AND ii.currentQuantity = 1 " +
20
                        "    AND ii.lastScanType NOT IN ('DOA_IN', 'DOA_OUT', 'SALE_RET_UNUSABLE') " +
21
                        "    AND ii.created > '2018-01-01' " +
22
                        "JOIN warehouse.scanNew s ON s.inventoryItemId = ii.id AND s.type = 'PURCHASE' " +
23
                        "JOIN catalog.item i ON i.id = ii.itemId AND i.category = 10006 " +
24
                        "JOIN catalog.tag_listing tl ON tl.item_id = i.id " +
25
                        "WHERE inv.invoiceDate < DATE_SUB(CURDATE(), INTERVAL 15 DAY) " +
26
                        "GROUP BY po.warehouseId",
27
                resultSetMapping = "WarehouseAgingStock")
28
})
29
 
30
@SqlResultSetMappings({
31
        @SqlResultSetMapping(name = "WarehouseAgingStock",
32
                classes = {@ConstructorResult(targetClass = WarehouseAgingStockModel.class,
33
                        columns = {
34
                                @ColumnResult(name = "warehouse_id", type = Integer.class),
35
                                @ColumnResult(name = "total_aging", type = Long.class),
36
                        }
37
                )}
38
        )
39
})
40
 
41
public class WarehouseAgingStockModel {
42
 
43
    @Id
44
    @GeneratedValue(strategy = GenerationType.IDENTITY)
45
    private Long id;
46
 
47
    private int warehouseId;
48
    private long totalAging;
49
 
50
    public WarehouseAgingStockModel(int warehouseId, long totalAging) {
51
        this.warehouseId = warehouseId;
52
        this.totalAging = totalAging;
53
    }
54
 
55
    public int getWarehouseId() {
56
        return warehouseId;
57
    }
58
 
59
    public void setWarehouseId(int warehouseId) {
60
        this.warehouseId = warehouseId;
61
    }
62
 
63
    public long getTotalAging() {
64
        return totalAging;
65
    }
66
 
67
    public void setTotalAging(long totalAging) {
68
        this.totalAging = totalAging;
69
    }
70
}