Merge pull request #954 from jrogelstad/20438
authorTravis Webb <travis@traviswebb.com>
Mon, 21 Oct 2013 22:43:54 +0000 (15:43 -0700)
committerTravis Webb <travis@traviswebb.com>
Mon, 21 Oct 2013 22:43:54 +0000 (15:43 -0700)
issue #20438: Implement convert quote to work order.

1  2 
enyo-client/application/source/en/strings.js
enyo-client/application/source/views/list.js
enyo-client/database/source/manifest.js

@@@ -328,7 -328,6 +328,7 @@@ strict:true, trailing:true, white:true 
      "_isPrinted": "Printed",
      "_isPublic": "Public",
      "_isSold": "Sold",
 +    "_issueItem": "Issue Item",
      "_isSearchable": "Searchable",
      "_isSystem": "System",
      "_item": "Item",
      "_manager": "Manager",
      "_mainAddress": "Main Address",
      "_manufactured": "Manufactured",
 +    "_manufacturing": "Manufacturing",
      "_map": "Map",
      "_margin": "Margin",
      "_markup": "Markup",
      "_showCompletedOnly": "Show Complete Only",
      "_showExpired": "Show Expired",
      "_showUnReleased": "Show Unreleased",
 +    "_showOnlyTopLevel": "Show Only Top Level",
      "_showInactive": "Show Inactive",
      "_sold": "Sold",
      "_soldRanking": "Sold Ranking",
      "_welcome": "Welcome",
      "_wholesalePrice": "Wholesale Price",
      "_workOrder": "Work Order",
 +    "_workOrders": "Work Orders",
      "_xtuplePostbooks": "PostBooks",
      "_yearExpired": "Expiration Year",
  
      "_createNewCurrency": "Create New Currency",
      "_createReceiptTrans": "Create Receipt Transactions",
      "_createScrapTrans": "Create Scrap Transactions",
+     "_createSOForHoldCustomer": "Create for Customers on Hold",
+     "_createSOForWarnCustomer": "Create for Customers on Warn",
      "_deleteCountSlips": "Delete Count Slips",
      "_deleteCountTags": "Delete Count Tags",
      "_deleteItemMasters": "Delete Item Masters",
      "_convertAccountSalesRep": "Convert this Account to a SalesRep?",
      "_convertAccountTaxAuthority": "Convert this Account to a Tax Authority?",
      "_convertProspect": "Convert this Prospect to a Customer?",
+     "_creditWarn": "This customer is on credit warn.",
+     "_creditHold": "This customer is on credit hold.",
      "_customerExists": "A customer with this number already exists.",
      "_customerOrProspect": "Would you like to create a new Customer or a new Prospect?",
      "_exitPageWarning": "You are about to leave the xTuple application.",
@@@ -1685,16 -1685,14 +1685,14 @@@ trailing:true, white:true, strict: fals
      },
      convertQuote: function (inEvent) {
        var model = inEvent.model,
+         that = this,
          customer = model.get("customer"),
          K = XM.CustomerProspectRelation,
-         that = this,
+         attrs,
  
          // In case we are converting a prospect
          convertToCustomer = function (resp) {
            if (!resp.answer) { return; }
-           var success = function () {
-             this.getValue().convertFromProspect(customer.id);
-           };
  
            that.doWorkspace({
              workspace: "XV.CustomerWorkspace",
                number: customer.get("number"),
                name: customer.get("name")
              },
-             success: success,
+             success: afterCustomerCreated,
              callback: convertToSalesOrder,
              allowNew: false
            });
          },
  
-         // A callback in case we had to convert to a customer first
+         afterCustomerCreated = function () {
+           this.getValue().convertFromProspect(customer.id);
+         },
          convertToSalesOrder = function () {
-           var success = function () {
-               var gridBox = this.$.salesOrderLineItemGridBox;
-               this.getValue().convertFromQuote(model.id, {
-                 success: function () {
-                   // Hack to force grid to refresh. Why doesn't it on its own?
-                   gridBox.valueChanged();
-                   gridBox.setDisabled(false);
-                 }
-               });
-             };
+           XM.SalesOrder.convertFromQuote(model.id, {
+             success: afterQuoteConvertedSuccess
+           });
+         },
  
+         afterQuoteConvertedSuccess = function (resp) {
+           attrs = resp;
            that.doWorkspace({
              workspace: "XV.SalesOrderWorkspace",
-             success: success,
+             success: afterSalesOrderCreated,
              allowNew: false
            });
+         },
+         afterSalesOrderCreated = function () {
+           var value = this.getValue(),
+             gridBox = this.$.salesOrderLineItemGridBox;
+           value.setStatus(XM.Model.BUSY_FETCHING);
+           value.set(attrs);
+           value.revertStatus();
+           //Hack to force grid to refresh. Why doesn't it on its own?
+           gridBox.valueChanged();
+           gridBox.setDisabled(false);
          };
  
+       // Get the process started one way or another
        if (customer.get("status") === K.PROSPECT_STATUS) {
          this.doNotify({
            type: XM.Model.QUESTION,
  
    XV.registerModelList("XM.VendorRelation", "XV.VendorList");
  
 +  // ..........................................................
 +  // WORK ORDER
 +  //
 +
 +  enyo.kind({
 +    name: "XV.WorkOrderList",
 +    kind: "XV.List",
 +    label: "_workOrders".loc(),
 +    collection: "XM.WorkOrderListItemCollection",
 +    parameterWidget: "XV.WorkOrderListParameters",
 +    query: {orderBy: [
 +      {attribute: 'number'}
 +    ]},
 +    components: [
 +      {kind: "XV.ListItem", components: [
 +        {kind: "FittableColumns", components: [
 +          {kind: "XV.ListColumn", components: [
 +            {kind: "XV.ListAttr", attr: "number", isKey: true, fit: true}
 +          ]},
 +          {kind: "XV.ListColumn", classes: "first", components: [
 +            {kind: "FittableColumns", components: [
 +              {kind: "XV.ListAttr", attr: "status",
 +                style: "padding-left: 24px"},
 +              {kind: "XV.ListAttr", attr: "itemSite.item.number", classes: "bold", style: "padding-left: 12px"}
 +            ]},
 +            {kind: "FittableColumns", components: [
 +              {kind: "XV.ListAttr", attr: "itemSite.site.code", style: "padding-left: 12px"},
 +              {kind: "XV.ListAttr", attr: "itemSite.item.description1", classes: "italic"}
 +            ]}
 +          ]},
 +          {kind: "XV.ListColumn", classes: "second", components: [
 +            {kind: "FittableColumns", components: [
 +              {kind: "XV.ListAttr", attr: "dueDate", classes: "right"}
 +            ]}
 +          ]},
 +          {kind: "XV.ListColumn", classes: "last", components: [
 +            {kind: "FittableColumns", components: [
 +              {kind: "XV.ListAttr", attr: "itemSite.item.inventoryUnit.name"},
 +              {kind: "XV.ListAttr", attr: "qtyOrdered"},
 +              {kind: "XV.ListAttr", attr: "qtyReceived"}
 +            ]}
 +          ]}
 +        ]}
 +      ]}
 +    ]
 +  });
 +
 +  XV.registerModelList("XM.WorkOrderListItem", "XV.WorkOrderList");
 +
    enyo.kind({
      name: "XV.NameList",
      kind: "XV.List",
@@@ -1,10 -1,11 +1,12 @@@
  {
    "name": "_application_",
    "databaseScripts": [
 +    "version_check.sql",
      "drop_deprecated.sql",
      "xt/trigger_functions/comment_did_change.sql",
+     "xt/trigger_functions/customer_did_change.sql",
      "xt/trigger_functions/owner_record_did_change.sql",
+     "xt/trigger_functions/sales_order_did_change.sql",
      "xt/trigger_functions/taxtype_record_did_change.sql",
      "xt/trigger_functions/usr_did_change.sql",
      "xt/trigger_functions/usrpref_did_change.sql",
@@@ -29,8 -30,6 +31,8 @@@
      "public/tables/todoitem.sql",
      "public/tables/usrpref.sql",
      "public/tables/usrpriv.sql",
 +    "public/tables/wo.sql",
 +    "public/tables/womatl.sql",
      "xt/functions/add_priv.sql",
      "xt/functions/average_cost.sql",
      "xt/functions/change_password.sql",
      "xt/views/site.sql",
      "xt/views/todoiteminfo.sql",
      "xt/views/usrinfo.sql",
 +    "xt/views/woinfo.sql",
      "xt/tables/usrlite.sql",
      "xm/javascript/account.sql",
      "xm/javascript/address.sql",