def get_connection_info(self): from django.conf import settings import lucterios.CORE import os LucteriosSession.clean_anonymous() info_cnx = {} info_cnx['TITLE'] = six.text_type(settings.APPLIS_NAME) info_cnx['SUBTITLE'] = settings.APPLIS_SUBTITLE() info_cnx['VERSION'] = six.text_type(settings.APPLIS_VERSION) info_cnx['SERVERVERSION'] = six.text_type(lucterios.CORE.__version__) info_cnx['COPYRIGHT'] = six.text_type(settings.APPLIS_COPYRIGHT) info_cnx['LOGONAME'] = settings.APPLIS_LOGO.decode() info_cnx['BACKGROUND'] = settings.APPLIS_BACKGROUND.decode() info_cnx['STYLE'] = settings.APPLIS_STYLE.decode() info_cnx['SUPPORT_EMAIL'] = six.text_type(settings.APPLI_EMAIL) info_cnx['SUPPORT_HTML'] = six.text_type(settings.APPLI_SUPPORT()) info_cnx['INFO_SERVER'] = get_info_server() setting_module_name = os.getenv("DJANGO_SETTINGS_MODULE", "???.???") info_cnx['INSTANCE'] = setting_module_name.split('.')[0] info_cnx['MESSAGE_BEFORE'] = Params.getvalue("CORE-MessageBefore") info_cnx['LANGUAGE'] = self.language info_cnx['MODE'] = six.text_type(Params.getvalue("CORE-connectmode")) if self.request.user.is_authenticated: info_cnx['LOGIN'] = self.request.user.username info_cnx['REALNAME'] = "%s %s" % (self.request.user.first_name, self.request.user.last_name) info_cnx['EMAIL'] = self.request.user.email else: info_cnx['LOGIN'] = '' info_cnx['REALNAME'] = '' info_cnx['EMAIL'] = '' self.responsejson['connexion'] = info_cnx
def conf_wizard_member(wizard_ident, xfer): if isinstance(wizard_ident, list) and (xfer is None): wizard_ident.append(("member_season", 11)) wizard_ident.append(("member_subscriptiontype", 12)) wizard_ident.append(("member_category", 13)) wizard_ident.append(("member_params", 14)) elif (xfer is not None) and (wizard_ident == "member_season"): xfer.add_title(_("Diacamma member"), _('Season'), _('Configuration of season')) xfer.fill_grid(5, Season, "season", Season.objects.all()) elif (xfer is not None) and (wizard_ident == "member_subscriptiontype"): xfer.add_title(_("Diacamma member"), _('Subscriptions'), _('Configuration of subscription')) xfer.fill_grid(15, SubscriptionType, "subscriptiontype", SubscriptionType.objects.all()) xfer.get_components("subscriptiontype").colspan = 6 fill_params(xfer, ["member-subscription-mode", "member-subscription-message"], True) elif (xfer is not None) and (wizard_ident == "member_category"): xfer.add_title(_("Diacamma member"), _("Categories"), _('Configuration of categories')) xfer.new_tab(_('Parameters')) fill_params(xfer, ["member-team-enable", "member-team-text", "member-activite-enable", "member-activite-text", "member-age-enable"], True) if Params.getvalue("member-age-enable") == 1: xfer.new_tab(_('Age')) xfer.fill_grid(1, Age, "age", Age.objects.all()) if Params.getvalue("member-team-enable") == 1: xfer.new_tab(Params.getvalue("member-team-text")) xfer.fill_grid(1, Team, "team", Team.objects.all()) if Params.getvalue("member-activite-enable") == 1: xfer.new_tab(Params.getvalue("member-activite-text")) xfer.fill_grid(1, Activity, "activity", Activity.objects.all()) elif (xfer is not None) and (wizard_ident == "member_params"): xfer.add_title(_("Diacamma member"), _('Parameters'), _('Configuration of main parameters')) fill_params(xfer, ["member-licence-enabled", "member-filter-genre", "member-numero", "member-birth", "member-connection"], True)
def before_save(self, xfer): self.item.vta_rate = 0 if (Params.getvalue("invoice-vat-mode") != 0) and (self.item.article is not None) and (self.item.article.vat is not None): self.item.vta_rate = float(self.item.article.vat.rate / 100) if Params.getvalue("invoice-vat-mode") == 2: self.item.vta_rate = -1 * self.item.vta_rate return
def show(self, xfer): if xfer.item.cost_accounting is None: xfer.remove_component("cost_accounting") xfer.remove_component("lbl_cost_accounting") xfer.params['new_account'] = Params.getvalue('invoice-account-third') xfer.move(0, 0, 1) lbl = XferCompLabelForm('title') lbl.set_location(1, 0, 4) lbl.set_value_as_title(get_value_if_choices( self.item.bill_type, self.item.get_field_by_name('bill_type'))) xfer.add_component(lbl) details = xfer.get_components('detail') if Params.getvalue("invoice-vat-mode") != 0: if Params.getvalue("invoice-vat-mode") == 1: details.headers[2] = XferCompHeader(details.headers[2].name, _( 'price excl. taxes'), details.headers[2].type, details.headers[2].orderable) details.headers[6] = XferCompHeader(details.headers[6].name, _( 'total excl. taxes'), details.headers[6].type, details.headers[6].orderable) elif Params.getvalue("invoice-vat-mode") == 2: details.headers[2] = XferCompHeader(details.headers[2].name, _( 'price incl. taxes'), details.headers[2].type, details.headers[2].orderable) details.headers[6] = XferCompHeader(details.headers[6].name, _( 'total incl. taxes'), details.headers[6].type, details.headers[6].orderable) xfer.get_components('lbl_total_excltax').set_value_as_name( _('total excl. taxes')) xfer.filltab_from_model(1, xfer.get_max_row() + 1, True, [((_('VTA sum'), 'vta_sum'), (_('total incl. taxes'), 'total_incltax'))]) if self.item.status == 0: SupportingEditor.show_third(self, xfer, 'invoice.add_bill') else: SupportingEditor.show_third_ex(self, xfer) details.actions = [] if self.item.bill_type != 0: SupportingEditor.show(self, xfer) return
def get_show_fields(cls): fields = [ "adherent", "date", ((Params.getvalue("event-degree-text"), 'degree'),)] if Params.getvalue("event-subdegree-enable") == 1: fields.append( ((Params.getvalue("event-subdegree-text"), 'subdegree'),)) return fields
def _generate_account_callfunds_by_type(self, new_entry, type_call, calldetails): detail_account_filter = None if type_call == 0: detail_account_filter = Params.getvalue( "condominium-current-revenue-account") if type_call == 1: detail_account_filter = Params.getvalue( "condominium-exceptional-revenue-account") if type_call == 2: detail_account_filter = Params.getvalue( "condominium-advance-revenue-account") if type_call == 4: detail_account_filter = Params.getvalue( "condominium-fundforworks-revenue-account") detail_account = ChartsAccount.get_account(detail_account_filter, new_entry.year) if detail_account is None: raise LucteriosException(IMPORTANT, _("incorrect account for call of found")) total = 0 for calldetail in calldetails: EntryLineAccount.objects.create( account=detail_account, amount=calldetail.price, entry=new_entry, costaccounting=calldetail.set.current_cost_accounting) total += calldetail.price calldetail.entry = new_entry calldetail.save() return total
def total(self): if Params.getvalue("invoice-vat-mode") == 2: return self.total_incltax elif Params.getvalue("invoice-vat-mode") == 1: return self.total_excltax else: return format_devise(self.get_total(), 5)
def generate_revenue_for_expense(self, expense, is_asset, fiscal_year): if Params.getvalue("condominium-old-accounting"): for detail in expense.expensedetail_set.all(): self._generate_revenue_for_expense_oldaccounting(detail, is_asset, fiscal_year) elif len(expense.expensedetail_set.filter(set__type_load=1)) > 0: total = 0 revenue_code = Params.getvalue("condominium-exceptional-revenue-account") revenue_account = ChartsAccount.get_account(revenue_code, fiscal_year) if revenue_account is None: raise LucteriosException(IMPORTANT, _("code account %s unknown!") % revenue_code) reserve_code = Params.getvalue("condominium-exceptional-reserve-account") reserve_account = ChartsAccount.get_account(reserve_code, fiscal_year) if revenue_account is None: raise LucteriosException(IMPORTANT, _("code account %s unknown!") % reserve_code) new_entry = EntryAccount.objects.create(year=fiscal_year, date_value=expense.expense.date, designation=expense.__str__(), journal=Journal.objects.get(id=3)) for detail in expense.expensedetail_set.all(): detail.generate_ratio(is_asset) if detail.set.type_load == 1: cost_accounting = detail.set.current_cost_accounting price = currency_round(detail.price) EntryLineAccount.objects.create(account=revenue_account, amount=is_asset * price, entry=new_entry, costaccounting=cost_accounting) total += price detail.entry = new_entry detail.save() EntryLineAccount.objects.create(account=reserve_account, amount=-1 * is_asset * total, entry=new_entry) no_change, debit_rest, credit_rest = new_entry.serial_control(new_entry.get_serial()) if not no_change or (abs(debit_rest) > 0.001) or (abs(credit_rest) > 0.001): raise LucteriosException(GRAVE, _("Error in accounting generator!") + "{[br/]} no_change=%s debit_rest=%.3f credit_rest=%.3f" % (no_change, debit_rest, credit_rest))
def will_mail_send(): from lucterios.CORE.parameters import Params from lucterios.contacts.models import LegalEntity sender_email = LegalEntity.objects.get(id=1).email return (sender_email != '') and ( (Params.getvalue('mailing-smtpserver') != '') or (Params.getvalue('mailing-smtpsecurity') == 3))
def __str__(self): val = [] if Params.getvalue("member-team-enable") and (self.team is not None): val.append(six.text_type(self.team)) if Params.getvalue("member-activite-enable") and (self.activity is not None): val.append("[%s]" % six.text_type(self.activity)) if Params.getvalue("member-licence-enabled") and (self.value is not None): val.append(self.value) return " ".join(val)
def get_default_fields(cls): fields = ["contact", (_('subscript?'), 'is_subscripter'), (_('current'), 'current_degree'), (_( '%s result') % Params.getvalue("event-degree-text"), 'degree_result_simple')] if Params.getvalue("event-subdegree-enable") == 1: fields.append( (_('%s result') % Params.getvalue("event-subdegree-text"), 'subdegree_result')) fields.append((_('article'), 'article.ref_price')) fields.append('comment') return fields
def fillresponse_body(self): if Params.getvalue("event-degree-enable") == 1: self.new_tab(Params.getvalue("event-degree-text")) self.fill_grid(0, DegreeType, "degreetype", DegreeType.objects.all()) if Params.getvalue("event-subdegree-enable") == 1: self.new_tab(Params.getvalue("event-subdegree-text")) self.fill_grid(0, SubDegreeType, "subdegreetype", SubDegreeType.objects.all())
def get_show_fields(cls): fields = [ "adherent", "date", ((Params.getvalue("event-degree-text"), 'degree'), ) ] if Params.getvalue("event-subdegree-enable") == 1: fields.append( ((Params.getvalue("event-subdegree-text"), 'subdegree'), )) return fields
def get_show_fields(cls): fields = [] if Params.getvalue("member-team-enable"): fields.append(((Params.getvalue("member-team-text"), "team"),)) if Params.getvalue("member-activite-enable"): fields.append( ((Params.getvalue("member-activite-text"), "activity"),)) if Params.getvalue("member-licence-enabled"): fields.append("value") return fields
def fillresponse(self): XferListEditor.fillresponse(self) grid = self.get_components(self.field_id) grid.colspan = 3 if Params.getvalue("invoice-vat-mode") == 1: grid.headers[5] = XferCompHeader(grid.headers[5].name, _('total excl. taxes'), grid.headers[5].type, grid.headers[5].orderable) elif Params.getvalue("invoice-vat-mode") == 2: grid.headers[5] = XferCompHeader(grid.headers[5].name, _('total incl. taxes'), grid.headers[5].type, grid.headers[5].orderable)
def get_edit_fields(cls): field = [] if Params.getvalue("member-activite-enable"): field.append( ((Params.getvalue("member-activite-text"), "activity"), )) field.extend([ 'status', 'event_type', 'date', 'date_end', 'default_article', 'default_article_nomember', 'comment' ]) return field
def before_save(self, xfer): accounts = self.item.third.accountthird_set.filter(code__regex=current_system_account().get_societary_mask()) if len(accounts) == 0: if Params.getvalue("condominium-old-accounting"): AccountThird.objects.create(third=self.item.third, code=correct_accounting_code(Params.getvalue("condominium-default-owner-account"))) else: for num_account in range(1, 5): AccountThird.objects.create(third=self.item.third, code=correct_accounting_code(Params.getvalue("condominium-default-owner-account%d" % num_account))) return SupportingEditor.before_save(self, xfer)
def fillresponse_body(self): if Params.getvalue("member-age-enable") == 1: self.new_tab(_('Age')) self.fill_grid(0, Age, "age", Age.objects.all()) if Params.getvalue("member-team-enable") == 1: self.new_tab(Params.getvalue("member-team-text")) self.fill_grid(0, Team, "team", Team.objects.all()) if Params.getvalue("member-activite-enable") == 1: self.new_tab(Params.getvalue("member-activite-text")) self.fill_grid(0, Activity, "activity", Activity.objects.all())
def conf_wizard_member(wizard_ident, xfer): if isinstance(wizard_ident, list) and (xfer is None): wizard_ident.append(("member_season", 11)) wizard_ident.append(("member_subscriptiontype", 12)) wizard_ident.append(("member_category", 13)) wizard_ident.append(("member_params", 14)) elif (xfer is not None) and (wizard_ident == "member_season"): xfer.add_title(_("Diacamma member"), _('Season'), _('Configuration of season')) xfer.fill_grid(5, Season, "season", Season.objects.all()) elif (xfer is not None) and (wizard_ident == "member_subscriptiontype"): xfer.add_title(_("Diacamma member"), _('Subscriptions'), _('Configuration of subscription')) xfer.fill_grid(15, SubscriptionType, "subscriptiontype", SubscriptionType.objects.all()) xfer.get_components("subscriptiontype").colspan = 6 fill_params(xfer, [ "member-subscription-mode", "member-connection", "member-family-type", "member-tax-receipt", "member-subscription-message" ], True) elif (xfer is not None) and (wizard_ident == "member_category"): xfer.add_title(_("Diacamma member"), _("Categories"), _('Configuration of categories')) xfer.new_tab(_('Parameters')) fill_params(xfer, [ "member-team-enable", "member-team-text", "member-activite-enable", "member-activite-text", "member-age-enable" ], True) if Params.getvalue("member-age-enable") == 1: xfer.new_tab(_('Age')) xfer.fill_grid(1, Age, "age", Age.objects.all()) if Params.getvalue("member-team-enable") == 1: xfer.new_tab(Params.getvalue("member-team-text")) xfer.fill_grid(1, Team, "team", Team.objects.all()) if Params.getvalue("member-activite-enable") == 1: xfer.new_tab(Params.getvalue("member-activite-text")) xfer.fill_grid(1, Activity, "activity", Activity.objects.all()) grid = xfer.get_components("activity") if hasattr(settings, "DIACAMMA_MAXACTIVITY") and (getattr( settings, "DIACAMMA_MAXACTIVITY") <= grid.nb_lines): lbl = XferCompLabelForm("limit_activity") lbl.set_color('red') lbl.set_value_as_headername( _('You have the maximum of activities!')) lbl.set_location(grid.col, xfer.get_max_row() + 1) xfer.add_component(lbl) grid.delete_action("diacamma.member/activityAddModify", True) elif (xfer is not None) and (wizard_ident == "member_params"): xfer.add_title(_("Diacamma member"), _('Parameters'), _('Configuration of main parameters')) fill_params(xfer, [ "member-licence-enabled", "member-filter-genre", "member-numero", "member-birth", "member-fields" ], True)
def generate_entry(self): if self.bill_type == 2: is_bill = -1 else: is_bill = 1 third_account = self.get_third_account( current_system_account().get_customer_mask(), self.fiscal_year) self.entry = EntryAccount.objects.create( year=self.fiscal_year, date_value=self.date, designation=self.__str__(), journal=Journal.objects.get(id=3), costaccounting=self.cost_accounting) EntryLineAccount.objects.create( account=third_account, amount=is_bill * self.get_total_incltax(), third=self.third, entry=self.entry) remise_total = 0 detail_list = {} for detail in self.detail_set.all(): if detail.article is not None: detail_code = detail.article.sell_account else: detail_code = Params.getvalue("invoice-default-sell-account") detail_account = ChartsAccount.get_account( detail_code, self.fiscal_year) if detail_account is None: raise LucteriosException( IMPORTANT, _("article has code account unknown!")) if detail_account.id not in detail_list.keys(): detail_list[detail_account.id] = [detail_account, 0] detail_list[detail_account.id][ 1] += detail.get_total_excltax() + detail.get_reduce_excltax() remise_total += detail.get_reduce_excltax() if remise_total > 0.001: remise_code = Params.getvalue("invoice-reduce-account") remise_account = ChartsAccount.get_account( remise_code, self.fiscal_year) if remise_account is None: raise LucteriosException( IMPORTANT, _("reduce-account is not defined!")) EntryLineAccount.objects.create( account=remise_account, amount=-1 * is_bill * remise_total, entry=self.entry) for detail_item in detail_list.values(): EntryLineAccount.objects.create( account=detail_item[0], amount=is_bill * detail_item[1], entry=self.entry) if self.get_vta_sum() > 0.001: vta_code = Params.getvalue("invoice-vatsell-account") vta_account = ChartsAccount.get_account( vta_code, self.fiscal_year) if vta_account is None: raise LucteriosException( IMPORTANT, _("vta-account is not defined!")) EntryLineAccount.objects.create( account=vta_account, amount=is_bill * self.get_vta_sum(), entry=self.entry) no_change, debit_rest, credit_rest = self.entry.serial_control( self.entry.get_serial()) if not no_change or (abs(debit_rest) > 0.001) or (abs(credit_rest) > 0.001): raise LucteriosException( GRAVE, _("Error in accounting generator!") + "{[br/]} no_change=%s debit_rest=%.3f credit_rest=%.3f" % (no_change, debit_rest, credit_rest))
def edit(self, xfer): if xfer.item.id is None: new_account = [] if Params.getvalue("condominium-old-accounting"): new_account.append( Params.getvalue("condominium-default-owner-account")) else: for num_account in LIST_DEFAULT_ACCOUNTS: new_account.append( Params.getvalue("condominium-default-owner-account%d" % num_account)) sel = XferCompSelect('third') sel.needed = True sel.description = _('third') sel.set_location(1, 0) owner_third_ids = [] for owner in Owner.objects.all(): owner_third_ids.append(owner.third_id) items = Third.objects.filter( accountthird__code__regex=current_system_account( ).get_societary_mask()).exclude( id__in=owner_third_ids).distinct() items = sorted(items, key=lambda t: str(t)) sel.set_select_query(items) xfer.add_component(sel) btn = XferCompButton('add_third') btn.set_location(3, 0) btn.set_is_mini(True) btn.set_action(xfer.request, ActionsManage.get_action_url( 'accounting.Third', 'Add', xfer), close=CLOSE_NO, modal=FORMTYPE_MODAL, params={'new_account': ';'.join(new_account)}) xfer.add_component(btn) xfer.filltab_from_model(1, xfer.get_max_row() + 1, False, ["information"]) else: old_item = xfer.item xfer.item = old_item.third.contact.get_final_child() xfer.filltab_from_model(1, 0, False, xfer.item.get_edit_fields()) CustomField.edit_fields(xfer, 1) xfer.item = old_item.third.get_final_child() xfer.filltab_from_model(1, xfer.get_max_row() + 1, False, xfer.item.get_edit_fields()) CustomField.edit_fields(xfer, 1) xfer.item = old_item xfer.filltab_from_model(1, xfer.get_max_row() + 1, False, ["information"])
def get_show_fields(cls): fields = Individual.get_show_fields() keys = list(fields.keys()) if Params.getvalue("member-numero"): fields[keys[0]][0] = ("num", fields[keys[0]][0]) if Params.getvalue("member-birth"): fields[keys[0]].insert(-1, ("birthday", "birthplace")) fields[keys[0]].insert(-1, ((_("age category"), "age_category"),)) fields[_('002@Subscription')] = ['subscription_set'] fields[''] = [((_("reference date"), "dateref"),)] return fields
def get_import_fields(cls): fields = super(Individual, cls).get_import_fields() fields.append(('subscriptiontype', _('subscription type'))) if Params.getvalue("member-team-enable"): fields.append(('team', Params.getvalue("member-team-text"))) if Params.getvalue("member-activite-enable"): fields.append( ('activity', Params.getvalue("member-activite-text"))) if Params.getvalue("member-licence-enabled"): fields.append(('value', _('license #'))) return fields
def conf_wizard_event(wizard_ident, xfer): if isinstance(wizard_ident, list) and (xfer is None): wizard_ident.append(("event_degree", 60)) elif (xfer is not None) and (wizard_ident == "event_degree"): xfer.add_title(_("Diacamma event"), _("Degrees"), _('Configuration of degree parameters')) xfer.new_tab(_('Parameters')) fill_params(xfer) xfer.new_tab(Params.getvalue("event-degree-text")) xfer.fill_grid(1, DegreeType, "degreetype", DegreeType.objects.all()) if Params.getvalue("event-subdegree-enable") == 1: xfer.new_tab(Params.getvalue("event-subdegree-text")) xfer.fill_grid(1, SubDegreeType, "subdegreetype", SubDegreeType.objects.all())
def test_scheduler(self): six.print_('-- Begin test_scheduler --') self.factory.xfer = SessionList() self.calljson('/CORE/sessionList', {}, False) self.assert_observer('core.custom', 'CORE', 'sessionList') self.assert_grid_equal('tasks', { "name": "nom", "trigger": "déclencheur", "nextdate": "date suivante" }, 0) self.calljson('/lucterios.dummy/addSchedulerTask', {}) self.assert_observer('core.acknowledge', 'lucterios.dummy', 'addSchedulerTask') value = Params.getvalue('dummy-value') self.assertEqual(value, "") self.factory.xfer = SessionList() self.calljson('/CORE/sessionList', {}, False) self.assert_observer('core.custom', 'CORE', 'sessionList') self.assert_count_equal('tasks', 1) self.assert_json_equal('', 'tasks/@0/name', 'Run simple action') self.assert_json_equal('', 'tasks/@0/trigger', 'interval[0:00:10]') self.assert_json_equal('', 'tasks/@0/nextdate', datetime.now().strftime('%Y-%m-%dT%H:'), True) sleep(6 * 10 + .2) value = Params.getvalue('dummy-value') self.assertEqual(len(value.split('{[br/]}')), 5) self.factory.xfer = SessionList() self.calljson('/CORE/sessionList', {}, False) self.assert_observer('core.custom', 'CORE', 'sessionList') self.assert_count_equal('tasks', 1) self.assert_json_equal('', 'tasks/@0/name', 'Run simple action') self.assert_json_equal( '', 'tasks/@0/trigger', 'date[' + datetime.now().strftime('%Y-%m-%d %H:'), True) self.assert_json_equal('', 'tasks/@0/nextdate', datetime.now().strftime('%Y-%m-%dT%H:'), True) sleep(10 + .2) value = Params.getvalue('dummy-value') self.assertEqual(value, "") self.factory.xfer = SessionList() self.calljson('/CORE/sessionList', {}, False) self.assert_observer('core.custom', 'CORE', 'sessionList') self.assert_count_equal('tasks', 0) six.print_('-- End test_scheduler --')
def format_devise(amount, mode): # mode 0 25.45 => 25,45€ / -25.45 => # mode 1 25.45 => Credit 25,45€ / -25.45 => Debit 25,45€ # mode 2 25.45 => {[font color="green"]}Credit 25,45€{[/font]} / # -25.45 => {[font color="blue"]}Debit 25,45€{[/font]} # mode 3 25.45 => 25,45 / -25.45 => -25.45 # mode 4 25.45 => 25,45€ / -25.45 => 25.45€ # mode 5 25.45 => 25,45€ / -25.45 => -25.45€ # mode 6 25.45 => {[font color="green"]}25,45€{[/font]} / # -25.45 => {[font color="blue"]}25,45€{[/font]} from decimal import InvalidOperation result = '' currency_short = Params.getvalue("accounting-devise") currency_decimal = Params.getvalue("accounting-devise-prec") currency_format = "%%0.%df" % currency_decimal currency_epsilon = pow(10, -1 * currency_decimal - 1) try: if (amount is None) or (abs(amount) < currency_epsilon): amount = 0 except InvalidOperation: return "???" if (abs(amount) >= currency_epsilon) or (mode in (1, 2, 6)): if amount >= 0: if mode in (2, 6): result = '{[font color="green"]}' if (mode == 1) or (mode == 2): result = '%s%s: ' % (result, _('Credit')) else: if mode in (2, 6): result = result + '{[font color="blue"]}' if (mode == 1) or (mode == 2): result = '%s%s: ' % (result, _('Debit')) if mode == 3: result = currency_format % amount elif mode == 0: if amount >= currency_epsilon: result = currency_format % abs(amount) + currency_short elif mode == 6: if abs(amount) >= currency_epsilon: result = result + currency_format % abs(amount) + currency_short else: if mode < 5: amount_text = currency_format % abs(amount) else: amount_text = currency_format % amount result = result + amount_text + currency_short if mode in (2, 6): result = result + '{[/font]}' return result
def get_default_fields(cls): fields = [ "contact", 'is_subscripter', 'current_degree', (_('%s result') % Params.getvalue("event-degree-text"), 'degree_result_simple') ] if Params.getvalue("event-subdegree-enable") == 1: fields.append( (_('%s result') % Params.getvalue("event-subdegree-text"), 'subdegree_result')) fields.append('article_ref_price') fields.append('comment') return fields
def fillresponse(self): XferListEditor.fillresponse(self) self.item.editor.add_email_selector( self, 0, self.get_max_row() + 1, 10) self.get_components('title').colspan = 10 self.get_components(self.field_id).colspan = 10 self.get_components('nb_adherent').colspan = 10 self.get_components(self.field_id).add_action(self.request, AdherentSubscription.get_action(_("Subscription"), ""), unique=SELECT_SINGLE, close=CLOSE_NO) if Params.getvalue("member-licence-enabled"): self.get_components(self.field_id).add_action(self.request, AdherentLicense.get_action(_("License"), ""), unique=SELECT_SINGLE, close=CLOSE_NO) if Params.getvalue("member-subscription-mode") == 1: self.add_action(SubscriptionModerate.get_action(_("Moderation"), "images/up.png"), pos_act=0, close=CLOSE_NO)
def get_show_fields(cls): field = [('date', 'date_end')] if Params.getvalue("member-activite-enable"): field.append(('status', (Params.getvalue("member-activite-text"), "activity"))) else: field.append(('status', )) field.extend([ 'organizer_set', 'participant_set', ('comment', ), ((_('default article (member)'), 'default_article.ref_price'), (_('default article (no member)'), 'default_article_nomember.ref_price')) ]) return field
def paramchange_payoff(params): if 'accounting-sizecode' in params: for bank in BankAccount.objects.all(): if bank.account_code != correct_accounting_code(bank.account_code): bank.account_code = correct_accounting_code(bank.account_code) bank.save() if ('payoff-cash-account' in params) or ('accounting-sizecode' in params): Parameter.change_value( 'payoff-cash-account', correct_accounting_code(Params.getvalue('payoff-cash-account'))) if ('payoff-bankcharges-account' in params) or ('accounting-sizecode' in params): pvalue = Params.getvalue('payoff-bankcharges-account') if pvalue != '': Parameter.change_value( 'payoff-bankcharges-account', correct_accounting_code(pvalue)) Params.clear()
def fillresponse_body(self): if Params.getvalue("member-age-enable") == 1: self.new_tab(_('Age')) self.fill_grid(0, Age, "age", Age.objects.all()) if Params.getvalue("member-team-enable") == 1: show_only_enabled_team = self.getparam('show_only_enabled_team', True) self.new_tab(Params.getvalue("member-team-text")) if show_only_enabled_team: team_list = Team.objects.filter(unactive=False) else: team_list = Team.objects.all() self.fill_grid(0, Team, "team", team_list) if show_only_enabled_team: grid = self.get_components('team') grid.delete_header('unactive') check = XferCompCheck('show_only_enabled_team') check.set_location(0, 2) check.set_value(show_only_enabled_team) check.description = _('show only enabled team') check.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(check) if Params.getvalue("member-activite-enable") == 1: self.new_tab(Params.getvalue("member-activite-text")) self.fill_grid(0, Activity, "activity", Activity.objects.all()) grid = self.get_components("activity") if WrapAction.is_permission(self.request, 'CORE.add_parameter'): grid.add_action(self.request, ObjectMerge.get_action(_("Merge"), "images/clone.png"), close=CLOSE_NO, unique=SELECT_MULTI, params={ 'modelname': 'member.Activity', 'field_id': 'activity' }) if hasattr(settings, "DIACAMMA_MAXACTIVITY") and (getattr( settings, "DIACAMMA_MAXACTIVITY") <= grid.nb_lines): lbl = XferCompLabelForm("limit_activity") lbl.set_color('red') lbl.set_value_as_headername( _('You have the maximum of activities!')) lbl.set_location(grid.col, self.get_max_row() + 1) self.add_component(lbl) grid.delete_action("diacamma.member/activityAddModify", True)
def fillresponse(self): img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) self.add_component(img) self.item = self.item.current_subscription if self.item is None: raise LucteriosException(IMPORTANT, _("no subscription!")) self.fill_from_model( 1, 0, True, ['adherent', 'season', 'subscriptiontype']) row = self.get_max_row() + 1 for lic in self.item.license_set.all(): lbl = XferCompLabelForm('lbl_sep_%d' % lic.id) lbl.set_location(1, row, 2) lbl.set_value("{[hr/]}") self.add_component(lbl) row += 1 if Params.getvalue("member-team-enable"): lbl = XferCompLabelForm('lblteam_%d' % lic.id) lbl.set_value_as_name(Params.getvalue("member-team-text")) lbl.set_location(1, row) self.add_component(lbl) lbl = XferCompLabelForm('team_%d' % lic.id) lbl.set_value(six.text_type(lic.team)) lbl.set_location(2, row) self.add_component(lbl) row += 1 if Params.getvalue("member-activite-enable"): lbl = XferCompLabelForm('lblactivity_%d' % lic.id) lbl.set_value_as_name(Params.getvalue("member-activite-text")) lbl.set_location(1, row) self.add_component(lbl) lbl = XferCompLabelForm('activity_%d' % lic.id) lbl.set_value(six.text_type(lic.activity)) lbl.set_location(2, row) self.add_component(lbl) row += 1 lbl = XferCompLabelForm('lblvalue_%d' % lic.id) lbl.set_value_as_name(_('value')) lbl.set_location(1, row) self.add_component(lbl) lbl = XferCompEdit('value_%d' % lic.id) lbl.set_value(lic.value) lbl.set_location(2, row) self.add_component(lbl) row += 1 self.add_action(AdherentLicenseSave.get_action(TITLE_OK, 'images/ok.png')) self.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
def get_info_state(self): info = [] if self.status == 0: info = Supporting.get_info_state( self, current_system_account().get_customer_mask()) details = self.detail_set.all() if len(details) == 0: info.append(six.text_type(_("no detail"))) else: for detail in details: if detail.article is not None: detail_code = detail.article.sell_account else: detail_code = Params.getvalue( "invoice-default-sell-account") detail_account = None if match(current_system_account().get_revenue_mask(), detail_code) is not None: try: detail_account = ChartsAccount.get_account( detail_code, FiscalYear.get_current()) except LucteriosException: break if detail_account is None: info.append( six.text_type(_("article has code account unknown!"))) break try: info.extend(self.check_date(self.date.isoformat())) except LucteriosException: pass return "{[br/]}".join(info)
def get_connection_info(self): from lxml import etree from django.conf import settings import lucterios.CORE import os connextion = etree.SubElement(self.responsexml, "CONNECTION") etree.SubElement(connextion, 'TITLE').text = six.text_type(settings.APPLIS_NAME) etree.SubElement(connextion, 'SUBTITLE').text = settings.APPLIS_SUBTITLE() etree.SubElement(connextion, 'VERSION').text = six.text_type(settings.APPLIS_VERSION) etree.SubElement(connextion, 'SERVERVERSION').text = six.text_type(lucterios.CORE.__version__) etree.SubElement(connextion, 'COPYRIGHT').text = six.text_type(settings.APPLIS_COPYRIGHT) etree.SubElement(connextion, 'LOGONAME').text = settings.APPLIS_LOGO etree.SubElement(connextion, 'BACKGROUND').text = settings.APPLIS_BACKGROUND etree.SubElement(connextion, 'SUPPORT_EMAIL').text = six.text_type(settings.APPLI_EMAIL) etree.SubElement(connextion, 'SUPPORT_HTML').text = six.text_type(settings.APPLI_SUPPORT()) etree.SubElement(connextion, 'INFO_SERVER').text = get_info_server() setting_module_name = os.getenv("DJANGO_SETTINGS_MODULE", "???.???") etree.SubElement(connextion, 'INSTANCE').text = setting_module_name.split('.')[0] etree.SubElement(connextion, 'LANGUAGE').text = self.language etree.SubElement(connextion, 'MODE').text = six.text_type(Params.getvalue("CORE-connectmode")) if self.request.user.is_authenticated(): etree.SubElement(connextion, 'LOGIN').text = self.request.user.username etree.SubElement(connextion, 'REALNAME').text = "%s %s" % (self.request.user.first_name, self.request.user.last_name) etree.SubElement(connextion, 'EMAIL').text = self.request.user.email else: etree.SubElement(connextion, 'LOGIN').text = '' etree.SubElement(connextion, 'REALNAME').text = '' etree.SubElement(connextion, 'EMAIL').text = '' self.responsexml.text = "OK"
def set_auditlog_states(): from lucterios.CORE.parameters import Params try: LucteriosAuditlogModelRegistry.set_state_packages( Params.getvalue('CORE-AuditLog').split()) except LucteriosException: pass
def edit(self, xfer): set_comp = xfer.get_components('set') set_comp.set_select_query(Set.objects.filter(is_active=True)) xfer.get_components('price').prec = Params.getvalue( "accounting-devise-prec") old_account = xfer.get_components("expense_account") xfer.remove_component("expense_account") sel_account = XferCompSelect("expense_account") sel_account.description = old_account.description sel_account.set_location(old_account.col, old_account.row, old_account.colspan, old_account.rowspan) for item in FiscalYear.get_current().chartsaccount_set.all().filter( code__regex=current_system_account().get_expence_mask( )).order_by('code'): sel_account.select_list.append((item.code, six.text_type(item))) sel_account.set_value(self.item.expense_account) xfer.add_component(sel_account) self.item.year = FiscalYear.get_current() btn = XferCompButton('add_account') btn.set_location(old_account.col + 1, old_account.row) btn.set_is_mini(True) btn.set_action(xfer.request, ActionsManage.get_action_url('accounting.ChartsAccount', 'AddModify', xfer), close=CLOSE_NO, modal=FORMTYPE_MODAL, params={'year': self.item.year.id}) xfer.add_component(btn) xfer.get_components("set").colspan = old_account.colspan + 1 xfer.get_components("designation").colspan = old_account.colspan + 1 xfer.get_components("price").colspan = old_account.colspan + 1
def comptenofound_condo(known_codes, accompt_returned): if Params.getvalue("condominium-old-accounting"): account_filter = Q(name='condominium-default-owner-account') set_unknown = Set.objects.exclude( revenue_account__in=known_codes).values_list('revenue_account', flat=True) else: account_filter = Q() for param_item in current_system_condo().get_config_params(True): account_filter |= Q(name=param_item) set_unknown = [] param_unknown = Parameter.objects.filter(account_filter).exclude( value__in=known_codes).values_list('value', flat=True) comptenofound = "" if (len(set_unknown) > 0): comptenofound = _("set") + ":" + ",".join(set(set_unknown)) + " " param_unknown = list(param_unknown) if '0' in param_unknown: param_unknown.remove('0') if (len(param_unknown) > 0): comptenofound += _("parameters") + ":" + ",".join(set(param_unknown)) if comptenofound != "": accompt_returned.append("- {[i]}{[u]}%s{[/u]}: %s{[/i]}" % (_('Condominium'), comptenofound)) return True
def test_parameters_float(self): param = Parameter.objects.create( name='param_float', typeparam=2) param.args = "{'Min':20, 'Max':30, 'Prec':2}" param.value = '22.25' param.save() Params.fill(self.xfer, ['param_float'], 1, 1, True) Params.fill(self.xfer, ['param_float'], 1, 2, False) self.callparam() self.assert_count_equal('COMPONENTS/*', 4) self.assert_count_equal( 'COMPONENTS/LABELFORM[@name="lbl_param_float"]', 2) self.assert_xml_equal( 'COMPONENTS/LABELFORM[@name="param_float"]', '22.25') self.assert_xml_equal('COMPONENTS/FLOAT[@name="param_float"]', '22.25') self.assert_attrib_equal( 'COMPONENTS/FLOAT[@name="param_float"]', 'min', '20.0') self.assert_attrib_equal( 'COMPONENTS/FLOAT[@name="param_float"]', 'max', '30.0') self.assert_attrib_equal( 'COMPONENTS/FLOAT[@name="param_float"]', 'prec', '2') self.factory.xfer = ParamSave() self.call( '/CORE/paramSave', {'params': 'param_float', 'param_float': '26.87'}, False) self.assert_observer('core.acknowledge', 'CORE', 'paramSave') self.assertEqual(Params.getvalue('param_float'), 26.87)
def init_compta(): year = FiscalYear.get_current() if Params.getvalue("condominium-old-accounting"): add_entry(year.id, 1, '2015-01-01', 'Report à nouveau', '-1|2|0|23.450000|0|0|None|\n-2|17|4|-23.450000|0|0|None|', True) elif get_accounting_system() == 'FR': add_entry( year.id, 1, '2015-01-01', 'Report à nouveau', """-1|2|0|16.680000|0|0|None| -2|17|4|-23.450000|0|0|None| -3|18|4|-5.730000|0|0|None| -4|17|5|10.500000|0|0|None| -5|18|5|0.7500000|0|0|None| -6|19|5|0.6000000|0|0|None| -7|20|5|0.250000|0|0|None| -8|21|5|0.400000|0|0|None|""", True) elif get_accounting_system() == 'BE': add_entry( year.id, 1, '2015-01-01', 'Report à nouveau', """-1|2|0|16.680000|0|0|None| -2|17|4|-23.450000|0|0|None| -3|18|4|-5.730000|0|0|None| -4|17|5|12.500000|0|0|None|""", True) add_entry(year.id, 5, '2015-02-20', 'Frais bancaire', '-1|2|0|-12.340000|0|0|None|\n-2|15|0|12.340000|0|0|None|', True)
def save(self, force_insert=False, force_update=False, using=None, update_fields=None): if (self.id is None) and (self.event.event_type == 0) and ((self.comment is None) or (self.comment == '')): self.comment = Params.getvalue("event-comment-text") if (self.id is None) and (self.event.default_article is not None): self.article = self.event.default_article return LucteriosModel.save(self, force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)
def summary_dummy(xfer): if not hasattr(xfer, 'add_component'): return True else: row = xfer.get_max_row() + 1 lab = XferCompLabelForm('dummytitle') lab.set_value_as_infocenter("Dummy") lab.set_location(0, row, 4) xfer.add_component(lab) lbl = XferCompLabelForm('dummy_time') lbl.set_color('blue') lbl.set_location(0, row + 1, 4) lbl.set_centered() lbl.set_value(datetime.now().ctime()) xfer.add_component(lbl) btn = XferCompButton('btnscheduler') btn.set_action(xfer.request, AddSchedulerTask.get_action('Task', '')) btn.set_location(0, row + 2, 4) xfer.add_component(btn) lbl = XferCompLabelForm('dummy-value') lbl.set_location(0, row + 3, 4) lbl.set_value(Params.getvalue('dummy-value')) xfer.add_component(lbl) return True
def correct_accounting_code(code): code_size = Params.getvalue("accounting-sizecode") while len(code) > code_size and code[-1] == '0': code = code[:-1] while len(code) < code_size: code += '0' return code
def get_statistic(cls, season): def sort_fct(item): if item[1][1] is None: return item[1][0].level * 100000 else: return item[1][0].level * 100000 + item[1][1].level static_res = [] for activity in Activity.objects.all(): degree_activity = {} for degree in Degree.objects.filter( date__gte=season.begin_date, date__lte=season.end_date, degree__activity=activity).distinct(): if degree.get_text() not in degree_activity.keys(): degree_activity[degree.get_text()] = [ degree.degree, degree.subdegree, 0 ] degree_activity[degree.get_text()][2] += 1 result_activity = [] for item in sorted(degree_activity.items(), key=lambda item: sort_fct(item), reverse=True): result_activity.append((item[0], item[1][2])) if Params.getvalue("member-activite-enable"): static_res.append((activity, result_activity)) else: static_res.append((None, result_activity)) return static_res
def current_system_account(): import sys current_module = sys.modules[__name__] if not hasattr(current_module, 'SYSTEM_ACCOUNT_CACHE'): setattr(current_module, 'SYSTEM_ACCOUNT_CACHE', get_accounting_system(Params.getvalue("accounting-system"))) return current_module.SYSTEM_ACCOUNT_CACHE
def summary_dummy(xfer): if not hasattr(xfer, 'add_component'): return True else: row = xfer.get_max_row() + 1 lab = XferCompLabelForm('dummytitle') lab.set_value_as_infocenter("Dummy") lab.set_location(0, row, 4) xfer.add_component(lab) lbl = XferCompLabelForm('dummy_time') lbl.set_color('blue') lbl.set_location(0, row + 1, 4) lbl.set_centered() lbl.set_value(datetime.now()) lbl.set_format('H') xfer.add_component(lbl) btn = XferCompButton('btnscheduler') btn.set_action(xfer.request, AddSchedulerTask.get_action('Task', '')) btn.set_location(0, row + 2, 4) xfer.add_component(btn) lbl = XferCompLabelForm('dummy-value') lbl.set_location(0, row + 3, 4) lbl.set_value(Params.getvalue('dummy-value')) xfer.add_component(lbl) return True
def send_connection_by_email(recipients, alias, passwd): subject = _("Connection password") message = Params.getvalue('mailing-msg-connection') % {'username': alias, 'password': passwd} msg_connection = "<html>" msg_connection += message.replace('{[newline]}', '<br/>').replace('{[', '<').replace(']}', '>') msg_connection += "</html>" send_email(recipients, subject, msg_connection)
def paramchange_invoice(params): invoice_params = ['invoice-default-sell-account', 'invoice-vatsell-account', 'invoice-reduce-account', 'invoice-account-third'] if 'accounting-sizecode' in params: for param_item in invoice_params: Parameter.change_value( param_item, correct_accounting_code(Params.getvalue(param_item))) Params.clear() for art in Article.objects.all(): if art.sell_account != correct_accounting_code(art.sell_account): art.sell_account = correct_accounting_code(art.sell_account) art.save() for invoice_param in invoice_params: if invoice_param in params: Parameter.change_value( invoice_param, correct_accounting_code(Params.getvalue(invoice_param)))
def test_parameters_select(self): param = Parameter.objects.create(name='param_select', typeparam=4) param.args = "{'Enum':4}" param.value = '2' param.save() Params.fill(self.xfer, ['param_select'], 1, 1, True) self.callparam() self.assert_count_equal('', 1) self.assert_json_equal('LABELFORM', "param_select", 'param_select.2') Params.fill(self.xfer, ['param_select'], 1, 1, False) self.callparam() self.assert_count_equal('', 1) self.assert_json_equal('SELECT', "param_select", '2') self.assert_select_equal( "param_select", { 0: 'param_select.0', 1: 'param_select.1', 2: 'param_select.2', 3: 'param_select.3' }) self.factory.xfer = ParamSave() self.calljson('/CORE/paramSave', { 'params': 'param_select', 'param_select': '1' }, False) self.assert_observer('core.acknowledge', 'CORE', 'paramSave') self.assertEqual(Params.getvalue('param_select'), 1)
def paramchange_condominium(params): if 'accounting-sizecode' in params: for set_item in Set.objects.all(): if set_item.revenue_account != correct_accounting_code(set_item.revenue_account): set_item.revenue_account = correct_accounting_code(set_item.revenue_account) set_item.save() for exp_item in ExpenseDetail.objects.filter(expense__status=0): if exp_item.expense_account != correct_accounting_code(exp_item.expense_account): exp_item.expense_account = correct_accounting_code(exp_item.expense_account) exp_item.save() accounts = ('condominium-default-owner-account', 'condominium-current-revenue-account', 'condominium-default-owner-account1', 'condominium-default-owner-account2', 'condominium-default-owner-account3', 'condominium-default-owner-account4', 'condominium-default-owner-account5', 'condominium-exceptional-revenue-account', 'condominium-fundforworks-revenue-account', 'condominium-exceptional-reserve-account', 'condominium-advance-reserve-account', 'condominium-fundforworks-reserve-account') for account_item in accounts: has_changed = False if (account_item in params) or ('accounting-sizecode' in params): Parameter.change_value(account_item, correct_accounting_code(Params.getvalue(account_item))) system_condo = current_system_condo() system_condo.owner_account_changed(account_item) has_changed = True if has_changed: Params.clear() if 'accounting-system' in params: clear_system_condo() system_condo = current_system_condo() system_condo.initialize_system()
def test_parameters_int(self): param = Parameter.objects.create(name='param_int', typeparam=1) param.args = "{'Min':5, 'Max':25}" param.value = '5' param.save() Params.fill(self.xfer, ['param_int'], 1, 1, True) self.callparam() self.assert_count_equal('', 1) self.assert_json_equal('LABELFORM', "param_int", '5') Params.fill(self.xfer, ['param_int'], 1, 1, False) self.callparam() self.assert_count_equal('', 1) self.assert_json_equal('FLOAT', "param_int", '5') self.assert_attrib_equal("param_int", 'min', '5.0') self.assert_attrib_equal("param_int", 'max', '25.0') self.assert_attrib_equal("param_int", 'prec', '0') self.factory.xfer = ParamSave() self.calljson('/CORE/paramSave', { 'params': 'param_int', 'param_int': '13' }, False) self.assert_observer('core.acknowledge', 'CORE', 'paramSave') self.assertEqual(Params.getvalue('param_int'), 13)
def test_parameters_float(self): param = Parameter.objects.create(name='param_float', typeparam=2) param.args = "{'Min':20, 'Max':30, 'Prec':2}" param.value = '22.25' param.save() Params.fill(self.xfer, ['param_float'], 1, 1, True) self.callparam() self.assert_count_equal('', 1) self.assert_json_equal('LABELFORM', "param_float", '22.25') Params.fill(self.xfer, ['param_float'], 1, 1, False) self.callparam() self.assert_count_equal('', 1) self.assert_json_equal('FLOAT', "param_float", '22.25') self.assert_attrib_equal("param_float", 'min', '20.0') self.assert_attrib_equal("param_float", 'max', '30.0') self.assert_attrib_equal("param_float", 'prec', '2') self.factory.xfer = ParamSave() self.calljson('/CORE/paramSave', { 'params': 'param_float', 'param_float': '26.87' }, False) self.assert_observer('core.acknowledge', 'CORE', 'paramSave') self.assertEqual(Params.getvalue('param_float'), 26.87)
def default_setowner_fr(with_lots=True): if Params.getvalue("condominium-old-accounting"): create_account(['450'], 0, FiscalYear.get_current()) else: create_account(['4501', '4502', '4503', '4504', '4505'], 0, FiscalYear.get_current()) create_account(['120', '103', '105'], 2, FiscalYear.get_current()) create_account(['702'], 3, FiscalYear.get_current()) set1 = Set.objects.create(name="AAA", budget=1000, revenue_account='701', is_link_to_lots=with_lots, type_load=0) _set_budget(set1, '604', 1000) set2 = Set.objects.create(name="BBB", budget=100, revenue_account='701', type_load=0) _set_budget(set2, '604', 100) set3 = Set.objects.create(name="CCC", budget=500, revenue_account='702', type_load=1) _set_budget(set3, '604', 500) set4 = Set.objects.create(name="OLD", budget=100, revenue_account='702', type_load=1, is_active=False) _set_budget(set4, '602', 100) _create_owners(set1, set2, set3, set4, with_lots) Owner.check_all_account()
def finalizeyear_condo(xfer): year = FiscalYear.get_current(xfer.getparam('year')) if year is not None: ventilate = xfer.getparam("ventilate", 0) if xfer.observer_name == "core.custom": if year.check_to_close() > 0: raise LucteriosException(IMPORTANT, _("This fiscal year has entries not closed!")) result = year.total_revenue - year.total_expense if abs(result) > 0.001: row = xfer.get_max_row() + 1 lbl = XferCompLabelForm('title_condo') lbl.set_value(_('This fiscal year has a result no null equals to %s.') % format_devise(result, 5)) lbl.set_location(0, row, 2) xfer.add_component(lbl) lbl = XferCompLabelForm('question_condo') lbl.set_value(_('Where do you want to ventilate this amount?')) lbl.set_location(0, row + 1) xfer.add_component(lbl) sel_cmpt = [('0', _("For each owner"))] for account in year.chartsaccount_set.filter(type_of_account=2).order_by('code'): sel_cmpt.append((account.id, six.text_type(account))) sel = XferCompSelect("ventilate") sel.set_select(sel_cmpt) sel.set_value(ventilate) sel.set_location(1, row + 1) xfer.add_component(sel) elif xfer.observer_name == "core.acknowledge": for set_cost in year.setcost_set.filter(year=year, set__is_active=True, set__type_load=0): if ventilate == 0: set_cost.set.ventilate_costaccounting(set_cost.cost_accounting, 1, Params.getvalue("condominium-current-revenue-account")) set_cost.cost_accounting.close() ventilate_result(year, ventilate)
def send_connection_by_email(recipients, alias, passwd): subject = _("Connection password") msg_connection = Params.getvalue('mailing-msg-connection').replace( '{[newline]}', '\n') % { 'username': alias, 'password': passwd } send_email(recipients, subject, msg_connection)
def send_mailing_in_waiting(http_root_address): '''Mailing''' msg_list = Message.objects.filter(status=2) if len(msg_list) == 0: LucteriosScheduler.remove(send_mailing_in_waiting) else: for msg_item in msg_list: msg_item.sendemail(Params.getvalue('mailing-nb-by-batch'), http_root_address)
def show(self, xfer): if Params.getvalue("member-team-enable") and (len( Prestation.objects.all()) > 0) and (self.item.status in (0, 1)): xfer.remove_component('license') xfer.filltab_from_model(1, xfer.get_max_row() + 1, True, ['prestations'])
def initial_account_asso(account_list): from diacamma.accounting.system import accounting_system_ident filename = join( dirname(__file__), 'init_%s.csv' % accounting_system_ident(Params.getvalue("accounting-system"))) if isinstance(account_list, list): account_list.append(filename) return isfile(filename)
def CurrentCallFundsAdding(self, to_create): if to_create: nb_seq = 0 if Params.getvalue("condominium-mode-current-callfunds") == 0: nb_seq = 4 if Params.getvalue("condominium-mode-current-callfunds") == 1: nb_seq = 12 year = FiscalYear.get_current() for num in range(nb_seq): date = same_day_months_after(year.begin, int(num * 12 / nb_seq)) new_call = CallFunds.objects.create(date=date, comment=_("Call of funds #%(num)d of year from %(begin)s to %(end)s") % {'num': num + 1, 'begin': get_value_converted(year.begin), 'end': get_value_converted(year.end)}, status=0) for category in Set.objects.filter(type_load=0, is_active=True): CallDetail.objects.create(set=category, type_call=0, callfunds=new_call, price=category.get_current_budget() / nb_seq, designation=_("%(type)s - #%(num)d") % {'type': _('current'), 'num': num + 1}) else: year = FiscalYear.get_current() calls = CallFunds.objects.filter(date__gte=year.begin, date__lte=year.end, calldetail__type_call=0).distinct() return len(calls) == 0