|
| 1 | +SALES_ORDER_LIST = """ |
| 2 | +SELECT |
| 3 | + s.id, s.billToAddress, s.billToCity, s.billToCountryId, s.billToName, |
| 4 | + s.billToStateId, s.billToZip, s.carrierId, s.cost, s.currencyId, |
| 5 | + s.currencyRate, s.customerContact, s.customerId, s.customerPO, |
| 6 | + s.dateCompleted, s.dateCreated AS `CreatedDate`, s.dateFirstShip AS `FirstShipDate`, |
| 7 | + s.dateIssued AS `IssuedDate`, s.dateLastModified, s.dateRevision, s.fobPointId, |
| 8 | + s.locationGroupId, s.note, s.num AS `Number`, s.paymentTermsId, |
| 9 | + s.qbClassId, s.registerID, s.salesman, s.salesmanId, s.salesmanInitials, |
| 10 | + s.shipTermsId, s.shipToAddress, s.shipToCity, s.shipToCountryId, s.shipToName, |
| 11 | + s.shipToStateId, s.shipToZip, s.statusId, s.taxRate, s.taxRateId, s.taxRateName, |
| 12 | + s.totalIncludesTax, s.totalPrice, s.totalTax, s.typeId, s.url, s.vendorPO, |
| 13 | + s.priorityId, c.name AS `Carrier`, ss.name AS status, f.name AS fob, |
| 14 | + st.name AS ShippingTerms, qb.name AS QuickBooksClassName, |
| 15 | + cu.name AS CustomerName, pt.name AS PaymentTerms, |
| 16 | + lg.name AS LocationGroup, cur.code AS CurrencyName |
| 17 | +FROM |
| 18 | + so s |
| 19 | +LEFT JOIN Carrier c ON s.carrierId = c.id |
| 20 | +LEFT JOIN sostatus ss ON s.statusId = ss.id |
| 21 | +LEFT JOIN fobpoint f ON s.fobpointid = f.id |
| 22 | +LEFT JOIN shipterms st ON s.shiptermsid = st.id |
| 23 | +LEFT JOIN qbclass qb ON s.qbclassid = qb.id |
| 24 | +LEFT JOIN customer cu ON s.customerid = cu.id |
| 25 | +LEFT JOIN paymentterms pt ON s.paymenttermsid = pt.id |
| 26 | +LEFT JOIN locationgroup lg ON s.locationgroupid = lg.id |
| 27 | +LEFT JOIN currency cur ON s.currencyid = cur.id |
| 28 | +""" |
| 29 | + |
| 30 | +SALES_ORDER_ITEMS = """ |
| 31 | +SELECT |
| 32 | + si.ID, si.adjustamount AS AdjustmentAmount, si.AdjustPercentage, si.CustomerPartNum, |
| 33 | + si.DateLastFulfillment, si.DateLastModified, si.DateScheduledFulfillment, |
| 34 | + si.Description, si.ExchangeSOLineItem, si.ItemAdjustID, |
| 35 | + si.productNum AS ProductNumber, si.qtytofulfill AS Quantity, si.QtyFulfilled, |
| 36 | + si.QtyPicked, si.revLevel AS RevisionLevel, si.ShowItemFlag, si.SOID, |
| 37 | + si.soLineItem AS LineNumber, si.TaxableFlag, si.TotalPrice, si.TotalCost, |
| 38 | + it.name AS ItemType, p.price AS ProductPrice, qb.name AS QuickBooksClassName, |
| 39 | + sis.name AS Status, u.code AS UOMCode |
| 40 | +FROM soitem si |
| 41 | +LEFT JOIN soitemtype it ON si.typeid = it.id |
| 42 | +LEFT JOIN product p ON si.productId = p.id |
| 43 | +LEFT JOIN qbclass qb ON si.qbclassid = qb.id |
| 44 | +LEFT JOIN soitemstatus sis ON si.statusId = sis.id |
| 45 | +LEFT JOIN uom u ON si.uomid = u.id |
| 46 | +WHERE si.soid = {sales_order_id} |
| 47 | +ORDER BY LineNumber ASC |
| 48 | +""" |
| 49 | + |
| 50 | +PRICING_RULES_SQL = ( |
| 51 | + "SELECT p.id, p.isactive, product.num, " |
| 52 | + "p.patypeid, p.papercent, p.pabaseamounttypeid, p.paamount, " |
| 53 | + "p.customerincltypeid, p.customerinclid, p.datelastmodified " |
| 54 | + "from pricingrule p INNER JOIN product on p.productinclid = product.id " |
| 55 | + "where p.productincltypeid = 2 and " |
| 56 | + "p.customerincltypeid in (1, 2)" |
| 57 | +) |
| 58 | + |
| 59 | + |
| 60 | +CUSTOMER_GROUP_PRICING_RULES_SQL = ( |
| 61 | + "SELECT p.id, p.isactive, product.num, p.patypeid, p.papercent, " |
| 62 | + "p.pabaseamounttypeid, p.paamount, p.customerincltypeid, p.datelastmodified, " |
| 63 | + "p.customerinclid, c.id as customerid, ag.name as accountgroupname, " |
| 64 | + "c.name as customername " |
| 65 | + "FROM pricingrule p " |
| 66 | + "INNER JOIN product ON p.productinclid = product.id " |
| 67 | + "INNER JOIN accountgroup ag ON p.customerinclid = ag.id " |
| 68 | + "INNER JOIN accountgrouprelation agr ON agr.groupid = ag.id " |
| 69 | + "INNER JOIN customer c ON agr.accountid = c.accountid " |
| 70 | + "WHERE p.productincltypeid = 2 AND p.customerincltypeid = 3" |
| 71 | +) |
| 72 | + |
| 73 | +# https://www.fishbowlinventory.com/files/databasedictionary/2017/tables/product.html |
| 74 | +PRODUCTS_SQL = """ |
| 75 | +SELECT |
| 76 | + P.*, |
| 77 | + PART.STDCOST AS StandardCost, |
| 78 | + PART.TYPEID as TypeID |
| 79 | + {ci_fields} |
| 80 | +FROM PRODUCT P |
| 81 | +INNER JOIN PART ON P.PARTID = PART.ID |
| 82 | +{custom_joins} |
| 83 | +""" |
| 84 | + |
| 85 | +# https://www.fishbowlinventory.com/files/databasedictionary/2017/tables/part.html |
| 86 | +PARTS_SQL = "SELECT * FROM Part" |
| 87 | + |
| 88 | + |
| 89 | +SERIAL_NUMBER_SQL = ( |
| 90 | + "SELECT sn.id, sn.serialId, sn.serialNum, p.num as PartNum, " |
| 91 | + "t.dateCreated as DateCreated, t.dateLastModified as DateLastModified " |
| 92 | + "FROM serialnum sn " |
| 93 | + "LEFT JOIN serial s ON s.id = sn.serialId " |
| 94 | + "LEFT JOIN tag t on t.id = s.tagId " |
| 95 | + "LEFT JOIN part p on t.partId = p.id" |
| 96 | +) |
| 97 | + |
| 98 | + |
| 99 | +USERS_SQL = "SELECT id, email, firstName, lastname, phone, username FROM sysuser" |
0 commit comments