fix: test "test_pending_and_received_qty"
This commit is contained in:
parent
256b4245d5
commit
addd7347d8
@ -4,6 +4,8 @@
|
|||||||
# Decompiled by https://python-decompiler.com
|
# Decompiled by https://python-decompiler.com
|
||||||
|
|
||||||
|
|
||||||
|
import copy
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.tests.utils import FrappeTestCase
|
from frappe.tests.utils import FrappeTestCase
|
||||||
|
|
||||||
@ -11,10 +13,12 @@ from erpnext.buying.report.subcontracted_item_to_be_received.subcontracted_item_
|
|||||||
execute,
|
execute,
|
||||||
)
|
)
|
||||||
from erpnext.controllers.tests.test_subcontracting_controller import (
|
from erpnext.controllers.tests.test_subcontracting_controller import (
|
||||||
|
get_rm_items,
|
||||||
get_subcontracting_order,
|
get_subcontracting_order,
|
||||||
make_service_item,
|
make_service_item,
|
||||||
|
make_stock_in_entry,
|
||||||
|
make_stock_transfer_entry,
|
||||||
)
|
)
|
||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
|
||||||
from erpnext.subcontracting.doctype.subcontracting_order.subcontracting_order import (
|
from erpnext.subcontracting.doctype.subcontracting_order.subcontracting_order import (
|
||||||
make_subcontracting_receipt,
|
make_subcontracting_receipt,
|
||||||
)
|
)
|
||||||
@ -36,15 +40,18 @@ class TestSubcontractedItemToBeReceived(FrappeTestCase):
|
|||||||
sco = get_subcontracting_order(
|
sco = get_subcontracting_order(
|
||||||
service_items=service_items, supplier_warehouse="_Test Warehouse 1 - _TC"
|
service_items=service_items, supplier_warehouse="_Test Warehouse 1 - _TC"
|
||||||
)
|
)
|
||||||
make_stock_entry(
|
rm_items = get_rm_items(sco.supplied_items)
|
||||||
item_code="_Test Item", target="_Test Warehouse 1 - _TC", qty=100, basic_rate=100
|
itemwise_details = make_stock_in_entry(rm_items=rm_items)
|
||||||
)
|
|
||||||
make_stock_entry(
|
for item in rm_items:
|
||||||
item_code="_Test Item Home Desktop 100",
|
item["sco_rm_detail"] = sco.items[0].name
|
||||||
target="_Test Warehouse 1 - _TC",
|
|
||||||
qty=100,
|
make_stock_transfer_entry(
|
||||||
basic_rate=100,
|
sco_no=sco.name,
|
||||||
|
rm_items=rm_items,
|
||||||
|
itemwise_details=copy.deepcopy(itemwise_details),
|
||||||
)
|
)
|
||||||
|
|
||||||
make_subcontracting_receipt_against_sco(sco.name)
|
make_subcontracting_receipt_against_sco(sco.name)
|
||||||
sco.reload()
|
sco.reload()
|
||||||
col, data = execute(
|
col, data = execute(
|
||||||
|
@ -490,7 +490,7 @@ class SubcontractingController(StockController):
|
|||||||
row.item_code,
|
row.item_code,
|
||||||
row.get(self.subcontract_data.order_field),
|
row.get(self.subcontract_data.order_field),
|
||||||
) and transfer_item.qty > 0:
|
) and transfer_item.qty > 0:
|
||||||
qty = self.__get_qty_based_on_material_transfer(row, transfer_item) or 0
|
qty = flt(self.__get_qty_based_on_material_transfer(row, transfer_item))
|
||||||
transfer_item.qty -= qty
|
transfer_item.qty -= qty
|
||||||
self.__add_supplied_item(row, transfer_item.get("item_details"), qty)
|
self.__add_supplied_item(row, transfer_item.get("item_details"), qty)
|
||||||
|
|
||||||
@ -749,7 +749,7 @@ class SubcontractingController(StockController):
|
|||||||
{"item_code": item.rm_item_code, "warehouse": self.supplier_warehouse},
|
{"item_code": item.rm_item_code, "warehouse": self.supplier_warehouse},
|
||||||
"actual_qty",
|
"actual_qty",
|
||||||
)
|
)
|
||||||
item.current_stock = flt(actual_qty) or 0
|
item.current_stock = flt(actual_qty)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sub_contracted_items(self):
|
def sub_contracted_items(self):
|
||||||
|
@ -95,9 +95,7 @@ class SubcontractingOrder(SubcontractingController):
|
|||||||
def set_missing_values_in_items(self):
|
def set_missing_values_in_items(self):
|
||||||
total_qty = total = 0
|
total_qty = total = 0
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
item.rate = (
|
item.rate = item.rm_cost_per_qty + item.service_cost_per_qty + flt(item.additional_cost_per_qty)
|
||||||
item.rm_cost_per_qty + item.service_cost_per_qty + (item.additional_cost_per_qty or 0)
|
|
||||||
)
|
|
||||||
item.amount = item.qty * item.rate
|
item.amount = item.qty * item.rate
|
||||||
total_qty += flt(item.qty)
|
total_qty += flt(item.qty)
|
||||||
total += flt(item.amount)
|
total += flt(item.amount)
|
||||||
@ -168,7 +166,7 @@ class SubcontractingOrder(SubcontractingController):
|
|||||||
total_required_qty = total_supplied_qty = 0
|
total_required_qty = total_supplied_qty = 0
|
||||||
for item in self.supplied_items:
|
for item in self.supplied_items:
|
||||||
total_required_qty += item.required_qty
|
total_required_qty += item.required_qty
|
||||||
total_supplied_qty += item.supplied_qty or 0
|
total_supplied_qty += flt(item.supplied_qty)
|
||||||
if total_supplied_qty:
|
if total_supplied_qty:
|
||||||
status = "Partial Material Transferred"
|
status = "Partial Material Transferred"
|
||||||
if total_supplied_qty >= total_required_qty:
|
if total_supplied_qty >= total_required_qty:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import cint, getdate, nowdate
|
from frappe.utils import cint, flt, getdate, nowdate
|
||||||
|
|
||||||
from erpnext.controllers.subcontracting_controller import SubcontractingController
|
from erpnext.controllers.subcontracting_controller import SubcontractingController
|
||||||
|
|
||||||
@ -128,10 +128,10 @@ class SubcontractingReceipt(SubcontractingController):
|
|||||||
|
|
||||||
if item.recalculate_rate:
|
if item.recalculate_rate:
|
||||||
item.rate = (
|
item.rate = (
|
||||||
item.rm_cost_per_qty + (item.service_cost_per_qty or 0) + item.additional_cost_per_qty
|
flt(item.rm_cost_per_qty) + flt(item.service_cost_per_qty) + flt(item.additional_cost_per_qty)
|
||||||
)
|
)
|
||||||
|
|
||||||
item.received_qty = item.qty + (item.rejected_qty or 0)
|
item.received_qty = item.qty + flt(item.rejected_qty)
|
||||||
item.amount = item.qty * item.rate
|
item.amount = item.qty * item.rate
|
||||||
total_qty += item.qty
|
total_qty += item.qty
|
||||||
total_amount += item.amount
|
total_amount += item.amount
|
||||||
|
Loading…
Reference in New Issue
Block a user