picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

er.l (5467B)


      1 # 30may13abu
      2 # (c) Software Lab. Alexander Burger
      3 
      4 ### Entity/Relations ###
      5 #
      6 #           nr    nm                   nr    nm               nm
      7 #            |    |                     |    |                |
      8 #          +-*----*-+                 +-*----*-+           +--*-----+
      9 #          |        |             sup |        |           |        |
     10 #    str --*  CuSu  O-----------------*  Item  *-- inv     |  Role  @-- perm
     11 #          |        |                 |        |           |        |
     12 #          +-*-*--O-+                 +----O---+           +----@---+
     13 #            | |  |                        |                    | usr
     14 #   nm  tel -+ |  |                        |                    |
     15 #    |         |  |                        | itm                | role
     16 #  +-*-----+   |  |   +-------+        +---*---+           +----*---+
     17 #  |       |   |  |   |       |    ord |       |           |        |
     18 #  |  Sal  +---+  +---*  Ord  @--------*  Pos  |      nm --*  User  *-- pw
     19 #  |       |      cus |       | pos    |       |           |        |
     20 #  +-*---*-+          +-*---*-+        +-*---*-+           +--------+
     21 #    |   |              |   |            |   |
     22 #   hi   sex           nr  dat          pr   cnt
     23 
     24 (extend +Role)
     25 
     26 (dm url> (Tab)
     27    (and (may RoleAdmin) (list "app/role.l" '*ID This)) )
     28 
     29 
     30 (extend +User)
     31 (rel nam (+String))                    # Full Name
     32 (rel tel (+String))                    # Phone
     33 (rel em (+String))                     # EMail
     34 
     35 (dm url> (Tab)
     36    (and (may UserAdmin) (list "app/user.l" '*ID This)) )
     37 
     38 
     39 # Salutation
     40 (class +Sal +Entity)
     41 (rel nm (+Key +String))                # Salutation
     42 (rel hi (+String))                     # Greeting
     43 (rel sex (+Any))                       # T:male, 0:female
     44 
     45 (dm url> (Tab)
     46    (and (may Customer) (list "app/sal.l" '*ID This)) )
     47 
     48 (dm hi> (Nm)
     49    (or (text (: hi) Nm) ,"Dear Sir or Madam,") )
     50 
     51 
     52 # Customer/Supplier
     53 (class +CuSu +Entity)
     54 (rel nr (+Need +Key +Number))          # Customer/Supplier Number
     55 (rel sal (+Link) (+Sal))               # Salutation
     56 (rel nm (+Sn +Idx +String))            # Name
     57 (rel nm2 (+String))                    # Name 2
     58 (rel str (+String))                    # Street
     59 (rel plz (+Ref +String))               # Zip
     60 (rel ort (+IdxFold +String))           # City
     61 (rel tel (+Fold +Ref +String))         # Phone
     62 (rel fax (+String))                    # Fax
     63 (rel mob (+Fold +Ref +String))         # Mobile
     64 (rel em (+String))                     # EMail
     65 (rel txt (+Blob))                      # Memo
     66 
     67 (dm url> (Tab)
     68    (and (may Customer) (list "app/cusu.l"  '*Tab Tab  '*ID This)) )
     69 
     70 (dm check> ()
     71    (make
     72       (or (: nr) (link ,"No customer number"))
     73       (or (: nm) (link ,"No customer name"))
     74       (unless (and (: str) (: plz) (: ort))
     75          (link ,"Incomplete customer address") ) ) )
     76 
     77 
     78 # Item
     79 (class +Item +Entity)
     80 (rel nr (+Need +Key +Number))          # Item Number
     81 (rel nm (+IdxFold +String))            # Item Description
     82 (rel sup (+Ref +Link) NIL (+CuSu))     # Supplier
     83 (rel inv (+Number))                    # Inventory
     84 (rel pr (+Ref +Number) NIL 2)          # Price
     85 (rel txt (+Blob))                      # Memo
     86 (rel jpg (+Blob))                      # Picture
     87 
     88 (dm url> (Tab)
     89    (and (may Item) (list "app/item.l" '*ID This)) )
     90 
     91 (dm cnt> ()
     92    (-
     93       (or (: inv) 0)
     94       (sum '((This) (: cnt))
     95          (collect 'itm '+Pos This) ) ) )
     96 
     97 (dm check> ()
     98    (make
     99       (or (: nr) (link ,"No item number"))
    100       (or (: nm) (link ,"No item description")) ) )
    101 
    102 
    103 # Order
    104 (class +Ord +Entity)
    105 (rel nr (+Need +Key +Number))          # Order Number
    106 (rel dat (+Need +Ref +Date))           # Order date
    107 (rel cus (+Ref +Link) NIL (+CuSu))     # Customer
    108 (rel pos (+List +Joint) ord (+Pos))    # Positions
    109 
    110 (dm lose> ()
    111    (mapc 'lose> (: pos))
    112    (super) )
    113 
    114 (dm url> (Tab)
    115    (and (may Order) (list "app/ord.l" '*ID This)) )
    116 
    117 (dm sum> ()
    118    (sum 'sum> (: pos)) )
    119 
    120 (dm check> ()
    121    (make
    122       (or (: nr) (link ,"No order number"))
    123       (or (: dat) (link ,"No order date"))
    124       (if (: cus)
    125          (chain (check> @))
    126          (link ,"No customer") )
    127       (if (: pos)
    128          (chain (mapcan 'check> @))
    129          (link ,"No positions") ) ) )
    130 
    131 
    132 (class +Pos +Entity)
    133 (rel ord (+Dep +Joint)                 # Order
    134    (itm)
    135    pos (+Ord) )
    136 (rel itm (+Ref +Link) NIL (+Item))     # Item
    137 (rel pr (+Number) 2)                   # Price
    138 (rel cnt (+Number))                    # Quantity
    139 
    140 (dm sum> ()
    141    (* (: pr) (: cnt)) )
    142 
    143 (dm check> ()
    144    (make
    145       (if (: itm)
    146          (chain (check> @))
    147          (link ,"Position without item") )
    148       (or (: pr) (link ,"Position without price"))
    149       (or (: cnt) (link ,"Position without quantity")) ) )
    150 
    151 
    152 # Database sizes
    153 (dbs
    154    (3 +Role +User +Sal (+User pw))              # 512 Prevalent objects
    155    (0 +Pos)                                     # A:64 Tiny objects
    156    (1 +Item +Ord)                               # B:128 Small objects
    157    (2 +CuSu)                                    # C:256 Normal objects
    158    (2 (+Role nm) (+User nm) (+Sal nm))          # D:256 Small indexes
    159    (4 (+CuSu nr plz tel mob))                   # E:1024 Normal indexes
    160    (4 (+CuSu nm))                               # F:1024
    161    (4 (+CuSu ort))                              # G:1024
    162    (4 (+Item nr sup pr))                        # H:1024
    163    (4 (+Item nm))                               # I:1024
    164    (4 (+Ord nr dat cus))                        # J:1024
    165    (4 (+Pos itm)) )                             # K:1024
    166 
    167 # vi:et:ts=3:sw=3