Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests invoice #8

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// Copyright (c) 2024, Navari Ltd and contributors
// For license information, please see license.txt
const doctypeName = 'Navari eTims Registered Purchases';
const doctypeName = "Navari eTims Registered Purchases";

frappe.ui.form.on(doctypeName, {
refresh: function (frm) {
const companyName = frappe.boot.sysdefaults.company;

if (!frm.is_new()) {
frm.add_custom_button(
__('Create Supplier'),
__("Create Supplier"),
function () {
frappe.call({
method:
'kenya_compliance.kenya_compliance.apis.apis.create_supplier_from_fetched_registered_purchases',
"kenya_compliance.kenya_compliance.apis.apis.create_supplier_from_fetched_registered_purchases",
args: {
request_data: {
name: frm.doc.name,
Expand All @@ -28,14 +28,14 @@ frappe.ui.form.on(doctypeName, {
},
});
},
__('eTims Actions'),
__("eTims Actions")
);
frm.add_custom_button(
__('Create Items'),
__("Create Items"),
function () {
frappe.call({
method:
'kenya_compliance.kenya_compliance.apis.apis.create_items_from_fetched_registered_purchases',
"kenya_compliance.kenya_compliance.apis.apis.create_items_from_fetched_registered_purchases",
args: {
request_data: {
name: frm.doc.name,
Expand All @@ -49,14 +49,14 @@ frappe.ui.form.on(doctypeName, {
},
});
},
__('eTims Actions'),
__("eTims Actions")
);
frm.add_custom_button(
__('Create Purchase Invoice'),
__("Create Purchase Invoice"),
function () {
frappe.call({
method:
'kenya_compliance.kenya_compliance.apis.apis.create_purchase_invoice_from_request',
"kenya_compliance.kenya_compliance.apis.apis.create_purchase_invoice_from_request",
args: {
request_data: {
name: frm.doc.name,
Expand All @@ -75,7 +75,7 @@ frappe.ui.form.on(doctypeName, {
},
});
},
__('eTims Actions'),
__("eTims Actions")
);
// frm.add_custom_button(
// __("Create Purchase Receipt"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,4 @@ def test_auto_creation_of_acct_dimension(self) -> None:
new_setting.save()

self.assertTrue(frappe.db.exists("Accounting Dimension", "Branch", cache=False))

Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
const parentDoctype = 'Purchase Invoice';
const settingsDoctypeName = 'Navari KRA eTims Settings';
const parentDoctype = "Purchase Invoice";
const settingsDoctypeName = "Navari KRA eTims Settings";

frappe.ui.form.on(parentDoctype, {
refresh: function (frm) {
frm.set_value('update_stock', 1);
frm.set_value("update_stock", 1);
if (frm.doc.update_stock === 1) {
frm.toggle_reqd('set_warehouse', true);
frm.toggle_reqd("set_warehouse", true);
}
},
validate: function (frm) {
frappe.db.get_value(
settingsDoctypeName,
{
is_active: 1,
bhfid: frm.doc.branch ?? '00',
company: frappe.defaults.get_user_default('Company'),
bhfid: frm.doc.branch ?? "00",
company: frappe.defaults.get_user_default("Company"),
},
[
'name',
'company',
'bhfid',
'purchases_purchase_type',
'purchases_receipt_type',
'purchases_payment_type',
'purchases_purchase_status',
"name",
"company",
"bhfid",
"purchases_purchase_type",
"purchases_receipt_type",
"purchases_payment_type",
"purchases_purchase_status",
],
(response) => {
if (!frm.doc.custom_purchase_type) {
frm.set_value(
'custom_purchase_type',
response.purchases_purchase_type,
"custom_purchase_type",
response.purchases_purchase_type
);
}
if (!frm.doc.custom_receipt_type) {
frm.set_value('custom_receipt_type', response.purchases_receipt_type);
frm.set_value("custom_receipt_type", response.purchases_receipt_type);
}
if (!frm.doc.custom_purchase_status) {
frm.set_value(
'custom_purchase_status',
response.purchases_purchase_status,
"custom_purchase_status",
response.purchases_purchase_status
);
}
if (!frm.doc.custom_payment_type) {
frm.set_value('custom_payment_type', response.purchases_payment_type);
frm.set_value("custom_payment_type", response.purchases_payment_type);
}
},
}
);
},
});
52 changes: 26 additions & 26 deletions kenya_compliance/kenya_compliance/overrides/client/sales_invoice.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const parentDoctype = 'Sales Invoice';
const parentDoctype = "Sales Invoice";
const childDoctype = `${parentDoctype} Item`;
const packagingUnitDoctypeName = 'Navari eTims Packaging Unit';
const unitOfQuantityDoctypeName = 'Navari eTims Unit of Quantity';
const taxationTypeDoctypeName = 'Navari KRA eTims Taxation Type';
const settingsDoctypeName = 'Navari KRA eTims Settings';
const packagingUnitDoctypeName = "Navari eTims Packaging Unit";
const unitOfQuantityDoctypeName = "Navari eTims Unit of Quantity";
const taxationTypeDoctypeName = "Navari KRA eTims Taxation Type";
const settingsDoctypeName = "Navari KRA eTims Settings";

frappe.ui.form.on(parentDoctype, {
refresh: function (frm) {
frm.set_value('update_stock', 1);
frm.set_value("update_stock", 1);
if (frm.doc.update_stock === 1) {
frm.toggle_reqd('set_warehouse', true);
frm.toggle_reqd("set_warehouse", true);
}
},
validate: function (frm) {
Expand All @@ -18,26 +18,26 @@ frappe.ui.form.on(parentDoctype, {
{
is_active: 1,
bhfid: frm.doc.branch,
company: frappe.defaults.get_user_default('Company'),
company: frappe.defaults.get_user_default("Company"),
},
[
'name',
'company',
'bhfid',
'sales_payment_type',
'sales_transaction_progress',
"name",
"company",
"bhfid",
"sales_payment_type",
"sales_transaction_progress",
],
(response) => {
if (!frm.doc.custom_payment_type) {
frm.set_value('custom_payment_type', response.sales_payment_type);
frm.set_value("custom_payment_type", response.sales_payment_type);
}
if (!frm.doc.custom_transaction_progres) {
frm.set_value(
'custom_transaction_progres',
response.sales_transaction_progress,
"custom_transaction_progres",
response.sales_transaction_progress
);
}
},
}
);
},
});
Expand All @@ -49,14 +49,14 @@ frappe.ui.form.on(childDoctype, {

if (!taxationType) {
frappe.db.get_value(
'Item',
"Item",
{ item_code: item },
['custom_taxation_type'],
["custom_taxation_type"],
(response) => {
locals[cdt][cdn].custom_taxation_type = response.custom_taxation_type;
locals[cdt][cdn].custom_taxation_type_code =
response.custom_taxation_type;
},
}
);
}
},
Expand All @@ -69,12 +69,12 @@ frappe.ui.form.on(childDoctype, {
{
name: packagingUnit,
},
['code'],
["code"],
(response) => {
const code = response.code;
locals[cdt][cdn].custom_packaging_unit_code = code;
frm.refresh_field('custom_packaging_unit_code');
},
frm.refresh_field("custom_packaging_unit_code");
}
);
}
},
Expand All @@ -87,12 +87,12 @@ frappe.ui.form.on(childDoctype, {
{
name: unitOfQuantity,
},
['code'],
["code"],
(response) => {
const code = response.code;
locals[cdt][cdn].custom_unit_of_quantity_code = code;
frm.refresh_field('custom_unit_of_quantity_code');
},
frm.refresh_field("custom_unit_of_quantity_code");
}
);
}
},
Expand Down
2 changes: 1 addition & 1 deletion kenya_compliance/kenya_compliance/overrides/server/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
def before_insert(doc: Document, method: str) -> None:
"""Item doctype before insertion hook"""

item_registration_data = {
item_registration_data = {
"name": doc.name,
"company_name": frappe.defaults.get_user_default("Company"),
"itemCd": doc.custom_item_code_etims,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ def on_submit(doc: Document, method: str) -> None:
"""Intercepts POS invoice on submit event"""

if not doc.custom_successfully_submitted:
generic_invoices_on_submit_override(doc, "POS Invoice")
generic_invoices_on_submit_override(doc, "POS Invoice")
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def build_purchase_invoice_payload(doc: Document) -> dict:
"taxblAmtB": doc.custom_taxbl_amount_b or 0,
"taxblAmtC": doc.custom_taxbl_amount_c or 0,
"taxblAmtD": doc.custom_taxbl_amount_d or 0,
"taxblAmtE": doc.custom_taxbl_amount_e or 0,
"taxblAmtE": doc.custom_taxbl_amount_e or 0,
"taxRtA": 0,
"taxRtB": 16 if doc.custom_tax_b else 0,
"taxRtC": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def generic_invoices_on_submit_override(
timeout=300,
job_name=f"{doc.name}_send_sales_request",
doctype=invoice_type,
document_name=doc.name,
document_name=doc.name,
)


Expand Down
Loading