def form_valid(self, form): # Lydia min price lydia_min_price = settings_safe_get('LYDIA_MIN_PRICE') if not form.cleaned_data['lydia_min_price']: lydia_min_price.value = '' else: lydia_min_price.value = form.cleaned_data['lydia_min_price'] lydia_min_price.save() # Lydia max price lydia_max_price = settings_safe_get('LYDIA_MAX_PRICE') if not form.cleaned_data['lydia_max_price']: lydia_max_price.value = '' else: lydia_max_price.value = form.cleaned_data['lydia_max_price'] lydia_max_price.save() # Lydia api token lydia_api_token = settings_safe_get('LYDIA_API_TOKEN') lydia_api_token.value = form.cleaned_data['lydia_api_token'] lydia_api_token.save() # Lydia vendor token lydia_vendor_token = settings_safe_get('LYDIA_VENDOR_TOKEN') lydia_vendor_token.value = form.cleaned_data['lydia_vendor_token'] lydia_vendor_token.save() return redirect( reverse('url_global_config', kwargs={'group_name': self.group.name}))
def get_initial(self, **kwargs): initial = super(LydiaConfig, self).get_initial(**kwargs) initial['lydia_min_price'] = settings_safe_get( 'LYDIA_MIN_PRICE').get_value() initial['lydia_max_price'] = settings_safe_get( 'LYDIA_MAX_PRICE').get_value() initial['lydia_api_token'] = settings_safe_get( 'LYDIA_API_TOKEN').get_value() initial['lydia_vendor_token'] = settings_safe_get( 'LYDIA_VENDOR_TOKEN').get_value() return initial
def form_valid(self, form): # balance_threshold_purchase balance_threshold_purchase = settings_safe_get( 'BALANCE_THRESHOLD_PURCHASE') balance_threshold_purchase.value = form.cleaned_data[ 'balance_threshold_purchase'] balance_threshold_purchase.save() """ # balance_threshold_mail_alert balance_threshold_mail_alert = settings_safe_get('BALANCE_THRESHOLD_MAIL_ALERT') if not form.cleaned_data['balance_threshold_mail_alert']: balance_threshold_mail_alert.value = '' else: balance_threshold_mail_alert.value = form.cleaned_data['balance_threshold_mail_alert'] balance_threshold_mail_alert.save() # balance_frequency_mail_alert balance_frequency_mail_alert = settings_safe_get('BALANCE_FREQUENCY_MAIL_ALERT') if not form.cleaned_data['balance_frequency_mail_alert']: balance_frequency_mail_alert.value = '' else: balance_frequency_mail_alert.value = form.cleaned_data['balance_frequency_mail_alert'] balance_frequency_mail_alert.save() """ return redirect( reverse('url_global_config', kwargs={'group_name': self.group.name}))
def get_initial(self, **kwargs): initial = super(BalanceConfig, self).get_initial(**kwargs) initial['balance_threshold_purchase'] = settings_safe_get( 'BALANCE_THRESHOLD_PURCHASE').get_value() #initial['balance_threshold_mail_alert'] = settings_safe_get('BALANCE_THRESHOLD_MAIL_ALERT').get_value() #initial['balance_frequency_mail_alert'] = settings_safe_get('BALANCE_FREQUENCY_MAIL_ALERT').get_value() return initial
def form_valid(self, form): # Margin profit margin_profit = settings_safe_get('MARGIN_PROFIT') margin_profit.value = form.cleaned_data['margin_profit'] margin_profit.save() return redirect( reverse('url_global_config', kwargs={'group_name': self.group.name}))
def form_valid(self, form): # Margin profit center_name = settings_safe_get('CENTER_NAME') center_name.value = form.cleaned_data['center_name'] center_name.save() return redirect( reverse('url_global_config', kwargs={'group_name': self.group.name}))
def get_context_data(self, **kwargs): context = super(GlobalConfig, self).get_context_data(**kwargs) context['center_name'] = settings_safe_get('CENTER_NAME') context['margin_profit'] = settings_safe_get('MARGIN_PROFIT') context['lydia_min_price'] = settings_safe_get('LYDIA_MIN_PRICE') context['lydia_max_price'] = settings_safe_get("LYDIA_MAX_PRICE") context['lydia_api_token'] = settings_safe_get("LYDIA_API_TOKEN") context['lydia_vendor_token'] = settings_safe_get("LYDIA_VENDOR_TOKEN") context['balance_threshold_purchase'] = settings_safe_get( "BALANCE_THRESHOLD_PURCHASE") #context['balance_threshold_mail_alert'] = settings_safe_get("BALANCE_THRESHOLD_MAIL_ALERT") #context['balance_frequency_mail_alert'] = settings_safe_get("BALANCE_FREQUENCY_MAIL_ALERT") return context
def get_automatic_price(self): """ Return the price calculated over the last stockentry concerning the product. If there is no stock entry realisated, return 0. """ try: margin_profit = settings_safe_get('MARGIN_PROFIT').get_value() last_stockentry = self.stockentryproduct_set.order_by( '-stockentry__datetime').first() if last_stockentry is not None: return round( decimal.Decimal( last_stockentry.unit_price() * self.correcting_factor * decimal.Decimal(1 + margin_profit / 100)), 4) else: return 0 except IndexError: return decimal.Decimal(0)
def form_query(self, query): if self.search: query = query.filter( Q(last_name__icontains=self.search) | Q(first_name__icontains=self.search) | Q(surname__icontains=self.search) | Q(username__icontains=self.search)) if self.year and self.year != 'all': query = query.filter(year=self.year) if self.state and self.state != 'all': if self.state == 'negative_balance': query = query.filter(balance__lt=0.0, is_active=True) elif self.state == 'threshold': threshold = settings_safe_get( 'BALANCE_THRESHOLD_PURCHASE').get_value() query = query.filter(balance__lt=threshold, is_active=True) elif self.state == 'unactive': query = query.filter(is_active=False) else: query = query.filter(is_active=True) return query
def get_center_name(): return settings_safe_get("CENTER_NAME").get_value()
def get_initial(self, **kwargs): initial = super(PriceConfig, self).get_initial(**kwargs) initial['margin_profit'] = settings_safe_get( 'MARGIN_PROFIT').get_value() return initial
def get_initial(self, **kwargs): initial = super(CenterConfig, self).get_initial(**kwargs) initial['center_name'] = settings_safe_get('CENTER_NAME').get_value() return initial
def get_form_kwargs(self, **kwargs): kwargs = super(SaleShopModuleInterface, self).get_form_kwargs(**kwargs) kwargs['module'] = self.module kwargs['balance_threshold_purchase'] = settings_safe_get( 'BALANCE_THRESHOLD_PURCHASE') return kwargs
def get_context_data(self, **kwargs): context = super(ProductUpdatePrice, self).get_context_data(**kwargs) context['product'] = self.object context['margin_profit'] = settings_safe_get( 'MARGIN_PROFIT').get_value() return context