Merge branch 'develop' into fix-reserve-qty
This commit is contained in:
commit
46afbb594a
@ -135,6 +135,34 @@ def get_assets(filters):
|
|||||||
where a.docstatus=1 and a.company=%(company)s and a.purchase_date <= %(to_date)s and ads.asset = a.name and ads.docstatus=1 and ads.name = ds.parent and ifnull(ds.journal_entry, '') != ''
|
where a.docstatus=1 and a.company=%(company)s and a.purchase_date <= %(to_date)s and ads.asset = a.name and ads.docstatus=1 and ads.name = ds.parent and ifnull(ds.journal_entry, '') != ''
|
||||||
group by a.asset_category
|
group by a.asset_category
|
||||||
union
|
union
|
||||||
|
SELECT a.asset_category,
|
||||||
|
ifnull(sum(case when gle.posting_date < %(from_date)s and (ifnull(a.disposal_date, 0) = 0 or a.disposal_date >= %(from_date)s) then
|
||||||
|
gle.debit
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end), 0) as accumulated_depreciation_as_on_from_date,
|
||||||
|
ifnull(sum(case when ifnull(a.disposal_date, 0) != 0 and a.disposal_date >= %(from_date)s
|
||||||
|
and a.disposal_date <= %(to_date)s and gle.posting_date <= a.disposal_date then
|
||||||
|
gle.debit
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end), 0) as depreciation_eliminated_during_the_period,
|
||||||
|
ifnull(sum(case when gle.posting_date >= %(from_date)s and gle.posting_date <= %(to_date)s
|
||||||
|
and (ifnull(a.disposal_date, 0) = 0 or gle.posting_date <= a.disposal_date) then
|
||||||
|
gle.debit
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end), 0) as depreciation_amount_during_the_period
|
||||||
|
from `tabGL Entry` gle
|
||||||
|
join `tabAsset` a on
|
||||||
|
gle.against_voucher = a.name
|
||||||
|
join `tabAsset Category Account` aca on
|
||||||
|
aca.parent = a.asset_category and aca.company_name = %(company)s
|
||||||
|
join `tabCompany` company on
|
||||||
|
company.name = %(company)s
|
||||||
|
where a.docstatus=1 and a.company=%(company)s and a.calculate_depreciation=0 and a.purchase_date <= %(to_date)s and gle.debit != 0 and gle.is_cancelled = 0 and gle.account = ifnull(aca.depreciation_expense_account, company.depreciation_expense_account)
|
||||||
|
group by a.asset_category
|
||||||
|
union
|
||||||
SELECT a.asset_category,
|
SELECT a.asset_category,
|
||||||
ifnull(sum(case when ifnull(a.disposal_date, 0) != 0 and (a.disposal_date < %(from_date)s or a.disposal_date > %(to_date)s) then
|
ifnull(sum(case when ifnull(a.disposal_date, 0) != 0 and (a.disposal_date < %(from_date)s or a.disposal_date > %(to_date)s) then
|
||||||
0
|
0
|
||||||
|
|||||||
@ -209,20 +209,19 @@ frappe.ui.form.on('Asset', {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var x_intervals = [frm.doc.purchase_date];
|
var x_intervals = [frappe.format(frm.doc.purchase_date, { fieldtype: 'Date' })];
|
||||||
var asset_values = [frm.doc.gross_purchase_amount];
|
var asset_values = [frm.doc.gross_purchase_amount];
|
||||||
var last_depreciation_date = frm.doc.purchase_date;
|
|
||||||
|
|
||||||
if(frm.doc.opening_accumulated_depreciation) {
|
|
||||||
last_depreciation_date = frappe.datetime.add_months(frm.doc.next_depreciation_date,
|
|
||||||
-1*frm.doc.frequency_of_depreciation);
|
|
||||||
|
|
||||||
x_intervals.push(last_depreciation_date);
|
|
||||||
asset_values.push(flt(frm.doc.gross_purchase_amount) -
|
|
||||||
flt(frm.doc.opening_accumulated_depreciation));
|
|
||||||
}
|
|
||||||
if(frm.doc.calculate_depreciation) {
|
if(frm.doc.calculate_depreciation) {
|
||||||
if (frm.doc.finance_books.length == 1) {
|
if(frm.doc.opening_accumulated_depreciation) {
|
||||||
|
var depreciation_date = frappe.datetime.add_months(
|
||||||
|
frm.doc.finance_books[0].depreciation_start_date,
|
||||||
|
-1 * frm.doc.finance_books[0].frequency_of_depreciation
|
||||||
|
);
|
||||||
|
x_intervals.push(frappe.format(depreciation_date, { fieldtype: 'Date' }));
|
||||||
|
asset_values.push(flt(frm.doc.gross_purchase_amount - frm.doc.opening_accumulated_depreciation, precision('gross_purchase_amount')));
|
||||||
|
}
|
||||||
|
|
||||||
let depr_schedule = (await frappe.call(
|
let depr_schedule = (await frappe.call(
|
||||||
"erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule.get_depr_schedule",
|
"erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule.get_depr_schedule",
|
||||||
{
|
{
|
||||||
@ -233,10 +232,9 @@ frappe.ui.form.on('Asset', {
|
|||||||
)).message;
|
)).message;
|
||||||
|
|
||||||
$.each(depr_schedule || [], function(i, v) {
|
$.each(depr_schedule || [], function(i, v) {
|
||||||
x_intervals.push(v.schedule_date);
|
x_intervals.push(frappe.format(v.schedule_date, { fieldtype: 'Date' }));
|
||||||
var asset_value = flt(frm.doc.gross_purchase_amount) - flt(v.accumulated_depreciation_amount);
|
var asset_value = flt(frm.doc.gross_purchase_amount - v.accumulated_depreciation_amount, precision('gross_purchase_amount'));
|
||||||
if(v.journal_entry) {
|
if(v.journal_entry) {
|
||||||
last_depreciation_date = v.schedule_date;
|
|
||||||
asset_values.push(asset_value);
|
asset_values.push(asset_value);
|
||||||
} else {
|
} else {
|
||||||
if (in_list(["Scrapped", "Sold"], frm.doc.status)) {
|
if (in_list(["Scrapped", "Sold"], frm.doc.status)) {
|
||||||
@ -246,25 +244,27 @@ frappe.ui.form.on('Asset', {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
if(frm.doc.opening_accumulated_depreciation) {
|
||||||
|
x_intervals.push(frappe.format(frm.doc.creation.split(" ")[0], { fieldtype: 'Date' }));
|
||||||
|
asset_values.push(flt(frm.doc.gross_purchase_amount - frm.doc.opening_accumulated_depreciation, precision('gross_purchase_amount')));
|
||||||
|
}
|
||||||
|
|
||||||
let depr_entries = (await frappe.call({
|
let depr_entries = (await frappe.call({
|
||||||
method: "get_manual_depreciation_entries",
|
method: "get_manual_depreciation_entries",
|
||||||
doc: frm.doc,
|
doc: frm.doc,
|
||||||
})).message;
|
})).message;
|
||||||
|
|
||||||
$.each(depr_entries || [], function(i, v) {
|
$.each(depr_entries || [], function(i, v) {
|
||||||
x_intervals.push(v.posting_date);
|
x_intervals.push(frappe.format(v.posting_date, { fieldtype: 'Date' }));
|
||||||
last_depreciation_date = v.posting_date;
|
|
||||||
let last_asset_value = asset_values[asset_values.length - 1]
|
let last_asset_value = asset_values[asset_values.length - 1]
|
||||||
asset_values.push(last_asset_value - v.value);
|
asset_values.push(last_asset_value - v.value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(in_list(["Scrapped", "Sold"], frm.doc.status)) {
|
if(in_list(["Scrapped", "Sold"], frm.doc.status)) {
|
||||||
x_intervals.push(frm.doc.disposal_date);
|
x_intervals.push(frappe.format(frm.doc.disposal_date, { fieldtype: 'Date' }));
|
||||||
asset_values.push(0);
|
asset_values.push(0);
|
||||||
last_depreciation_date = frm.doc.disposal_date;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
frm.dashboard.render_graph({
|
frm.dashboard.render_graph({
|
||||||
|
|||||||
@ -429,25 +429,16 @@ class Asset(AccountsController):
|
|||||||
|
|
||||||
def get_value_after_depreciation(self, finance_book=None):
|
def get_value_after_depreciation(self, finance_book=None):
|
||||||
if not self.calculate_depreciation:
|
if not self.calculate_depreciation:
|
||||||
return self.value_after_depreciation
|
return flt(self.value_after_depreciation, self.precision("gross_purchase_amount"))
|
||||||
|
|
||||||
if not finance_book:
|
if not finance_book:
|
||||||
return self.get("finance_books")[0].value_after_depreciation
|
return flt(
|
||||||
|
self.get("finance_books")[0].value_after_depreciation, self.precision("gross_purchase_amount")
|
||||||
|
)
|
||||||
|
|
||||||
for row in self.get("finance_books"):
|
for row in self.get("finance_books"):
|
||||||
if finance_book == row.finance_book:
|
if finance_book == row.finance_book:
|
||||||
return row.value_after_depreciation
|
return flt(row.value_after_depreciation, self.precision("gross_purchase_amount"))
|
||||||
|
|
||||||
def _get_value_after_depreciation_for_making_schedule(self, fb_row):
|
|
||||||
# value_after_depreciation - current Asset value
|
|
||||||
if self.docstatus == 1 and fb_row.value_after_depreciation:
|
|
||||||
value_after_depreciation = flt(fb_row.value_after_depreciation)
|
|
||||||
else:
|
|
||||||
value_after_depreciation = flt(self.gross_purchase_amount) - flt(
|
|
||||||
self.opening_accumulated_depreciation
|
|
||||||
)
|
|
||||||
|
|
||||||
return value_after_depreciation
|
|
||||||
|
|
||||||
def get_default_finance_book_idx(self):
|
def get_default_finance_book_idx(self):
|
||||||
if not self.get("default_finance_book") and self.company:
|
if not self.get("default_finance_book") and self.company:
|
||||||
|
|||||||
@ -134,7 +134,7 @@ class AssetDepreciationSchedule(Document):
|
|||||||
):
|
):
|
||||||
asset_doc.validate_asset_finance_books(row)
|
asset_doc.validate_asset_finance_books(row)
|
||||||
|
|
||||||
value_after_depreciation = asset_doc._get_value_after_depreciation_for_making_schedule(row)
|
value_after_depreciation = _get_value_after_depreciation_for_making_schedule(asset_doc, row)
|
||||||
row.value_after_depreciation = value_after_depreciation
|
row.value_after_depreciation = value_after_depreciation
|
||||||
|
|
||||||
if update_asset_finance_book_row:
|
if update_asset_finance_book_row:
|
||||||
@ -325,6 +325,17 @@ class AssetDepreciationSchedule(Document):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_value_after_depreciation_for_making_schedule(asset_doc, fb_row):
|
||||||
|
if asset_doc.docstatus == 1 and fb_row.value_after_depreciation:
|
||||||
|
value_after_depreciation = flt(fb_row.value_after_depreciation)
|
||||||
|
else:
|
||||||
|
value_after_depreciation = flt(asset_doc.gross_purchase_amount) - flt(
|
||||||
|
asset_doc.opening_accumulated_depreciation
|
||||||
|
)
|
||||||
|
|
||||||
|
return value_after_depreciation
|
||||||
|
|
||||||
|
|
||||||
def make_draft_asset_depr_schedules_if_not_present(asset_doc):
|
def make_draft_asset_depr_schedules_if_not_present(asset_doc):
|
||||||
for row in asset_doc.get("finance_books"):
|
for row in asset_doc.get("finance_books"):
|
||||||
draft_asset_depr_schedule_name = get_asset_depr_schedule_name(
|
draft_asset_depr_schedule_name = get_asset_depr_schedule_name(
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.query_builder.functions import Sum
|
from frappe.query_builder.functions import Sum
|
||||||
from frappe.utils import cstr, formatdate, getdate
|
from frappe.utils import cstr, flt, formatdate, getdate
|
||||||
|
|
||||||
from erpnext.accounts.report.financial_statements import (
|
from erpnext.accounts.report.financial_statements import (
|
||||||
get_fiscal_year_data,
|
get_fiscal_year_data,
|
||||||
@ -102,13 +102,9 @@ def get_data(filters):
|
|||||||
]
|
]
|
||||||
assets_record = frappe.db.get_all("Asset", filters=conditions, fields=fields)
|
assets_record = frappe.db.get_all("Asset", filters=conditions, fields=fields)
|
||||||
|
|
||||||
finance_book_filter = ("is", "not set")
|
|
||||||
if filters.finance_book:
|
|
||||||
finance_book_filter = ("=", filters.finance_book)
|
|
||||||
|
|
||||||
assets_linked_to_fb = frappe.db.get_all(
|
assets_linked_to_fb = frappe.db.get_all(
|
||||||
doctype="Asset Finance Book",
|
doctype="Asset Finance Book",
|
||||||
filters={"finance_book": finance_book_filter},
|
filters={"finance_book": filters.finance_book or ("is", "not set")},
|
||||||
pluck="parent",
|
pluck="parent",
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -194,7 +190,7 @@ def get_depreciation_amount_of_asset(asset, depreciation_amount_map, filters):
|
|||||||
else:
|
else:
|
||||||
depr_amount = get_manual_depreciation_amount_of_asset(asset, filters)
|
depr_amount = get_manual_depreciation_amount_of_asset(asset, filters)
|
||||||
|
|
||||||
return depr_amount
|
return flt(depr_amount, 2)
|
||||||
|
|
||||||
|
|
||||||
def get_finance_book_value_map(filters):
|
def get_finance_book_value_map(filters):
|
||||||
|
|||||||
@ -124,12 +124,11 @@ frappe.ui.form.on("Request for Quotation",{
|
|||||||
frappe.urllib.get_full_url(
|
frappe.urllib.get_full_url(
|
||||||
"/api/method/erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_pdf?" +
|
"/api/method/erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_pdf?" +
|
||||||
new URLSearchParams({
|
new URLSearchParams({
|
||||||
doctype: frm.doc.doctype,
|
|
||||||
name: frm.doc.name,
|
name: frm.doc.name,
|
||||||
supplier: data.supplier,
|
supplier: data.supplier,
|
||||||
print_format: data.print_format || "Standard",
|
print_format: data.print_format || "Standard",
|
||||||
language: data.language || frappe.boot.lang,
|
language: data.language || frappe.boot.lang,
|
||||||
letter_head: data.letter_head || frm.doc.letter_head || "",
|
letterhead: data.letter_head || frm.doc.letter_head || "",
|
||||||
}).toString()
|
}).toString()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
@ -388,26 +389,28 @@ def create_rfq_items(sq_doc, supplier, data):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_pdf(doctype, name, supplier, print_format=None, language=None, letter_head=None):
|
def get_pdf(
|
||||||
|
name: str,
|
||||||
|
supplier: str,
|
||||||
|
print_format: Optional[str] = None,
|
||||||
|
language: Optional[str] = None,
|
||||||
|
letterhead: Optional[str] = None,
|
||||||
|
):
|
||||||
|
doc = frappe.get_doc("Request for Quotation", name)
|
||||||
|
if supplier:
|
||||||
|
doc.update_supplier_part_no(supplier)
|
||||||
|
|
||||||
# permissions get checked in `download_pdf`
|
# permissions get checked in `download_pdf`
|
||||||
if doc := get_rfq_doc(doctype, name, supplier):
|
|
||||||
download_pdf(
|
download_pdf(
|
||||||
doctype,
|
doc.doctype,
|
||||||
name,
|
doc.name,
|
||||||
print_format,
|
print_format,
|
||||||
doc=doc,
|
doc=doc,
|
||||||
language=language,
|
language=language,
|
||||||
letter_head=letter_head or None,
|
letterhead=letterhead or None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_rfq_doc(doctype, name, supplier):
|
|
||||||
if supplier:
|
|
||||||
doc = frappe.get_doc(doctype, name)
|
|
||||||
doc.update_supplier_part_no(supplier)
|
|
||||||
return doc
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_item_from_material_requests_based_on_supplier(source_name, target_doc=None):
|
def get_item_from_material_requests_based_on_supplier(source_name, target_doc=None):
|
||||||
mr_items_list = frappe.db.sql(
|
mr_items_list = frappe.db.sql(
|
||||||
|
|||||||
@ -8,6 +8,7 @@ from frappe.utils import nowdate
|
|||||||
|
|
||||||
from erpnext.buying.doctype.request_for_quotation.request_for_quotation import (
|
from erpnext.buying.doctype.request_for_quotation.request_for_quotation import (
|
||||||
create_supplier_quotation,
|
create_supplier_quotation,
|
||||||
|
get_pdf,
|
||||||
make_supplier_quotation_from_rfq,
|
make_supplier_quotation_from_rfq,
|
||||||
)
|
)
|
||||||
from erpnext.crm.doctype.opportunity.opportunity import make_request_for_quotation as make_rfq
|
from erpnext.crm.doctype.opportunity.opportunity import make_request_for_quotation as make_rfq
|
||||||
@ -124,6 +125,11 @@ class TestRequestforQuotation(FrappeTestCase):
|
|||||||
rfq.status = "Draft"
|
rfq.status = "Draft"
|
||||||
rfq.submit()
|
rfq.submit()
|
||||||
|
|
||||||
|
def test_get_pdf(self):
|
||||||
|
rfq = make_request_for_quotation()
|
||||||
|
get_pdf(rfq.name, rfq.get("suppliers")[0].supplier)
|
||||||
|
self.assertEqual(frappe.local.response.type, "pdf")
|
||||||
|
|
||||||
|
|
||||||
def make_request_for_quotation(**args):
|
def make_request_for_quotation(**args):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -110,8 +110,11 @@ frappe.ui.form.on('Material Request', {
|
|||||||
|
|
||||||
if (frm.doc.material_request_type === "Material Transfer") {
|
if (frm.doc.material_request_type === "Material Transfer") {
|
||||||
add_create_pick_list_button();
|
add_create_pick_list_button();
|
||||||
frm.add_custom_button(__("Transfer Material"),
|
frm.add_custom_button(__("Material Transfer"),
|
||||||
() => frm.events.make_stock_entry(frm), __('Create'));
|
() => frm.events.make_stock_entry(frm), __('Create'));
|
||||||
|
|
||||||
|
frm.add_custom_button(__("Material Transfer (In Transit)"),
|
||||||
|
() => frm.events.make_in_transit_stock_entry(frm), __('Create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frm.doc.material_request_type === "Material Issue") {
|
if (frm.doc.material_request_type === "Material Issue") {
|
||||||
@ -333,6 +336,46 @@ frappe.ui.form.on('Material Request', {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
make_in_transit_stock_entry(frm) {
|
||||||
|
frappe.prompt(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
label: __('In Transit Warehouse'),
|
||||||
|
fieldname: 'in_transit_warehouse',
|
||||||
|
fieldtype: 'Link',
|
||||||
|
options: 'Warehouse',
|
||||||
|
reqd: 1,
|
||||||
|
get_query: () => {
|
||||||
|
return{
|
||||||
|
filters: {
|
||||||
|
'company': frm.doc.company,
|
||||||
|
'is_group': 0,
|
||||||
|
'warehouse_type': 'Transit'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
(values) => {
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.stock.doctype.material_request.material_request.make_in_transit_stock_entry",
|
||||||
|
args: {
|
||||||
|
source_name: frm.doc.name,
|
||||||
|
in_transit_warehouse: values.in_transit_warehouse
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
if (r.message) {
|
||||||
|
let doc = frappe.model.sync(r.message);
|
||||||
|
frappe.set_route('Form', doc[0].doctype, doc[0].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
__('In Transit Transfer'),
|
||||||
|
__("Create Stock Entry")
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
create_pick_list: (frm) => {
|
create_pick_list: (frm) => {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.stock.doctype.material_request.material_request.create_pick_list",
|
method: "erpnext.stock.doctype.material_request.material_request.create_pick_list",
|
||||||
|
|||||||
@ -716,3 +716,14 @@ def create_pick_list(source_name, target_doc=None):
|
|||||||
doc.set_item_locations()
|
doc.set_item_locations()
|
||||||
|
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def make_in_transit_stock_entry(source_name, in_transit_warehouse):
|
||||||
|
ste_doc = make_stock_entry(source_name)
|
||||||
|
ste_doc.add_to_transit = 1
|
||||||
|
|
||||||
|
for row in ste_doc.items:
|
||||||
|
row.t_warehouse = in_transit_warehouse
|
||||||
|
|
||||||
|
return ste_doc
|
||||||
|
|||||||
@ -11,6 +11,7 @@ from frappe.utils import flt, today
|
|||||||
|
|
||||||
from erpnext.stock.doctype.item.test_item import create_item
|
from erpnext.stock.doctype.item.test_item import create_item
|
||||||
from erpnext.stock.doctype.material_request.material_request import (
|
from erpnext.stock.doctype.material_request.material_request import (
|
||||||
|
make_in_transit_stock_entry,
|
||||||
make_purchase_order,
|
make_purchase_order,
|
||||||
make_stock_entry,
|
make_stock_entry,
|
||||||
make_supplier_quotation,
|
make_supplier_quotation,
|
||||||
@ -56,6 +57,22 @@ class TestMaterialRequest(FrappeTestCase):
|
|||||||
self.assertEqual(se.doctype, "Stock Entry")
|
self.assertEqual(se.doctype, "Stock Entry")
|
||||||
self.assertEqual(len(se.get("items")), len(mr.get("items")))
|
self.assertEqual(len(se.get("items")), len(mr.get("items")))
|
||||||
|
|
||||||
|
def test_in_transit_make_stock_entry(self):
|
||||||
|
mr = frappe.copy_doc(test_records[0]).insert()
|
||||||
|
|
||||||
|
self.assertRaises(frappe.ValidationError, make_stock_entry, mr.name)
|
||||||
|
|
||||||
|
mr = frappe.get_doc("Material Request", mr.name)
|
||||||
|
mr.material_request_type = "Material Transfer"
|
||||||
|
mr.submit()
|
||||||
|
|
||||||
|
in_transit_warehouse = get_in_transit_warehouse(mr.company)
|
||||||
|
se = make_in_transit_stock_entry(mr.name, in_transit_warehouse)
|
||||||
|
|
||||||
|
self.assertEqual(se.doctype, "Stock Entry")
|
||||||
|
for row in se.get("items"):
|
||||||
|
self.assertEqual(row.t_warehouse, in_transit_warehouse)
|
||||||
|
|
||||||
def _insert_stock_entry(self, qty1, qty2, warehouse=None):
|
def _insert_stock_entry(self, qty1, qty2, warehouse=None):
|
||||||
se = frappe.get_doc(
|
se = frappe.get_doc(
|
||||||
{
|
{
|
||||||
@ -742,6 +759,36 @@ class TestMaterialRequest(FrappeTestCase):
|
|||||||
self.assertEqual(existing_requested_qty, current_requested_qty)
|
self.assertEqual(existing_requested_qty, current_requested_qty)
|
||||||
|
|
||||||
|
|
||||||
|
def get_in_transit_warehouse(company):
|
||||||
|
if not frappe.db.exists("Warehouse Type", "Transit"):
|
||||||
|
frappe.get_doc(
|
||||||
|
{
|
||||||
|
"doctype": "Warehouse Type",
|
||||||
|
"name": "Transit",
|
||||||
|
}
|
||||||
|
).insert()
|
||||||
|
|
||||||
|
in_transit_warehouse = frappe.db.exists(
|
||||||
|
"Warehouse", {"warehouse_type": "Transit", "company": company}
|
||||||
|
)
|
||||||
|
|
||||||
|
if not in_transit_warehouse:
|
||||||
|
in_transit_warehouse = (
|
||||||
|
frappe.get_doc(
|
||||||
|
{
|
||||||
|
"doctype": "Warehouse",
|
||||||
|
"warehouse_name": "Transit",
|
||||||
|
"warehouse_type": "Transit",
|
||||||
|
"company": company,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.insert()
|
||||||
|
.name
|
||||||
|
)
|
||||||
|
|
||||||
|
return in_transit_warehouse
|
||||||
|
|
||||||
|
|
||||||
def make_material_request(**args):
|
def make_material_request(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
mr = frappe.new_doc("Material Request")
|
mr = frappe.new_doc("Material Request")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user