2
0

[FIX] calculate day mistake, remove asset

This commit is contained in:
Saran440 2022-01-20 16:26:01 +07:00 committed by Rodrigo
parent 9000d51a55
commit 6a8c389b78
2 changed files with 9 additions and 4 deletions

View File

@ -524,8 +524,8 @@ class TestAssetManagement(AccountTestInvoicingCommon):
wiz.remove()
asset.refresh()
self.assertEqual(len(asset.depreciation_line_ids), 3)
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 83.33, places=2)
self.assertAlmostEqual(asset.depreciation_line_ids[2].amount, 4916.67, places=2)
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, 81.46, places=2)
self.assertAlmostEqual(asset.depreciation_line_ids[2].amount, 4918.54, places=2)
def test_09_asset_from_invoice(self):
all_asset = self.env["account.asset"].search([])

View File

@ -273,9 +273,14 @@ class AccountAssetRemove(models.TransientModel):
)
last_depr_date = create_dl.line_date
period_number_days = (first_date - last_depr_date).days + 1
# Never create move.
same_month = (
last_depr_date.month == first_to_depreciate_dl.line_date.month and 1 or 0
)
period_number_days = (first_date - last_depr_date).days + same_month
new_line_date = date_remove + relativedelta(days=-1)
to_depreciate_days = (new_line_date - last_depr_date).days + 1
to_depreciate_days = (new_line_date - last_depr_date).days + same_month
to_depreciate_amount = round(
float(to_depreciate_days)
/ float(period_number_days)