How to use get_cc_list method in Kiwi

Best Python code snippet using Kiwi_python

other_contribution.py

Source:other_contribution.py Github

copy

Full Screen

...22 self.update_salary_structure(True)23 def validate_group_cost_center(self):24 if frappe.session.user != "Administrator":25 user_cc = frappe.db.get_value("Employee", {"user_id": frappe.session.user}, "cost_center")26 if not user_cc or user_cc not in self.get_cc_list(self.group_cost_center):27 frappe.throw(_("You do not have permission to access cost center <b>{0}</b>").format(self.group_cost_center), title="No permission")28 29 def validate_amounts(self):30 total_noof_employees = 031 total_noof_contributors = 032 total_contribution_amount = 033 for i in self.get("items"):34 if flt(i.contribution) < 0:35 frappe.throw(_("Row#{0} : Contribution amount cannot be a negative value").format(i.idx), title="Invalid data")36 # elif self.employee == i.employee and flt(i.contribution) > 0:37 # frappe.msgprint(_("Row#{0} : Employee to whom the contribution is meant is also in the contributors list").format(i.idx))38 else:39 pass40 41 total_noof_employees += 142 if flt(i.contribution) > 0:43 total_noof_contributors += 144 total_contribution_amount += flt(i.contribution)45 46 self.total_noof_employees = total_noof_employees47 self.total_noof_contributors = total_noof_contributors48 self.total_contribution_amount = total_contribution_amount49 if flt(self.total_contribution_amount) == 0:50 frappe.throw(_("Total contribution amount cannot be zero"), title="Invalid data")51 52 def update_defaults(self):53 self.posting_date = nowdate()54 if not self.salary_component:55 frappe.throw(_("Missing default value for field salary_component under DocType master. Please contact Administrator."), title="Data missing")56 57 if not frappe.db.exists("Salary Component", self.salary_component):58 frappe.throw(_("Salary component <b>`{0}`</b> not found").format(self.salary_component), title="Data missing")59 if self.docstatus < 2:60 self.reference = None61 62 def post_journal_entry(self):63 advance_other_account = frappe.db.get_value("Salary Component", self.salary_component, "gl_head")64 # default_business_activity = frappe.db.get_value("Business Activity", {"is_default": 1}, "name")65 default_cost_center = frappe.db.get_value("Company", self.company, "company_cost_center")66 # if not expense_bank_account:67 # frappe.throw(_("Please define <b>Expense Bank Account</b> for the branch <b>{0}</b>").format(self.employee_branch), title="Data missing")68 if not advance_other_account:69 frappe.throw(_("Please define GL Head for the salary component <b>{0}</b>").format(self.salary_component), title="Data missing")70 # elif not default_business_activity:71 # frappe.throw(_("Please define default business activity under <b>Business Activity</b>"), title="Data missing")72 elif not default_cost_center:73 frappe.throw(_("Please define default cost center under <b>Company</b> master"), title="Data missing")74 else:75 pass76 77 je = frappe.new_doc("Journal Entry")78 je.flags.ignore_permissions = 1 79 je.title = self.title + " ("+self.name+")"80 je.voucher_type = 'Bank Entry'81 je.naming_series = 'Bank Payment Voucher'82 je.remark = 'Payment against : ' + je.title83 je.posting_date = self.posting_date84 je.branch = self.branch85 je.pay_to_recd_from = self.contribution_to86 for i in self.get("items"):87 je.append("accounts", {88 "account": advance_other_account,89 # "business_activity": i.business_activity,90 "reference_type": "Other Contribution",91 "reference_name": self.name,92 "cost_center": i.cost_center,93 "debit_in_account_currency": flt(i.contribution),94 "debit": flt(i.contribution),95 "party_type": "Employee",96 "party": i.employee97 })98 frappe.msgprint("{}".format(je))99 je.append("accounts", {100 "account": self.expense_bank_account,101 # "business_activity": default_business_activity,102 "reference_type": "Other Contribution",103 "reference_name": self.name,104 "cost_center": default_cost_center,105 "credit_in_account_currency": flt(self.total_contribution_amount),106 "credit": flt(self.total_contribution_amount),107 })108 je.insert()109 self.db_set("reference", je.name)110 frappe.msgprint(_('Journal Entry <a href="#Form/Journal Entry/{0}" target="_blank">{0}</a> posted to accounts for payment').format(je.name))111 112 def update_salary_structure(self, cancel=False):113 for i in self.get("items"):114 if flt(i.contribution) > 0:115 if cancel:116 rem_list = []117 if i.salary_structure:118 doc = frappe.get_doc("Salary Structure", i.salary_structure)119 for d in doc.get("deductions"):120 if d.salary_component == self.salary_component and self.name in (d.reference_number, d.ref_docname):121 rem_list.append(d)122 [doc.remove(d) for d in rem_list]123 doc.save(ignore_permissions=True)124 else:125 if frappe.db.exists("Salary Structure", {"employee": i.employee, "is_active": "Yes"}):126 doc = frappe.get_doc("Salary Structure", {"employee": i.employee, "is_active": "Yes"})127 row = doc.append("deductions",{})128 row.salary_component = self.salary_component129 row.amount = flt(i.contribution)130 row.default_amount = flt(i.contribution)131 row.reference_number = self.name132 row.ref_docname = self.name133 row.total_deductible_amount = flt(i.contribution)134 row.total_deducted_amount = 0135 row.total_outstanding_amount= flt(i.contribution)136 row.total_days_in_month = 0137 row.working_days = 0138 row.leave_without_pay = 0139 row.payment_days = 0140 doc.save(ignore_permissions=True)141 i.db_set("salary_structure", doc.name, update_modified=False)142 else:143 frappe.throw(_("No active salary structure found for employee {0} {1}").format(i.employee, i.employee_name), title="No Data Found")144 145 def get_cc_list(self, group_cc):146 cc_list = []147 qry = "select name, is_group from `tabCost Center` where parent_cost_center = '{0}'".format(group_cc)148 for c in frappe.db.sql(qry, as_dict=True):149 if c.is_group:150 cc_list += self.get_cc_list(c.name)151 else:152 cc_list += [str(c.name)]153 return cc_list154 def update_amounts(self):155 grades = {}156 if self.contribution_type == "Grade":157 for i in frappe.db.sql("select name, other_contribution from `tabEmployee Grade`", as_dict=True):158 if not grades.has_key(str(i.name)):159 grades[str(i.name)] = i.other_contribution160 for i in self.get('items'):161 i.contribution = flt(self.contribution) if self.contribution_type == "Flat Rate" else flt(grades.get(i.employee_grade))162 163 def get_employees(self):164 self.set('items', [])165 cc_list = [str(self.group_cost_center)]166 cc_list += self.get_cc_list(self.group_cost_center)167 format_string = ','.join(["'%s'"]*len(cc_list))168 format_string = format_string % tuple(cc_list)169 qry = """170 select171 name, employee_name, employment_type,172 employee_group, employee_subgroup, 173 designation, branch, cost_center174 from `tabEmployee` e175 where cost_center in ({0})176 and status = 'Active'177 and exists(select 1178 from `tabSalary Structure` sst179 where sst.employee = e.name180 and sst.is_active = 'Yes')...

Full Screen

Full Screen

payment_email.py

Source:payment_email.py Github

copy

Full Screen

...34 self.override_bcc = override_bcc35 self.attachments = attachments or []36 def get_recipient_list(self):37 return self.override_to or []38 def get_cc_list(self):39 return []40 def get_bcc_list(self):41 return self.override_bcc or []42 def get_subject(self):43 raise NotImplementedError("Children must implement `get_subject()`")44 def get_context_data(self):45 ctx = {46 "debug_emails": bool(self.override_to),47 "to_email_list": self.get_recipient_list(),48 "cc_email_list": self.get_cc_list(),49 "bcc_email_list": self.get_bcc_list(),50 "COMPANY": getattr(settings, "ZING_INVOICES_COMPANY", ""),51 "DEPARTMENT": getattr(settings, "ZING_INVOICES_DEPARTMENT", ""),52 }53 ctx.update(self.invoice_ctx)54 return ctx55 def get_body(self):56 """Returns the invoice's email body as a HTML string."""57 return render_to_string(self.template_name, self.get_context_data())58 def send(self):59 """Sends the payment email along with the invoice."""60 body = self.get_body()61 # Set non-empty body according to62 # http://stackoverflow.com/questions/14580176/confusion-with-sending-email-in-django63 mail = EmailMultiAlternatives(64 subject=self.get_subject(),65 body=strip_tags(body),66 to=self.get_recipient_list(),67 cc=self.get_cc_list(),68 bcc=self.get_bcc_list(),69 )70 mail.attach_alternative(body, "text/html")71 for attachment in self.attachments:72 mail.attach_file(attachment[0], attachment[1])73 return mail.send()74class AccountingPaymentEmail(BasePaymentEmail):75 def get_recipient_list(self):76 return self.override_to or self.conf["accounting_email"].split()77 def get_cc_list(self):78 if self.override_to is not None:79 return []80 if "accounting_email_cc" in self.conf:81 return self.conf["accounting_email_cc"].split()82 return []83 def get_subject(self):84 """Returns the subject of the email sent to accounting."""85 # FIXME: make this customizable86 ctx = self.get_context_data()87 return u"For payment: Invoice %s, %s" % (self.id, ctx["name"])88 def get_context_data(self):89 ctx = super().get_context_data()90 ctx.update({"accounting": True})91 return ctx...

Full Screen

Full Screen

email.py

Source:email.py Github

copy

Full Screen

...5def email_case_update(case):6 recipients = get_case_notification_recipients(case)7 if not recipients:8 return9 cc_list = case.emailing.get_cc_list()10 subject, body = history_email_for(case, case.summary)11 mailto(None, subject, recipients, body, cc=cc_list)12def email_case_deletion(case):13 recipients = get_case_notification_recipients(case)14 cc_list = case.emailing.get_cc_list()15 if not recipients:16 return17 subject = _("DELETED: TestCase #%(pk)d - %(summary)s") % {18 "pk": case.pk,19 "summary": case.summary,20 }21 context = {"case": case}22 mailto("email/post_case_delete/email.txt", subject, recipients, context, cc=cc_list)23def get_case_notification_recipients(case):24 recipients = set()25 if case.emailing.auto_to_case_author:26 recipients.add(case.author.email)27 if case.emailing.auto_to_case_tester and case.default_tester:28 recipients.add(case.default_tester.email)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kiwi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful