Add price confirm prompt when adding unknown item to custorder
optional, per config
This commit is contained in:
		
							parent
							
								
									4247804707
								
							
						
					
					
						commit
						72dda3771e
					
				
					 3 changed files with 105 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -140,7 +140,8 @@
 | 
			
		|||
        Require these fields for new product:
 | 
			
		||||
      </p>
 | 
			
		||||
 | 
			
		||||
      <div style="margin-left: 2rem;">
 | 
			
		||||
      <div class="block"
 | 
			
		||||
           style="margin-left: 2rem;">
 | 
			
		||||
        % for field in pending_product_fields:
 | 
			
		||||
            <b-field>
 | 
			
		||||
              <b-checkbox name="rattail.custorders.unknown_product.fields.${field}.required"
 | 
			
		||||
| 
						 | 
				
			
			@ -153,6 +154,15 @@
 | 
			
		|||
        % endfor
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
      <b-field message="If set, user is always prompted to confirm price when adding new product.">
 | 
			
		||||
        <b-checkbox name="rattail.custorders.unknown_product.always_confirm_price"
 | 
			
		||||
                    v-model="simpleSettings['rattail.custorders.unknown_product.always_confirm_price']"
 | 
			
		||||
                    native-value="true"
 | 
			
		||||
                    @input="settingsNeedSaved = true">
 | 
			
		||||
          Require price confirmation
 | 
			
		||||
        </b-checkbox>
 | 
			
		||||
      </b-field>
 | 
			
		||||
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
  </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -757,6 +757,12 @@
 | 
			
		|||
                            </b-input>
 | 
			
		||||
                          </b-field>
 | 
			
		||||
 | 
			
		||||
                          <b-field label="Gross Margin">
 | 
			
		||||
                            <span class="control">
 | 
			
		||||
                              {{ pendingProductGrossMargin }}
 | 
			
		||||
                            </span>
 | 
			
		||||
                          </b-field>
 | 
			
		||||
 | 
			
		||||
                        </b-field>
 | 
			
		||||
 | 
			
		||||
                        <b-field label="Notes">
 | 
			
		||||
| 
						 | 
				
			
			@ -905,6 +911,52 @@
 | 
			
		|||
              </div>
 | 
			
		||||
            </b-modal>
 | 
			
		||||
 | 
			
		||||
            % if unknown_product_confirm_price:
 | 
			
		||||
                <b-modal has-modal-card
 | 
			
		||||
                         :active.sync="confirmPriceShowDialog">
 | 
			
		||||
                  <div class="modal-card">
 | 
			
		||||
 | 
			
		||||
                    <header class="modal-card-head">
 | 
			
		||||
                      <p class="modal-card-title">Confirm Price</p>
 | 
			
		||||
                    </header>
 | 
			
		||||
 | 
			
		||||
                    <section class="modal-card-body">
 | 
			
		||||
                      <p class="block">
 | 
			
		||||
                        Please confirm the price info before proceeding.
 | 
			
		||||
                      </p>
 | 
			
		||||
 | 
			
		||||
                      <div style="white-space: nowrap;">
 | 
			
		||||
 | 
			
		||||
                        <b-field label="Unit Cost" horizontal>
 | 
			
		||||
                          <span>{{ pendingProduct.unit_cost }}</span>
 | 
			
		||||
                        </b-field>
 | 
			
		||||
 | 
			
		||||
                        <b-field label="Unit Reg. Price" horizontal>
 | 
			
		||||
                          <span>{{ pendingProduct.regular_price_amount }}</span>
 | 
			
		||||
                        </b-field>
 | 
			
		||||
 | 
			
		||||
                        <b-field label="Gross Margin" horizontal>
 | 
			
		||||
                          <span>{{ pendingProductGrossMargin }}</span>
 | 
			
		||||
                        </b-field>
 | 
			
		||||
 | 
			
		||||
                      </div>
 | 
			
		||||
                    </section>
 | 
			
		||||
 | 
			
		||||
                    <footer class="modal-card-foot">
 | 
			
		||||
                      <b-button type="is-primary"
 | 
			
		||||
                                icon-pack="fas"
 | 
			
		||||
                                icon-left="check"
 | 
			
		||||
                                @click="confirmPriceSave()">
 | 
			
		||||
                        Confirm
 | 
			
		||||
                      </b-button>
 | 
			
		||||
                      <b-button @click="confirmPriceCancel()">
 | 
			
		||||
                        Cancel
 | 
			
		||||
                      </b-button>
 | 
			
		||||
                    </footer>
 | 
			
		||||
                  </div>
 | 
			
		||||
                </b-modal>
 | 
			
		||||
            % endif
 | 
			
		||||
 | 
			
		||||
            <tailbone-product-lookup ref="productLookup"
 | 
			
		||||
                                     @canceled="productLookupCanceled"
 | 
			
		||||
                                     @selected="productLookupSelected">
 | 
			
		||||
| 
						 | 
				
			
			@ -1242,6 +1294,9 @@
 | 
			
		|||
                pendingProduct: {},
 | 
			
		||||
                pendingProductRequiredFields: ${json.dumps(pending_product_required_fields)|n},
 | 
			
		||||
                departmentOptions: ${json.dumps(department_options)|n},
 | 
			
		||||
                % if unknown_product_confirm_price:
 | 
			
		||||
                    confirmPriceShowDialog: false,
 | 
			
		||||
                % endif
 | 
			
		||||
 | 
			
		||||
                submittingOrder: false,
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -1428,6 +1483,15 @@
 | 
			
		|||
 | 
			
		||||
            % endif
 | 
			
		||||
 | 
			
		||||
            pendingProductGrossMargin() {
 | 
			
		||||
                let cost = this.pendingProduct.unit_cost
 | 
			
		||||
                let price = this.pendingProduct.regular_price_amount
 | 
			
		||||
                if (cost && price) {
 | 
			
		||||
                    let margin = (price - cost) / price
 | 
			
		||||
                    return (100 * margin).toFixed(2).toString() + " %"
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
            itemDialogSaveDisabled() {
 | 
			
		||||
 | 
			
		||||
                if (this.itemDialogSaving) {
 | 
			
		||||
| 
						 | 
				
			
			@ -2116,7 +2180,7 @@
 | 
			
		|||
                }
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
            itemDialogSave() {
 | 
			
		||||
            itemDialogAttemptSave() {
 | 
			
		||||
                this.itemDialogSaving = true
 | 
			
		||||
 | 
			
		||||
                let params = {
 | 
			
		||||
| 
						 | 
				
			
			@ -2168,6 +2232,30 @@
 | 
			
		|||
                    this.itemDialogSaving = false
 | 
			
		||||
                })
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
            itemDialogSave() {
 | 
			
		||||
 | 
			
		||||
                % if unknown_product_confirm_price:
 | 
			
		||||
                    if (!this.productIsKnown && !this.editingItem) {
 | 
			
		||||
                        this.showingItemDialog = false
 | 
			
		||||
                        this.confirmPriceShowDialog = true
 | 
			
		||||
                        return
 | 
			
		||||
                    }
 | 
			
		||||
                % endif
 | 
			
		||||
 | 
			
		||||
                this.itemDialogAttemptSave()
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
            confirmPriceCancel() {
 | 
			
		||||
                this.confirmPriceShowDialog = false
 | 
			
		||||
                this.showingItemDialog = true
 | 
			
		||||
            },
 | 
			
		||||
 | 
			
		||||
            confirmPriceSave() {
 | 
			
		||||
                this.confirmPriceShowDialog = false
 | 
			
		||||
                this.showingItemDialog = true
 | 
			
		||||
                this.itemDialogAttemptSave()
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -375,6 +375,8 @@ class CustomerOrderView(MasterView):
 | 
			
		|||
            'product_key_label': app.get_product_key_label(),
 | 
			
		||||
            'allow_unknown_product': self.batch_handler.allow_unknown_product(),
 | 
			
		||||
            'pending_product_required_fields': self.get_pending_product_required_fields(),
 | 
			
		||||
            'unknown_product_confirm_price': self.rattail_config.getbool(
 | 
			
		||||
                'rattail.custorders', 'unknown_product.always_confirm_price'),
 | 
			
		||||
            'department_options': self.get_department_options(),
 | 
			
		||||
            'default_uom_choices': self.batch_handler.uom_choices_for_product(None),
 | 
			
		||||
            'default_uom': None,
 | 
			
		||||
| 
						 | 
				
			
			@ -1109,6 +1111,9 @@ class CustomerOrderView(MasterView):
 | 
			
		|||
            {'section': 'rattail.custorders',
 | 
			
		||||
             'option': 'allow_unknown_product',
 | 
			
		||||
             'type': bool},
 | 
			
		||||
            {'section': 'rattail.custorders',
 | 
			
		||||
             'option': 'unknown_product.always_confirm_price',
 | 
			
		||||
             'type': bool},
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
        for field in self.PENDING_PRODUCT_ENTRY_FIELDS:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue