mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-05 22:48:27 +00:00
show sales invoice data in gross profit report
This commit is contained in:
@@ -39,3 +39,24 @@ class SellingController(StockController):
|
||||
if self.meta.get_field("in_words_export"):
|
||||
self.doc.in_words_export = money_in_words(disable_rounded_total and
|
||||
self.doc.grand_total_export or self.doc.rounded_total_export, self.doc.currency)
|
||||
|
||||
def set_buying_amount(self):
|
||||
from stock.utils import get_buying_amount
|
||||
stock_ledger_entries = self.get_stock_ledger_entries()
|
||||
|
||||
item_sales_bom = {}
|
||||
for d in self.doclist.get({"parentfield": "packing_details"}):
|
||||
new_d = webnotes._dict(d.fields.copy())
|
||||
new_d.total_qty = -1 * d.qty
|
||||
item_sales_bom.setdefault(d.parent_item, []).append(new_d)
|
||||
|
||||
if stock_ledger_entries:
|
||||
for item in self.doclist.get({"parentfield": self.fname}):
|
||||
if item.item_code in self.stock_items or \
|
||||
(item_sales_bom and item_sales_bom.get(item.item_code)):
|
||||
buying_amount = get_buying_amount(item.item_code, item.warehouse, -1*item.qty,
|
||||
self.doc.doctype, self.doc.name, item.name, stock_ledger_entries,
|
||||
item_sales_bom)
|
||||
item.buying_amount = buying_amount > 0 and buying_amount or 0
|
||||
webnotes.conn.set_value(self.tname, item.name, "buying_amount",
|
||||
item.buying_amount)
|
||||
@@ -16,11 +16,14 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import msgprint, _
|
||||
from controllers.accounts_controller import AccountsController
|
||||
|
||||
class StockController(AccountsController):
|
||||
def make_gl_entries(self, against_stock_account, amount, cost_center=None):
|
||||
stock_in_hand_account = self.get_default_account("stock_in_hand_account")
|
||||
def get_gl_entries_for_stock(self, against_stock_account, amount,
|
||||
stock_in_hand_account=None, cost_center=None):
|
||||
if not stock_in_hand_account:
|
||||
stock_in_hand_account = self.get_default_account("stock_in_hand_account")
|
||||
|
||||
if amount:
|
||||
gl_entries = [
|
||||
@@ -41,9 +44,14 @@ class StockController(AccountsController):
|
||||
"remarks": self.doc.remarks or "Accounting Entry for Stock",
|
||||
}, self.doc.docstatus == 2),
|
||||
]
|
||||
from accounts.general_ledger import make_gl_entries
|
||||
make_gl_entries(gl_entries, cancel=self.doc.docstatus == 2)
|
||||
|
||||
return gl_entries
|
||||
|
||||
|
||||
def check_expense_account(self, item):
|
||||
if not item.expense_account:
|
||||
msgprint(_("""Expense account is mandatory for item: """) + item.item_code,
|
||||
raise_exception=1)
|
||||
|
||||
def get_stock_ledger_entries(self, item_list=None, warehouse_list=None):
|
||||
if not (item_list and warehouse_list):
|
||||
|
||||
Reference in New Issue
Block a user