示例#1
0
 def update_current_month_sales(self):
     if frappe.flags.in_test:
         update_company_current_month_sales(self.company)
     else:
         frappe.enqueue(
             'erpnext.setup.doctype.company.company.update_company_current_month_sales',
             company=self.company)
示例#2
0
    def on_cancel(self):
        self.check_close_sales_order("sales_order")

        from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
        if frappe.db.get_single_value(
                'Accounts Settings',
                'unlink_payment_on_cancellation_of_invoice'):
            unlink_ref_doc_from_payment_entries(self)

        if self.is_return:
            # NOTE status updating bypassed for is_return
            self.status_updater = []

        self.update_status_updater_args()
        self.update_prevdoc_status()
        self.update_billing_status_in_dn()

        if not self.is_return:
            self.update_billing_status_for_zero_amount_refdoc("Sales Order")
            self.update_serial_no(in_cancel=True)

        self.validate_c_form_on_cancel()

        # Updating stock ledger should always be called after updating prevdoc status,
        # because updating reserved qty in bin depends upon updated delivered qty in SO
        if self.update_stock == 1:
            self.update_stock_ledger()

        self.make_gl_entries_on_cancel()
        frappe.db.set(self, 'status', 'Cancelled')

        update_company_current_month_sales(self.company)
        self.update_project()
示例#3
0
	def on_cancel(self):
		self.check_close_sales_order("sales_order")

		from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
		if frappe.db.get_single_value('Accounts Settings', 'unlink_payment_on_cancellation_of_invoice'):
			unlink_ref_doc_from_payment_entries(self)

		if self.is_return:
			# NOTE status updating bypassed for is_return
			self.status_updater = []

		self.update_status_updater_args()
		self.update_prevdoc_status()
		self.update_billing_status_in_dn()

		if not self.is_return:
			self.update_billing_status_for_zero_amount_refdoc("Sales Order")
			self.update_serial_no(in_cancel=True)

		self.validate_c_form_on_cancel()

		# Updating stock ledger should always be called after updating prevdoc status,
		# because updating reserved qty in bin depends upon updated delivered qty in SO
		if self.update_stock == 1:
			self.update_stock_ledger()

		self.make_gl_entries_on_cancel()
		frappe.db.set(self, 'status', 'Cancelled')

		update_company_current_month_sales(self.company)
		self.update_project()
示例#4
0
 def on_cancel(self):
     delete_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
     self.set_status()
     if frappe.db.get_single_value(
             'Selling Settings',
             'sales_update_frequency') == "Each Transaction":
         update_company_current_month_sales(self.company)
         update_company_current_month_purchase(self.company)
def execute():
    '''Update company monthly sales history based on sales invoices'''
    frappe.reload_doctype("Company")
    companies = [d['name'] for d in frappe.get_list("Company")]

    for company in companies:
        update_company_current_month_sales(company)
        update_company_monthly_sales(company)
def execute():
	'''Update company monthly sales history based on sales invoices'''
	frappe.reload_doctype("Company")
	companies = [d['name'] for d in frappe.get_list("Company")]

	for company in companies:
		update_company_current_month_sales(company)
		update_company_monthly_sales(company)
示例#7
0
    def on_submit(self):
        if (self.cust_grand_total != 0):
            self.make_gl_entries()
        self.set_status()

        if frappe.db.get_single_value(
                'Selling Settings',
                'sales_update_frequency') == "Each Transaction":
            update_company_current_month_sales(self.company)
            update_company_current_month_purchase(self.company)
    def on_submit(self):
        self.validate_pos_paid_amount()

        if not self.subscription:
            frappe.get_doc(
                'Authorization Control').validate_approving_authority(
                    self.doctype, self.company, self.base_grand_total, self)

        self.check_prev_docstatus()

        if self.is_return:
            # NOTE status updating bypassed for is_return
            self.status_updater = []

        self.update_status_updater_args()
        self.update_prevdoc_status()
        self.update_billing_status_in_dn()
        self.clear_unallocated_mode_of_payments()

        # Updating stock ledger should always be called after updating prevdoc status,
        # because updating reserved qty in bin depends upon updated delivered qty in SO
        if self.update_stock == 1:
            self.update_stock_ledger()

        # this sequence because outstanding may get -ve
        self.make_gl_entries()

        if not self.is_return:
            self.update_billing_status_for_zero_amount_refdoc("Sales Order")
            self.check_credit_limit()

        self.update_serial_no()

        # if not cint(self.is_pos) == 1 and not self.is_return:
        #   self.update_against_document_in_jv()

        self.update_time_sheet(self.name)

        update_company_current_month_sales(self.company)
        self.update_project()
示例#9
0
	def on_submit(self):
		self.validate_pos_paid_amount()

		if not self.subscription:
			frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype,
				self.company, self.base_grand_total, self)

		self.check_prev_docstatus()

		if self.is_return:
			# NOTE status updating bypassed for is_return
			self.status_updater = []

		self.update_status_updater_args()
		self.update_prevdoc_status()
		self.update_billing_status_in_dn()
		self.clear_unallocated_mode_of_payments()

		# Updating stock ledger should always be called after updating prevdoc status,
		# because updating reserved qty in bin depends upon updated delivered qty in SO
		if self.update_stock == 1:
			self.update_stock_ledger()

		# this sequence because outstanding may get -ve
		self.make_gl_entries()

		if not self.is_return:
			self.update_billing_status_for_zero_amount_refdoc("Sales Order")
			self.check_credit_limit()

		self.update_serial_no()

		if not cint(self.is_pos) == 1 and not self.is_return:
			self.update_against_document_in_jv()

		self.update_time_sheet(self.name)

		update_company_current_month_sales(self.company)
		self.update_project()
示例#10
0
    def make_gl_entries(self):
        customer_against = self.supplier + " + " + self.income_account

        gl_entry = []

        #		customer_gl_entries =  self.get_gl_dict({
        gl_entry.append(
            self.get_gl_dict({
                "account": self.receivable_account,
                "against": customer_against,
                "party_type": "Customer",
                "party": self.customer,
                "debit": self.cust_grand_total,
                "debit_in_account_currency": self.cust_grand_total,
                "against_voucher": self.name,
                "against_voucher_type": self.doctype,
                "cost_center": self.cost_center
            }))

        supplier_against = self.customer + " - " + self.income_account

        #		supplier_gl_entry = self.get_gl_dict({
        gl_entry.append(
            self.get_gl_dict({
                "account": self.payable_account,
                "against": supplier_against,
                "party_type": "Supplier",
                "party": self.supplier,
                "credit": self.supp_grand_total,
                "credit_in_account_currency": self.supp_grand_total,
                "against_voucher": self.name,
                "against_voucher_type": self.doctype,
                "cost_center": self.cost_center
            }))

        income_against = self.customer + " - " + self.supplier

        #		income_gl_entry = self.get_gl_dict({
        gl_entry.append(
            self.get_gl_dict({
                "account": self.income_account,
                "against": income_against,
                "credit": self.uatp_grand_total,
                "credit_in_account_currency": self.uatp_grand_total,
                "against_voucher": self.name,
                "against_voucher_type": self.doctype,
                "cost_center": self.cost_center
            }))

        if float(self.paid_amount) > 0:
            #			payment_gl_entry = []
            payments = frappe.get_doc("Ticket Invoice",
                                      self.name).get('payments')
            for d in payments:
                gl_entry.append(
                    self.get_gl_dict({
                        "account":
                        d.get('account'),
                        "against":
                        self.customer,
                        "debit":
                        d.get('amount'),
                        "debit_in_account_currency":
                        d.get('amount'),
                        "against_voucher":
                        self.name,
                        "against_voucher_type":
                        self.doctype,
                        "cost_center":
                        self.cost_center
                    }))

                gl_entry.append(
                    self.get_gl_dict({
                        "account":
                        self.receivable_account,
                        "against":
                        d.get('account'),
                        "party_type":
                        "Customer",
                        "party":
                        self.customer,
                        "credit":
                        d.get('amount'),
                        "credit_in_account_currency":
                        d.get('amount'),
                        "against_voucher":
                        self.name,
                        "against_voucher_type":
                        self.doctype,
                        "cost_center":
                        self.cost_center
                    }))


#		make_gl_entries([customer_gl_entries, supplier_gl_entry, income_gl_entry], cancel=(self.docstatus == 2),
#				update_outstanding="No", merge_entries=False)

        make_gl_entries(gl_entry,
                        cancel=(self.docstatus == 2),
                        update_outstanding="No",
                        merge_entries=False)

        if frappe.db.get_single_value(
                'Selling Settings',
                'sales_update_frequency') == "Each Transaction":
            update_company_current_month_sales(self.company)
示例#11
0
	def update_current_month_sales(self):
		if frappe.flags.in_test:
			update_company_current_month_sales(self.company)
		else:
			frappe.enqueue('erpnext.setup.doctype.company.company.update_company_current_month_sales',
				company=self.company)
示例#12
0
    def make_gl_entries(self):
        #		customer_against = self.supplier + " + " + self.income_account

        gl_entry = []

        #		customer_gl_entries =  self.get_gl_dict({
        if self.account_currency == self.company_default_currency:
            gl_entry.append(
                self.get_gl_dict({
                    "account": self.receivable_account,
                    "against": self.income_account,
                    "party_type": "Customer",
                    "party": self.customer,
                    "debit": self.base_cust_grand_total,
                    "debit_in_account_currency": self.base_cust_grand_total,
                    "against_voucher": self.name,
                    "against_voucher_type": self.doctype,
                    "account_currency": self.account_currency
                }))
        else:
            gl_entry.append(
                self.get_gl_dict({
                    "account": self.receivable_account,
                    "against": self.income_account,
                    "party_type": "Customer",
                    "party": self.customer,
                    "debit": self.base_cust_grand_total,
                    "debit_in_account_currency": self.cust_grand_total,
                    "against_voucher": self.name,
                    "against_voucher_type": self.doctype,
                    "account_currency": self.account_currency
                }))

        if float(self.base_customer_vat) > 0:
            gl_entry.append(
                self.get_gl_dict({
                    "account":
                    self.def_sales_vat_acc,
                    "against":
                    self.customer,
                    "credit":
                    self.base_customer_vat,
                    "credit_in_account_currency":
                    self.base_customer_vat
                }))

        supplier_against = self.customer + " - " + self.income_account
        suppliers_gl_entry = frappe.get_doc("Tour Invoice",
                                            self.name).get('items')
        for d in suppliers_gl_entry:

            if d.supplier_account_currency == self.company_default_currency:
                gl_entry.append(
                    self.get_gl_dict({
                        "account":
                        d.payable_account,
                        "against":
                        self.customer,
                        "party_type":
                        "Supplier",
                        "party":
                        d.get('supplier'),
                        "credit":
                        d.get('base_supp_total_av'),
                        "credit_in_account_currency":
                        d.get('base_supp_total_av'),
                        "against_voucher":
                        self.name,
                        "against_voucher_type":
                        self.doctype,
                        "account_currency":
                        d.get('supplier_account_currency')
                    }))
            else:
                gl_entry.append(
                    self.get_gl_dict({
                        "account":
                        d.payable_account,
                        "against":
                        self.customer,
                        "party_type":
                        "Supplier",
                        "party":
                        d.get('supplier'),
                        "credit":
                        d.get('base_supp_total_av'),
                        "credit_in_account_currency":
                        d.get('supp_total_av'),
                        "against_voucher":
                        self.name,
                        "against_voucher_type":
                        self.doctype,
                        "account_currency":
                        d.get('supplier_account_currency')
                    }))

            if float(d.get('base_supp_vat')) > 0:
                gl_entry.append(
                    self.get_gl_dict({
                        "account":
                        self.def_purchase_vat_acc,
                        "against":
                        d.get('supplier'),
                        "debit":
                        d.get('base_supp_vat'),
                        "debit_in_account_currency":
                        d.get('base_supp_vat')
                    }))


#		income_against = self.customer + " - " + self.supplier

#		income_gl_entry = self.get_gl_dict({
        gl_entry.append(
            self.get_gl_dict({
                "account": self.income_account,
                "against": self.customer,
                "credit": self.base_c_s,
                "credit_in_account_currency": self.base_c_s,
                "cost_center": self.cost_center
            }))

        if float(self.paid_amount) > 0:
            #			payment_gl_entry = []
            payments = frappe.get_doc("Tour Invoice",
                                      self.name).get('payments')
            for d in payments:
                if d.account_currency == self.company_default_currency:
                    if d.account_currency == self.account_currency:
                        gl_entry.append(
                            self.get_gl_dict({
                                "account":
                                self.receivable_account,
                                "against":
                                d.get('account'),
                                "party_type":
                                "Customer",
                                "party":
                                self.customer,
                                "credit":
                                d.get('amount'),
                                "credit_in_account_currency":
                                d.get('amount'),
                                "against_voucher":
                                self.name,
                                "against_voucher_type":
                                self.doctype,
                                "account_currency":
                                self.account_currency
                            }))
                    else:
                        gl_entry.append(
                            self.get_gl_dict({
                                "account":
                                self.receivable_account,
                                "against":
                                d.get('account'),
                                "party_type":
                                "Customer",
                                "party":
                                self.customer,
                                "credit":
                                d.get('base_amount'),
                                "credit_in_account_currency":
                                d.get('base_amount') *
                                self.customer_exchange_rate,
                                "against_voucher":
                                self.name,
                                "against_voucher_type":
                                self.doctype,
                                "account_currency":
                                self.account_currency
                            }))

                    gl_entry.append(
                        self.get_gl_dict({
                            "account":
                            d.get('account'),
                            "against":
                            self.customer,
                            "debit":
                            d.get('amount'),
                            "debit_in_account_currency":
                            d.get('amount'),
                            "account_currency":
                            d.get('account_currency')
                        }))
                else:
                    if self.account_currency != self.company_default_currency:
                        if self.account_currency == d.account_currency:
                            gl_entry.append(
                                self.get_gl_dict({
                                    "account":
                                    self.receivable_account,
                                    "against":
                                    d.get('account'),
                                    "party_type":
                                    "Customer",
                                    "party":
                                    self.customer,
                                    "credit":
                                    d.get('base_amount'),
                                    "credit_in_account_currency":
                                    d.get('amount'),
                                    "against_voucher":
                                    self.name,
                                    "against_voucher_type":
                                    self.doctype,
                                    "account_currency":
                                    self.account_currency
                                }))
                        else:
                            gl_entry.append(
                                self.get_gl_dict({
                                    "account":
                                    self.receivable_account,
                                    "against":
                                    d.get('account'),
                                    "party_type":
                                    "Customer",
                                    "party":
                                    self.customer,
                                    "credit":
                                    d.get('base_amount'),
                                    "credit_in_account_currency":
                                    d.get('base_amount') *
                                    d.get('account_exchange_rate'),
                                    "against_voucher":
                                    self.name,
                                    "against_voucher_type":
                                    self.doctype,
                                    "account_currency":
                                    self.account_currency
                                }))
                    else:
                        gl_entry.append(
                            self.get_gl_dict({
                                "account":
                                self.receivable_account,
                                "against":
                                d.get('account'),
                                "party_type":
                                "Customer",
                                "party":
                                self.customer,
                                "credit":
                                d.get('base_amount'),
                                "credit_in_account_currency":
                                d.get('base_amount'),
                                "against_voucher":
                                self.name,
                                "against_voucher_type":
                                self.doctype,
                                "account_currency":
                                self.account_currency
                            }))

                    gl_entry.append(
                        self.get_gl_dict({
                            "account":
                            d.get('account'),
                            "against":
                            self.customer,
                            "debit":
                            d.get('base_amount'),
                            "debit_in_account_currency":
                            d.get('amount'),
                            "account_currency":
                            d.get('account_currency')
                        }))

        make_gl_entries(gl_entry,
                        cancel=(self.docstatus == 2),
                        update_outstanding="No",
                        merge_entries=False)

        if frappe.db.get_single_value(
                'Selling Settings',
                'sales_update_frequency') == "Each Transaction":
            update_company_current_month_sales(self.company)