mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 04:59:18 +00:00
fix: Fixes in flow
This commit is contained in:
@@ -1222,7 +1222,9 @@
|
|||||||
"fieldname": "inter_company_invoice_reference",
|
"fieldname": "inter_company_invoice_reference",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Inter Company Invoice Reference",
|
"label": "Inter Company Invoice Reference",
|
||||||
|
"no_copy": 1,
|
||||||
"options": "Sales Invoice",
|
"options": "Sales Invoice",
|
||||||
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1364,7 +1366,7 @@
|
|||||||
"idx": 204,
|
"idx": 204,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-12-25 23:44:48.551116",
|
"modified": "2020-12-26 20:49:03.305063",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Purchase Invoice",
|
"name": "Purchase Invoice",
|
||||||
|
|||||||
@@ -591,16 +591,17 @@ class PurchaseInvoice(BuyingController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
gl_entries.append(
|
if not self.is_internal_transfer():
|
||||||
self.get_gl_dict({
|
gl_entries.append(
|
||||||
"account": item.expense_account,
|
self.get_gl_dict({
|
||||||
"against": self.supplier,
|
"account": item.expense_account,
|
||||||
"debit": warehouse_debit_amount,
|
"against": self.supplier,
|
||||||
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
"debit": warehouse_debit_amount,
|
||||||
"cost_center": item.cost_center,
|
"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
|
||||||
"project": item.project or self.project
|
"cost_center": item.cost_center,
|
||||||
}, account_currency, item=item)
|
"project": item.project or self.project
|
||||||
)
|
}, account_currency, item=item)
|
||||||
|
)
|
||||||
|
|
||||||
# Amount added through landed-cost-voucher
|
# Amount added through landed-cost-voucher
|
||||||
if landed_cost_entries:
|
if landed_cost_entries:
|
||||||
@@ -652,13 +653,14 @@ class PurchaseInvoice(BuyingController):
|
|||||||
if expense_booked_in_pr:
|
if expense_booked_in_pr:
|
||||||
expense_account = service_received_but_not_billed_account
|
expense_account = service_received_but_not_billed_account
|
||||||
|
|
||||||
gl_entries.append(self.get_gl_dict({
|
if not self.is_internal_transfer():
|
||||||
"account": expense_account,
|
gl_entries.append(self.get_gl_dict({
|
||||||
"against": self.supplier,
|
"account": expense_account,
|
||||||
"debit": amount,
|
"against": self.supplier,
|
||||||
"cost_center": item.cost_center,
|
"debit": amount,
|
||||||
"project": item.project or self.project
|
"cost_center": item.cost_center,
|
||||||
}, account_currency, item=item))
|
"project": item.project or self.project
|
||||||
|
}, account_currency, item=item))
|
||||||
|
|
||||||
# If asset is bought through this document and not linked to PR
|
# If asset is bought through this document and not linked to PR
|
||||||
if self.update_stock and item.landed_cost_voucher_amount:
|
if self.update_stock and item.landed_cost_voucher_amount:
|
||||||
|
|||||||
@@ -1600,6 +1600,8 @@ def make_inter_company_transaction(doctype, source_name, target_doc=None):
|
|||||||
currency = frappe.db.get_value('Supplier', details.get('party'), 'default_currency')
|
currency = frappe.db.get_value('Supplier', details.get('party'), 'default_currency')
|
||||||
target_doc.company = details.get("company")
|
target_doc.company = details.get("company")
|
||||||
target_doc.supplier = details.get("party")
|
target_doc.supplier = details.get("party")
|
||||||
|
target_doc.is_internal_supplier = 1
|
||||||
|
target_doc.ignore_pricing_rule = 1
|
||||||
target_doc.buying_price_list = source_doc.selling_price_list
|
target_doc.buying_price_list = source_doc.selling_price_list
|
||||||
|
|
||||||
if currency:
|
if currency:
|
||||||
@@ -1620,7 +1622,11 @@ def make_inter_company_transaction(doctype, source_name, target_doc=None):
|
|||||||
"expense_account",
|
"expense_account",
|
||||||
"cost_center",
|
"cost_center",
|
||||||
"warehouse"
|
"warehouse"
|
||||||
]
|
],
|
||||||
|
"field_map": {
|
||||||
|
'rate': 'rate',
|
||||||
|
'name': 'sales_invoice_item'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if source_doc.get('update_stock'):
|
if source_doc.get('update_stock'):
|
||||||
@@ -1629,7 +1635,6 @@ def make_inter_company_transaction(doctype, source_name, target_doc=None):
|
|||||||
source_document_warehouse_field: target_document_warehouse_field,
|
source_document_warehouse_field: target_document_warehouse_field,
|
||||||
'batch_no': 'batch_no',
|
'batch_no': 'batch_no',
|
||||||
'serial_no': 'serial_no',
|
'serial_no': 'serial_no',
|
||||||
'name': 'sales_invoice_item'
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -965,7 +965,7 @@ class AccountsController(TransactionBase):
|
|||||||
"""
|
"""
|
||||||
if self.doctype in ('Sales Invoice', 'Delivery Note'):
|
if self.doctype in ('Sales Invoice', 'Delivery Note'):
|
||||||
internal_party_field = 'is_internal_customer'
|
internal_party_field = 'is_internal_customer'
|
||||||
elif self.doctype in ('Purchase Invoice', 'Purchase Invoice Item'):
|
elif self.doctype in ('Purchase Invoice', 'Purchase Receipt'):
|
||||||
internal_party_field = 'is_internal_supplier'
|
internal_party_field = 'is_internal_supplier'
|
||||||
|
|
||||||
if self.get(internal_party_field) and (self.represents_company == self.company):
|
if self.get(internal_party_field) and (self.represents_company == self.company):
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ class BuyingController(StockController):
|
|||||||
"allow_zero_valuation": d.get("allow_zero_valuation")
|
"allow_zero_valuation": d.get("allow_zero_valuation")
|
||||||
}, raise_error_if_no_rate=False)
|
}, raise_error_if_no_rate=False)
|
||||||
|
|
||||||
rate = flt(outgoing_rate * d.conversion_factor)
|
rate = flt(outgoing_rate * d.conversion_factor, d.precision('rate'))
|
||||||
else:
|
else:
|
||||||
rate = frappe.db.get_value(ref_doctype, d.get(frappe.scrub(ref_doctype)), 'rate')
|
rate = frappe.db.get_value(ref_doctype, d.get(frappe.scrub(ref_doctype)), 'rate')
|
||||||
|
|
||||||
|
|||||||
@@ -333,9 +333,11 @@ class SellingController(StockController):
|
|||||||
|
|
||||||
# For internal transfers use incoming rate as the valuation rate
|
# For internal transfers use incoming rate as the valuation rate
|
||||||
if self.get('is_internal_customer') and d.get('target_warehouse'):
|
if self.get('is_internal_customer') and d.get('target_warehouse'):
|
||||||
d.rate = flt(d.incoming_rate * d.conversion_factor)
|
rate = flt(d.incoming_rate * d.conversion_factor, d.precision('rate'))
|
||||||
frappe.msgprint(_("Row {0}: Item rate has been updated as per valuation rate since its an internal stock transfer")
|
if d.rate != rate:
|
||||||
.format(d.idx), alert=1)
|
d.rate = rate
|
||||||
|
frappe.msgprint(_("Row {0}: Item rate has been updated as per valuation rate since its an internal stock transfer")
|
||||||
|
.format(d.idx), alert=1)
|
||||||
|
|
||||||
elif self.get("return_against"):
|
elif self.get("return_against"):
|
||||||
# Get incoming rate of return entry from reference document
|
# Get incoming rate of return entry from reference document
|
||||||
|
|||||||
@@ -407,15 +407,15 @@ class StockController(AccountsController):
|
|||||||
self.validate_inter_company_reference()
|
self.validate_inter_company_reference()
|
||||||
|
|
||||||
def validate_in_transit_warehouses(self):
|
def validate_in_transit_warehouses(self):
|
||||||
if self.doctype in ('Sales Invoice', 'Delivery Note'):
|
if (self.doctype == 'Sales Invoice' and self.get('update_stock')) or self.doctype == 'Delivery Note':
|
||||||
for item in self.get('items'):
|
for item in self.get('items'):
|
||||||
if not item.target_warehouse:
|
if not item.target_warehouse:
|
||||||
frappe.throw(_("Row {0}: Target Warehouse is mandatory for internal transfers"))
|
frappe.throw(_("Row {0}: Target Warehouse is mandatory for internal transfers").format(item.idx))
|
||||||
|
|
||||||
if self.doctype in ('Purchase Invoice', 'Purchase Receipt'):
|
if (self.doctype == 'Purchase Invoice' and self.get('update_stock')) or self.doctype == 'Purchase Receipt':
|
||||||
for item in self.get('items'):
|
for item in self.get('items'):
|
||||||
if not item.from_warehouse:
|
if not item.from_warehouse:
|
||||||
frappe.throw(_("Row {0}: From Warehouse is mandatory for internal transfers"))
|
frappe.throw(_("Row {0}: From Warehouse is mandatory for internal transfers").format(item.idx))
|
||||||
|
|
||||||
def validate_multi_currency(self):
|
def validate_multi_currency(self):
|
||||||
if self.currency != self.company_currency:
|
if self.currency != self.company_currency:
|
||||||
@@ -428,9 +428,9 @@ class StockController(AccountsController):
|
|||||||
def validate_inter_company_reference(self):
|
def validate_inter_company_reference(self):
|
||||||
if self.doctype in ('Purchase Invoice', 'Purchase Receipt'):
|
if self.doctype in ('Purchase Invoice', 'Purchase Receipt'):
|
||||||
if not (self.get('inter_company_reference') or self.get('inter_company_invoice_reference')):
|
if not (self.get('inter_company_reference') or self.get('inter_company_invoice_reference')):
|
||||||
msg = _("Internal Sale or Delivery Reference needed for internal purchase")
|
msg = _("Internal Sale or Delivery Reference missing. ")
|
||||||
msg += _("Please create purchase from the internal sale or delivery document itself")
|
msg += _("Please create purchase from internal sale or delivery document itself")
|
||||||
frappe.throw(msg)
|
frappe.throw(msg, title=_("Internal Sales Reference Missing"))
|
||||||
|
|
||||||
def repost_future_sle_and_gle(self):
|
def repost_future_sle_and_gle(self):
|
||||||
args = frappe._dict({
|
args = frappe._dict({
|
||||||
|
|||||||
@@ -655,7 +655,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
args: item_args
|
args: item_args
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
frappe.model.set_value(item.doctype, item.name, 'rate', r.message);
|
frappe.model.set_value(item.doctype, item.name, 'rate', r.message * item.conversion_factor);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -723,7 +723,9 @@ def make_inter_company_transaction(doctype, source_name, target_doc=None):
|
|||||||
"doctype": target_doctype + " Item",
|
"doctype": target_doctype + " Item",
|
||||||
"field_map": {
|
"field_map": {
|
||||||
source_document_warehouse_field: target_document_warehouse_field,
|
source_document_warehouse_field: target_document_warehouse_field,
|
||||||
'name': 'delivery_note_item'
|
'name': 'delivery_note_item',
|
||||||
|
'batch_no': 'batch_no',
|
||||||
|
'serial_no': 'serial_no'
|
||||||
},
|
},
|
||||||
"field_no_map": [
|
"field_no_map": [
|
||||||
"warehouse"
|
"warehouse"
|
||||||
|
|||||||
@@ -1088,7 +1088,9 @@
|
|||||||
"fieldname": "inter_company_reference",
|
"fieldname": "inter_company_reference",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Inter Company Reference",
|
"label": "Inter Company Reference",
|
||||||
|
"no_copy": 1,
|
||||||
"options": "Delivery Note",
|
"options": "Delivery Note",
|
||||||
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1138,7 +1140,7 @@
|
|||||||
"idx": 261,
|
"idx": 261,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-12-26 17:10:00.798835",
|
"modified": "2020-12-26 20:49:39.106049",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Purchase Receipt",
|
"name": "Purchase Receipt",
|
||||||
|
|||||||
@@ -381,13 +381,13 @@ class update_entries_after(object):
|
|||||||
update_taxes_and_totals(sle.voucher_type, sle.voucher_no, outgoing_rate)
|
update_taxes_and_totals(sle.voucher_type, sle.voucher_no, outgoing_rate)
|
||||||
|
|
||||||
purchase_doctype = 'Purchase Invoice' if sle.voucher_type == 'Sales Invoice' else 'Purchase Receipt'
|
purchase_doctype = 'Purchase Invoice' if sle.voucher_type == 'Sales Invoice' else 'Purchase Receipt'
|
||||||
ref_field = frappe.scrub(sle.voucher_type + ' Item')
|
ref_doc_field = frappe.scrub(sle.voucher_type + ' Item')
|
||||||
|
|
||||||
purchase_document_list = frappe.db.get_all(purchase_doctype, {'inter_company_invoice_reference':
|
reference_field = 'inter_company_invoice_reference' if purchase_doctype == 'Purchase Invoice' else 'inter_company_reference'
|
||||||
sle.voucher_no}, ['name'])
|
purchase_document_list = frappe.db.get_all(purchase_doctype, {reference_field: sle.voucher_no}, ['name'])
|
||||||
|
|
||||||
for d in purchase_document_list:
|
for d in purchase_document_list:
|
||||||
frappe.db.set_value(purchase_doctype + ' Item', {ref_field: sle.voucher_detail_no}, 'rate', outgoing_rate)
|
frappe.db.set_value(purchase_doctype + ' Item', {ref_doc_field: sle.voucher_detail_no}, 'rate', outgoing_rate)
|
||||||
update_taxes_and_totals(purchase_doctype, d.name, outgoing_rate)
|
update_taxes_and_totals(purchase_doctype, d.name, outgoing_rate)
|
||||||
|
|
||||||
# Update item's incoming rate on transaction
|
# Update item's incoming rate on transaction
|
||||||
|
|||||||
Reference in New Issue
Block a user